@nxtedition/lib 20.4.8 → 21.0.1

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.
Files changed (2) hide show
  1. package/deepstream.js +18 -13
  2. package/package.json +1 -1
package/deepstream.js CHANGED
@@ -3,17 +3,22 @@ import qs from 'qs'
3
3
  import cached from './util/cached.js'
4
4
  import * as rxjs from 'rxjs'
5
5
 
6
+ const EMPTY_OPT = {}
7
+ const RECURSIVE_OPT = { recursive: true }
8
+
6
9
  function provide(ds, domain, callback, options) {
7
- if (domain instanceof RegExp) {
8
- domain = domain.source
9
- } else {
10
- domain = domain.replace('.', '\\.')
10
+ if (typeof domain !== 'string') {
11
+ throw new Error('domain must be a string')
11
12
  }
12
13
 
13
- if (!options || typeof options !== 'object') {
14
- options = {
15
- recursive: options === true,
16
- }
14
+ if (options === true) {
15
+ options = RECURSIVE_OPT
16
+ } else if (options == null) {
17
+ options = EMPTY_OPT
18
+ }
19
+
20
+ if (typeof options !== 'object') {
21
+ throw new Error('options must be an object, nully or `true`')
17
22
  }
18
23
 
19
24
  if (options.cached) {
@@ -32,20 +37,20 @@ function provide(ds, domain, callback, options) {
32
37
  callback = cached(callback, options, (id, options, key) => key)
33
38
  }
34
39
 
35
- let idExpr = '(?:([^{}]+|{.*}):)?'
40
+ let idExpr
36
41
  if (options.id === true) {
37
- idExpr = '([^{}]+):'
42
+ idExpr = '^(?:[^{}]+):'
38
43
  } else if (options.id === false) {
39
- idExpr = '(?:([{].*[}]):)?'
44
+ idExpr = '^(?:([{].*[}]):)?'
40
45
  }
41
46
 
42
47
  return ds.record.provide(
43
- `^${idExpr}(${domain})(?:[?].*)${options.strict ? '' : '?'}$`,
48
+ `${idExpr}(?:${domain})(?:[?].*)${options.strict ? '' : '?'}$`,
44
49
  (key) => {
45
50
  const [id, options] = parseKey(key)
46
51
  return callback(id, options, key)
47
52
  },
48
- { recursive: options.recursive, mode: options.mode, stringify: options.stringify },
53
+ options,
49
54
  )
50
55
  }
51
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "20.4.8",
3
+ "version": "21.0.1",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",