@thi.ng/oquery 2.0.7 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,64 +1,122 @@
1
1
  # Change Log
2
2
 
3
+ - **Last updated**: 2021-11-21T17:09:28Z
4
+ - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
+
3
6
  All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
+ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
8
+
9
+ **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
+ and/or version bumps of transitive dependencies.
11
+
12
+ ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@2.1.0) (2021-11-17)
5
13
 
6
- ## [2.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/oquery@2.0.6...@thi.ng/oquery@2.0.7) (2021-11-03)
14
+ #### 🚀 Features
7
15
 
8
- **Note:** Version bump only for package @thi.ng/oquery
16
+ - Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
17
+ Improving the overall build ergonomics
18
+ - introduced a tools workspaces
19
+ - imported it in all needed packages/examples
20
+ - inclusive project root
9
21
 
22
+ #### ♻️ Refactoring
10
23
 
24
+ - testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
25
+ this commit reverts (partly) changes made in:
26
+ ef346d7a8753590dc9094108a3d861a8dbd5dd2c
27
+ overall purpose is better testament ergonomics:
28
+ instead of having to pass NODE_OPTIONS with every invocation
29
+ having a binary to handle this for us.
11
30
 
31
+ ### [2.0.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@2.0.8) (2021-11-10)
12
32
 
33
+ #### ♻️ Refactoring
13
34
 
