Skip to content

Commit

Permalink
docs(readme.md): fix badge link
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Hundeloh committed Sep 10, 2019
2 parents 1d187b7 + 99ed4e3 commit 09d3083
Show file tree
Hide file tree
Showing 6 changed files with 2,866 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: dev
on:
pull_request:
branches:
- dev
- master

jobs:
build:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
run: yarn install
- name: yarn ci
run: yarn ci
- name: publish
uses: actions/npm@master
args: publish --access public
- name: semantic release
run: npx semantic-release
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_ACTION: true
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
"description": "Another parser for advanced search query syntax.",
"main": "build/cjs/src/index.js",
"module": "build/esm/src/index.js",
"types": "build/cjs/index.d.ts",
"types": "build/cjs/src/index.d.ts",
"files": [
"src",
"build"
],
"scripts": {
"build": "ts-build . --cjs --esm --out-dir build",
"ci": "npm run test && npm run build",
"prepublish": "npm run ci",
"ci": "yarn test && yarn build",
"prepare": "yarn build",
"prepublishOnly": "yarn ci",
"test": "jest",
"testWatch": "jest --watch"
"testWatch": "jest --watch",
"semantic-release": "semantic-release"
},
"author": "Julian Hundeloh <[email protected]> (https://approvals.cloud)",
"license": "MIT",
Expand All @@ -36,7 +38,8 @@
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1"
"pretty-quick": "^1.11.1",
"semantic-release": "^15.13.19"
},
"config": {
"commitizen": {
Expand Down
25 changes: 11 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { getQuotePairMap } from './utils'

// types
const RESET = 'RESET'
const IN_OPERAND = 'IN_OPERAND'
const IN_TEXT = 'IN_TEXT'
const SINGLE_QUOTE = 'SINGLE_QUOTE'
const DOUBLE_QUOTE = 'DOUBLE_QUOTE'

type State = typeof RESET | typeof IN_OPERAND | typeof IN_TEXT
type QuoteState = typeof RESET | typeof SINGLE_QUOTE | typeof DOUBLE_QUOTE
type Keyword = Exclude<string, 'exclude'>
Expand All @@ -12,13 +17,6 @@ type ParsedQuery = Record<string, any> & {
exclude: Record<string, Value[]>
}

// state tokens
const RESET = 'RESET'
const IN_OPERAND = 'IN_OPERAND'
const IN_TEXT = 'IN_TEXT'
const SINGLE_QUOTE = 'SINGLE_QUOTE'
const DOUBLE_QUOTE = 'DOUBLE_QUOTE'

/**
* AdvancedSearchQuery is a parsed search string which allows you to fetch conditions
* and text being searched.
Expand All @@ -40,15 +38,14 @@ export default class AdvancedSearchQuery {
}

/**
* @param {String} str to parse e.g. 'to:me -from:[email protected] foobar'.
* @param {String} string to parse e.g. 'to:me -from:[email protected] foobar'.
* @param {Array} transformTextToConditions Array of functions to transform text into conditions
* @returns {AdvancedSearchQuery} An instance of this class AdvancedSearchQuery.
*/
static parse(
str?: string | null,
string: string = '',
transformTextToConditions: Transformer[] = []
) {
if (!str) str = ''
const conditionArray: Condition[] = []
const textSegments: TextSegment[] = []

Expand Down Expand Up @@ -104,10 +101,10 @@ export default class AdvancedSearchQuery {

performReset()

const quotePairMap = getQuotePairMap(str)
const quotePairMap = getQuotePairMap(string)

for (let i = 0; i < str.length; i++) {
const char = str[i]
for (let i = 0; i < string.length; i++) {
const char = string[i]
if (char === ' ') {
if (inOperand()) {
if (inQuote()) {
Expand Down
4 changes: 2 additions & 2 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('searchString', () => {
expect(AdvancedSearchQuery.parse().getConditionArray()).toEqual([])
expect(AdvancedSearchQuery.parse('').getConditionArray()).toEqual([])
expect(AdvancedSearchQuery.parse(' ').getConditionArray()).toEqual([])
expect(AdvancedSearchQuery.parse(null).getConditionArray()).toEqual([])
expect(AdvancedSearchQuery.parse(null).getParsedQuery()).toEqual({
expect(AdvancedSearchQuery.parse('').getConditionArray()).toEqual([])
expect(AdvancedSearchQuery.parse('').getParsedQuery()).toEqual({
exclude: {},
})
})
Expand Down
Loading

0 comments on commit 09d3083

Please sign in to comment.