node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@ucast/core");function t(r,t,e){for(let n=0,o=r.length;n<o;n++)if(0===e(r[n],t))return!0;return!1}function e(r,t){return Array.isArray(r)&&Number.isNaN(Number(t))}function n(r,t,n){if(!e(r,t))return n(r,t);let o=[];for(let e=0;e<r.length;e++){const s=n(r[e],t);void 0!==s&&(o=o.concat(s))}return o}function o(r){return(t,e,n)=>{const o=n.get(e,t.field);return Array.isArray(o)?o.some(e=>r(t,e,n)):r(t,o,n)}}const s=(r,t)=>r[t];function u(r,t,e){const n=t.lastIndexOf(".");return-1===n?[r,t]:[e(r,t.slice(0,n)),t.slice(n+1)]}function p(t,e,o=s){if(e===r.ITSELF)return t;if(!t)throw new Error(`Unable to get field "${e}" out of ${String(t)}.`);return function(r,t,e){if(-1===t.indexOf("."))return n(r,t,e);const o=t.split(".");let s=r;for(let r=0,t=o.length;r<t;r++)if(s=n(s,o[r],e),!s||"object"!=typeof s)return s;return s}(t,e,o)}function c(r,t){return r===t?0:r>t?1:-1}function i(t,e={}){return r.createInterpreter(t,Object.assign({get:p,compare:c},e))}const x=(r,t,{interpret:e})=>r.value.some(r=>e(r,t)),f=(r,t,e)=>!x(r,t,e),a=(r,t,{interpret:e})=>r.value.every(r=>e(r,t)),l=(r,t,{interpret:e})=>!e(r.value[0],t),g=(r,e,{compare:n,get:o})=>{const s=o(e,r.field);return Array.isArray(s)&&!Array.isArray(r.value)?t(s,r.value,n):0===n(s,r.value)},y=(r,t,e)=>!g(r,t,e),b=o((r,t,e)=>{const n=e.compare(t,r.value);return 0===n||-1===n}),m=o((r,t,e)=>-1===e.compare(t,r.value)),A=o((r,t,e)=>1===e.compare(t,r.value)),d=o((r,t,e)=>{const n=e.compare(t,r.value);return 0===n||1===n}),_=(t,n,{get:o})=>{if(t.field===r.ITSELF)return void 0!==n;const[s,p]=u(n,t.field,o),c=r=>null==r?Boolean(r)===t.value:r.hasOwnProperty(p)===t.value;return e(s,p)?s.some(c):c(s)},j=o((r,t)=>"number"==typeof t&&t%r.value[0]===r.value[1]),v=(t,n,{get:o})=>{const[s,p]=u(n,t.field,o),c=r=>{const e=o(r,p);return Array.isArray(e)&&e.length===t.value};return t.field!==r.ITSELF&&e(s,p)?s.some(c):c(s)},h=o((r,t)=>"string"==typeof t&&r.value.test(t)),w=o((r,e,{compare:n})=>t(r.value,e,n)),O=(r,t,e)=>!w(r,t,e),q=(r,e,{compare:n,get:o})=>{const s=o(e,r.field);return Array.isArray(s)&&r.value.every(r=>t(s,r,n))},M=(r,t,{interpret:e,get:n})=>{const o=n(t,r.field);return Array.isArray(o)&&o.some(t=>e(r.value,t))},N=(r,t)=>r.value.call(t);var $=Object.freeze({__proto__:null,or:x,nor:f,and:a,not:l,eq:g,ne:y,lte:b,lt:m,gt:A,gte:d,exists:_,mod:j,size:v,regex:h,within:w,nin:O,all:q,elemMatch:M,where:N});const z=Object.assign({},$,{in:w}),B=i(z);exports.all=q,exports.allInterpreters=z,exports.and=a,exports.compare=c,exports.createGetter=function(r){return(t,e)=>p(t,e,r)},exports.createJsInterpreter=i,exports.elemMatch=M,exports.eq=g,exports.exists=_,exports.getObjectField=p,exports.getObjectFieldCursor=u,exports.gt=A,exports.gte=d,exports.interpret=B,exports.lt=m,exports.lte=b,exports.mod=j,exports.ne=y,exports.nin=O,exports.nor=f,exports.not=l,exports.or=x,exports.regex=h,exports.size=v,exports.where=N,exports.within=w;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/utils.ts","../../src/interpreter.ts","../../src/interpreters.ts","../../src/defaults.ts"],"sourcesContent":["import { FieldCondition } from '@ucast/core';\nimport { JsInterpretationOptions, JsInterpreter } from './types';\n\nexport type AnyObject = Record<PropertyKey, unknown>;\nexport type GetField = (object: any, field: string) => any;\n\nexport function includes<T>(\n items: T[],\n value: T,\n compare: JsInterpretationOptions['compare']\n): boolean {\n for (let i = 0, length = items.length; i < length; i++) {\n if (compare(items[i], value) === 0) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function isArrayAndNotNumericField<T>(object: T | T[], field: string): object is T[] {\n return Array.isArray(object) && Number.isNaN(Number(field));\n}\n\nfunction getField<T extends AnyObject>(object: T | T[], field: string, get: GetField) {\n if (!isArrayAndNotNumericField(object, field)) {\n return get(object, field);\n }\n\n let result: unknown[] = [];\n\n for (let i = 0; i < object.length; i++) {\n const value = get(object[i], field);\n if (typeof value !== 'undefined') {\n result = result.concat(value);\n }\n }\n\n return result;\n}\n\nexport function getValueByPath(object: AnyObject, field: string, get: GetField) {\n if (field.indexOf('.') === -1) {\n return getField(object, field, get);\n }\n\n const paths = field.split('.');\n let value = object;\n\n for (let i = 0, length = paths.length; i < length; i++) {\n value = getField(value, paths[i], get);\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n }\n\n return value;\n}\n\nexport function testValueOrArray<T, U = T>(test: JsInterpreter<FieldCondition<T>, U>) {\n return ((node, object, context) => {\n const value = context.get(object, node.field);\n\n if (!Array.isArray(value)) {\n return test(node, value, context);\n }\n\n return value.some(v => test(node, v, context));\n }) as JsInterpreter<FieldCondition<T>, AnyObject | U>;\n}\n","import { createInterpreter, ITSELF } from '@ucast/core';\nimport { getValueByPath, AnyObject, GetField } from './utils';\nimport { JsInterpretationOptions, JsInterpreter } from './types';\n\nconst defaultGet = (object: AnyObject, field: string) => object[field];\ntype Field = string | typeof ITSELF;\n\nexport function getObjectFieldCursor<T extends {}>(object: T, path: string, get: GetField) {\n const dotIndex = path.lastIndexOf('.');\n\n if (dotIndex === -1) {\n return [object, path] as const;\n }\n\n return [\n get(object, path.slice(0, dotIndex)) as T,\n path.slice(dotIndex + 1)\n ] as const;\n}\n\nexport function getObjectField(object: unknown, field: Field, get: GetField = defaultGet) {\n if (field === ITSELF) {\n return object;\n }\n\n if (!object) {\n throw new Error(`Unable to get field \"${field}\" out of ${String(object)}.`);\n }\n\n return getValueByPath(object as Record<string, unknown>, field, get);\n}\n\nexport function createGetter<T extends GetField>(get: T) {\n return (object: Parameters<T>[0], field: Parameters<T>[1]) => getObjectField(object, field, get);\n}\n\nexport function compare<T>(a: T, b: T): 0 | 1 | -1 {\n if (a === b) {\n return 0;\n }\n\n return a > b ? 1 : -1;\n}\n\nexport function createJsInterpreter<\n T extends JsInterpreter<any>,\n O extends Partial<JsInterpretationOptions>\n>(\n operators: Record<string, T>,\n options: O = {} as O\n) {\n return createInterpreter(operators, {\n get: getObjectField,\n compare,\n ...options,\n });\n}\n","import {\n CompoundCondition as Compound,\n FieldCondition as Field,\n DocumentCondition as Document,\n Condition,\n Comparable,\n ITSELF,\n} from '@ucast/core';\nimport { JsInterpreter as Interpret } from './types';\nimport {\n includes,\n testValueOrArray,\n isArrayAndNotNumericField,\n AnyObject,\n} from './utils';\nimport { getObjectFieldCursor } from './interpreter';\n\nexport const or: Interpret<Compound> = (node, object, { interpret }) => {\n return node.value.some(condition => interpret(condition, object));\n};\n\nexport const nor: typeof or = (node, object, context) => {\n return !or(node, object, context);\n};\n\nexport const and: Interpret<Compound> = (node, object, { interpret }) => {\n return node.value.every(condition => interpret(condition, object));\n};\n\nexport const not: Interpret<Compound> = (node, object, { interpret }) => {\n return !interpret(node.value[0], object);\n};\n\nexport const eq: Interpret<Field> = (node, object, { compare, get }) => {\n const value = get(object, node.field);\n\n if (Array.isArray(value) && !Array.isArray(node.value)) {\n return includes(value, node.value, compare);\n }\n\n return compare(value, node.value) === 0;\n};\n\nexport const ne: typeof eq = (node, object, context) => {\n return !eq(node, object, context);\n};\n\nexport const lte = testValueOrArray<Comparable>((node, value, cLine truncated