14
- # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/oquery@1.0.5...@thi.ng/oquery@2.0.0) (2021-10-12)
35
+ - update all countdown loops ([a5f374b](https://github.com/thi-ng/umbrella/commit/a5f374b))
15
36
 
37
+ ### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@2.0.1) (2021-10-13)
16
38
 
17
- ### Build System
39
+ #### ♻️ Refactoring
18
40
 
19
- * major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
41
+ - update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
42
+ - update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
43
+ - add .js suffix for all relative imports
20
44
 
45
+ # [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@2.0.0) (2021-10-12)
21
46
 
22
- ### BREAKING CHANGES
47
+ #### 🛑 Breaking changes
23
48
 
24
- * discontinue CommonJS & UMD versions
49
+ - major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
50
+ - BREAKING CHANGE: discontinue CommonJS & UMD versions
51
+ - only ESM modules will be published from now on
52
+ - CJS obsolete due to ESM support in recent versions of node:
53
+ - i.e. launch NodeJS via:
54
+ - `node --experimental-specifier-resolution=node --experimental-repl-await`
55
+ - in the node REPL use `await import(...)` instead of `require()`
56
+ - UMD obsolete due to widespread browser support for ESM
57
+ Also:
58
+ - normalize/restructure/reorg all package.json files
59
+ - cleanup all build scripts, remove obsolete
60
+ - switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
25
61
 
26
- - only ESM modules will be published from now on
27
- - CJS obsolete due to ESM support in recent versions of node:
28
- - i.e. launch NodeJS via:
29
- - `node --experimental-specifier-resolution=node --experimental-repl-await`
30
- - in the node REPL use `await import(...)` instead of `require()`
31
- - UMD obsolete due to widespread browser support for ESM
62
+ #### ♻️ Refactoring
32
63
 
33
- Also:
34
- - normalize/restructure/reorg all package.json files
35
- - cleanup all build scripts, remove obsolete
36
- - switch from mocha to @thi.ng/testament for all tests
64
+ - update defmulti impls ([8d3d49f](https://github.com/thi-ng/umbrella/commit/8d3d49f))
65
+ - update imports ([138571a](https://github.com/thi-ng/umbrella/commit/138571a))
66
+ - update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
67
+ - update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
37
68
 
69
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@0.3.0) (2021-03-22)
38
70
 
71
+ #### 🚀 Features
39
72
 
73
+ - fix [#264](https://github.com/thi-ng/umbrella/issues/264), add intersection queries ([f3ad108](https://github.com/thi-ng/umbrella/commit/f3ad108))
74
+ - add `QueryOpts.intersect` to force intersection query
75
+ (like `cwise` option, this is for O-terms only)
76
+ - add `intersect()` helper predicate
77
+ - update `coerce()`
78
+ - update `objQuery()`/`arrayQuery()` term initialization
79
+ - add/update `DEFAULT_OPTS`
80
+ - update tests
40
81
 
82
+ ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@0.2.0) (2020-12-07)
41
83
 
84
+ #### 🚀 Features
42
85
 
43
- ## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/oquery@1.0.4...@thi.ng/oquery@1.0.5) (2021-09-03)
86
+ - add defKeyQuery(), refactor/fix types ([4c5ba42](https://github.com/thi-ng/umbrella/commit/4c5ba42))
87
+ - add conditional types to fix return type inference (QueryFn/KeyQueryFn)
88
+ - add defKeyQuery()
89
+ - extract arrayQuery()/objQuery()
90
+ - optimize arrayQuery() by pre-selecting query impl
91
+ - add array support, add QueryOpts ([8498db0](https://github.com/thi-ng/umbrella/commit/8498db0))
92
+ - add QueryFn interface to define overrides for fn
93
+ returned by defQuery()
94
+ - if query called w/ source array, use only P/O terms,
95
+ no subjects (array indices), return array
96
+ - add `full` and `inspect` QueryOpts to control result format and
97
+ array value matching behavior
98
+ - add/update tests
44
99
 
45
- **Note:** Version bump only for package @thi.ng/oquery
100
+ #### ♻️ Refactoring
46
101
 
47
- # [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/oquery@0.2.11...@thi.ng/oquery@0.3.0) (2021-03-22)
102
+ - update QueryOpts and defaults ([90f4ee7](https://github.com/thi-ng/umbrella/commit/90f4ee7))
103
+ - rename full => partial (flip conditions)
104
+ - rename inspect => cwise
105
+ - update tests
48
106
 
49
- ### Features
107
+ ### [0.1.12](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@0.1.12) (2020-09-22)
50
108
 
51
- - **oquery:** fix [#264](https://github.com/thi-ng/umbrella/issues/264), add intersection queries ([f3ad108](https://github.com/thi-ng/umbrella/commit/f3ad1083645076c8a1bd38f7152345e25ab581f1))
109
+ #### ♻️ Refactoring
52
110
 
53
- # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/oquery@0.1.15...@thi.ng/oquery@0.2.0) (2020-12-07)
111
+ - further sub-query extraction/re-use ([4fb9b4b](https://github.com/thi-ng/umbrella/commit/4fb9b4b))
112
+ - dedupe, simplify sub-query fns ([498e4e5](https://github.com/thi-ng/umbrella/commit/498e4e5))
54
113
 
55
- ### Features
114
+ ## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/oquery@0.1.0) (2020-07-04)
56
115
 
57
- - **oquery:** add array support, add QueryOpts ([8498db0](https://github.com/thi-ng/umbrella/commit/8498db037216a6ebcd15cb76a141fedc88feecf3))
58
- - **oquery:** add defKeyQuery(), refactor/fix types ([4c5ba42](https://github.com/thi-ng/umbrella/commit/4c5ba4256c3b56f4d1e70069675e39f26ac11887))
116
+ #### 🚀 Features
59
117
 
60
- # 0.1.0 (2020-07-04)
118
+ - import as new pkg ([aaa3086](https://github.com/thi-ng/umbrella/commit/aaa3086))
61
119
 
62
- ### Features
120
+ #### ♻️ Refactoring
63
121
 
64
- - **oquery:** import as new pkg ([aaa3086](https://github.com/thi-ng/umbrella/commit/aaa30865d3318c06ab8f32862058a06af89ec8cc))
122
+ - minor refactoring ([03a1943](https://github.com/thi-ng/umbrella/commit/03a1943))
package/README.md CHANGED
@@ -77,7 +77,7 @@ node --experimental-repl-await
77
77
  > const oquery = await import("@thi.ng/oquery");
78
78
  ```
79
79
 
80
- Package sizes (gzipped, pre-treeshake): ESM: 1.39 KB
80
+ Package sizes (gzipped, pre-treeshake): ESM: 1.26 KB
81
81
 
82
82
  ## Dependencies
83
83
 
@@ -112,7 +112,7 @@ elements of the given array/set must match for the query to succeed (see
112
112
  examples/differences further below).
113
113
 
114
114
  The behavior can be chosen via the [`intersect` query
115
- option](https://docs.thi.ng/umbrella/oquery/interfaces/queryopts.html#intersect).
115
+ option](https://docs.thi.ng/umbrella/oquery/interfaces/QueryOpts.html#intersect).
116
116
 
117
117
  ### Query patterns
118
118
 
package/package.json CHANGED
@@ -1,90 +1,95 @@
1
1
  {
2
- "name": "@thi.ng/oquery",
3
- "version": "2.0.7",
4
- "description": "Datalog-inspired, optimized pattern/predicate query engine for JS objects & arrays",
5
- "type": "module",
6
- "module": "./index.js",
7
- "typings": "./index.d.ts",
8
- "sideEffects": false,
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/thi-ng/umbrella.git"
2
+ "name": "@thi.ng/oquery",
3
+ "version": "2.1.2",
4
+ "description": "Datalog-inspired, optimized pattern/predicate query engine for JS objects & arrays",
5
+ "type": "module",
6
+ "module": "./index.js",
7
+ "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/thi-ng/umbrella.git"
12
+ },
13
+ "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/oquery#readme",
14
+ "funding": [
15
+ {
16
+ "type": "github",
17
+ "url": "https://github.com/sponsors/postspectacular"
12
18
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/oquery#readme",
14
- "funding": [
15
- {
16
- "type": "github",
17
- "url": "https://github.com/sponsors/postspectacular"
18
- },
19
- {
20
- "type": "patreon",
21
- "url": "https://patreon.com/thing_umbrella"
22
- }
23
- ],
24
- "author": "Karsten Schmidt <k+npm@thi.ng>",
25
- "license": "Apache-2.0",
26
- "scripts": {
27
- "build": "yarn clean && tsc --declaration",
28
- "clean": "rimraf *.js *.d.ts *.map doc",
29
- "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
- "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
31
- "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
- "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
- "pub": "yarn build && yarn publish --access public",
34
- "test": "testament test"
35
- },
36
- "dependencies": {
37
- "@thi.ng/api": "^8.1.0",
38
- "@thi.ng/checks": "^3.0.6",
39
- "@thi.ng/defmulti": "^2.0.7",
40
- "@thi.ng/equiv": "^2.0.6"
19
+ {
20
+ "type": "patreon",
21
+ "url": "https://patreon.com/thing_umbrella"
22
+ }
23
+ ],
24
+ "author": "Karsten Schmidt <k+npm@thi.ng>",
25
+ "license": "Apache-2.0",
26
+ "scripts": {
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
+ "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
31
+ "doc:readme": "yarn doc:stats && tools:readme",
32
+ "doc:stats": "tools:module-stats",
33
+ "pub": "yarn npm publish --access public",
34
+ "test": "testament test"
35
+ },
36
+ "dependencies": {
37
+ "@thi.ng/api": "^8.3.2",
38
+ "@thi.ng/checks": "^3.1.2",
39
+ "@thi.ng/defmulti": "^2.1.2",
40
+ "@thi.ng/equiv": "^2.1.2"
41
+ },
42
+ "devDependencies": {
43
+ "@microsoft/api-extractor": "^7.18.19",
44
+ "@thi.ng/testament": "^0.2.2",
45
+ "rimraf": "^3.0.2",
46
+ "tools": "^0.0.1",
47
+ "typedoc": "^0.22.9",
48
+ "typescript": "^4.5.2"
49
+ },
50
+ "keywords": [
51
+ "array",
52
+ "datalog",
53
+ "graph",
54
+ "intersection",
55
+ "object",
56
+ "pattern",
57
+ "predicate",
58
+ "query",
59
+ "triples",
60
+ "typescript",
61
+ "union",
62
+ "wildcard"
63
+ ],
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "engines": {
68
+ "node": ">=12.7"
69
+ },
70
+ "files": [
71
+ "*.js",
72
+ "*.d.ts"
73
+ ],
74
+ "exports": {
75
+ ".": {
76
+ "import": "./index.js"
41
77
  },
42
- "devDependencies": {
43
- "@thi.ng/testament": "^0.1.6"
78
+ "./api": {
79
+ "import": "./api.js"
44
80
  },
45
- "keywords": [
46
- "array",
47
- "datalog",
48
- "graph",
49
- "intersection",
50
- "object",
51
- "pattern",
52
- "predicate",
53
- "query",
54
- "triples",
55
- "typescript",
56
- "union",
57
- "wildcard"
81
+ "./query": {
82
+ "import": "./query.js"
83
+ }
84
+ },
85
+ "thi.ng": {
86
+ "related": [
87
+ "associative",
88
+ "csv",
89
+ "egf",
90
+ "rstream-query"
58
91
  ],
59
- "publishConfig": {
60
- "access": "public"
61
- },
62
- "engines": {
63
- "node": ">=12.7"
64
- },
65
- "files": [
66
- "*.js",
67
- "*.d.ts"
68
- ],
69
- "exports": {
70
- ".": {
71
- "import": "./index.js"
72
- },
73
- "./api": {
74
- "import": "./api.js"
75
- },
76
- "./query": {
77
- "import": "./query.js"
78
- }
79
- },
80
- "thi.ng": {
81
- "related": [
82
- "associative",
83
- "csv",
84
- "egf",
85
- "rstream-query"
86
- ],
87
- "year": 2020
88
- },
89
- "gitHead": "852cd2450617c86d15d18477dc634f17f04202eb"
90
- }
92
+ "year": 2020
93
+ },
94
+ "gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
95
+ }
package/query.js CHANGED
@@ -30,7 +30,7 @@ const intersect = (src) => {
30
30
  const num = a.length;
31
31
  return (b) => {
32
32
  const $b = ensureSet(b);
33
- for (let i = num; --i >= 0;) {
33
+ for (let i = num; i-- > 0;) {
34
34
  if (!$b.has(a[i]))
35
35
  return false;
36
36
  }