@lowdefy/helpers 5.6.0 → 6.0.0
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/dist/getOperatorType.js +35 -0
- package/dist/index.js +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import type from './type.js';
|
|
16
|
+
// Keys that look like operators (single key starting with _) but are not.
|
|
17
|
+
const KNOWN_NON_OPERATORS = new Set([
|
|
18
|
+
'_id'
|
|
19
|
+
]);
|
|
20
|
+
// Returns the normalized operator name ('_get' for { '_get.key': ... },
|
|
21
|
+
// '_state' for { __state: ... }) when the value is an operator object, else
|
|
22
|
+
// null. An operator object has exactly one non-~-prefixed key starting with _
|
|
23
|
+
// (~ keys like ~k configKeys may sit alongside the operator key).
|
|
24
|
+
function getOperatorType(value) {
|
|
25
|
+
if (!type.isObject(value)) return null;
|
|
26
|
+
const nonTildeKeys = Object.keys(value).filter((key)=>!key.startsWith('~'));
|
|
27
|
+
if (nonTildeKeys.length !== 1) return null;
|
|
28
|
+
const [op] = nonTildeKeys[0].split('.');
|
|
29
|
+
const operator = op.replace(/^_+/, '_');
|
|
30
|
+
if (operator.length > 1 && operator[0] === '_' && !KNOWN_NON_OPERATORS.has(operator)) {
|
|
31
|
+
return operator;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
export default getOperatorType;
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import getKey from './getKey.js';
|
|
|
21
21
|
import getLocaleDateFormat from './getLocaleDateFormat.js';
|
|
22
22
|
import getLocaleDecimalSeparator from './getLocaleDecimalSeparator.js';
|
|
23
23
|
import getLocaleGroupSeparator from './getLocaleGroupSeparator.js';
|
|
24
|
+
import getOperatorType from './getOperatorType.js';
|
|
24
25
|
import { isReserved, ReservedKeyError } from './ReservedKeyError.js';
|
|
25
26
|
import joinPath from './joinPath.js';
|
|
26
27
|
import LRUCache from './LRUCache.js';
|
|
@@ -38,4 +39,4 @@ import unset from './unset.js';
|
|
|
38
39
|
import unsetKey from './unsetKey.js';
|
|
39
40
|
import urlQuery from './urlQuery.js';
|
|
40
41
|
import wait from './wait.js';
|
|
41
|
-
export { applyArrayIndices, builtinMessages, cachedPromises, extractErrorProps, get, getKey, getLocaleDateFormat, getLocaleDecimalSeparator, getLocaleGroupSeparator, isReserved, joinPath, LRUCache, mergeObjects, omit, ReservedKeyError, serializer, set, setKey, splitPath, stableStringify, swap, translate, type, unset, unsetKey, urlQuery, wait };
|
|
42
|
+
export { applyArrayIndices, builtinMessages, cachedPromises, extractErrorProps, get, getKey, getLocaleDateFormat, getLocaleDecimalSeparator, getLocaleGroupSeparator, getOperatorType, isReserved, joinPath, LRUCache, mergeObjects, omit, ReservedKeyError, serializer, set, setKey, splitPath, stableStringify, swap, translate, type, unset, unsetKey, urlQuery, wait };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"dist/*"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@lowdefy/errors": "
|
|
34
|
+
"@lowdefy/errors": "6.0.0",
|
|
35
35
|
"intl-messageformat": "11.2.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@jest/globals": "28.1.3",
|
|
39
|
-
"@swc/cli": "0.8.
|
|
40
|
-
"@swc/core": "1.15.
|
|
39
|
+
"@swc/cli": "0.8.1",
|
|
40
|
+
"@swc/core": "1.15.32",
|
|
41
41
|
"@swc/jest": "0.2.39",
|
|
42
42
|
"jest": "28.1.3",
|
|
43
43
|
"jest-diff": "28.1.3"
|