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 @@
import{ITSELF as r,createInterpreter as n}from"@ucast/core";function t(r,n,t){for(var u=0,e=r.length;u<e;u++)if(0===t(r[u],n))return!0;return!1}function u(r,n){return Array.isArray(r)&&Number.isNaN(Number(n))}function e(r,n,t){if(!u(r,n))return t(r,n);for(var e=[],o=0;o<r.length;o++){var i=t(r[o],n);void 0!==i&&(e=e.concat(i))}return e}function o(r){return function(n,t,u){var e=u.get(t,n.field);return Array.isArray(e)?e.some((function(t){return r(n,t,u)})):r(n,e,u)}}function i(){return(i=Object.assign||function(r){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(r[u]=t[u])}return r}).apply(this,arguments)}var f=function(r,n){return r[n]};function c(r,n,t){var u=n.lastIndexOf(".");return-1===u?[r,n]:[t(r,n.slice(0,u)),n.slice(u+1)]}function a(n,t,u){if(void 0===u&&(u=f),t===r)return n;if(!n)throw new Error('Unable to get field "'+t+'" out of '+String(n)+".");return function(r,n,t){if(-1===n.indexOf("."))return e(r,n,t);for(var u=n.split("."),o=r,i=0,f=u.length;i<f;i++)if(!(o=e(o,u[i],t))||"object"!=typeof o)return o;return o}(n,t,u)}function v(r){return function(n,t){return a(n,t,r)}}function l(r,n){return r===n?0:r>n?1:-1}function y(r,t){return void 0===t&&(t={}),n(r,i({get:a,compare:l},t))}var b=function(r,n,t){var u=t.interpret;return r.value.some((function(r){return u(r,n)}))},m=function(r,n,t){return!b(r,n,t)},d=function(r,n,t){var u=t.interpret;return r.value.every((function(r){return u(r,n)}))},g=function(r,n,t){return!(0,t.interpret)(r.value[0],n)},p=function(r,n,u){var e=u.compare,o=(0,u.get)(n,r.field);return Array.isArray(o)&&!Array.isArray(r.value)?t(o,r.value,e):0===e(o,r.value)},A=function(r,n,t){return!p(r,n,t)},s=o((function(r,n,t){var u=t.compare(n,r.value);return 0===u||-1===u})),h=o((function(r,n,t){return-1===t.compare(n,r.value)})),j=o((function(r,n,t){return 1===t.compare(n,r.value)})),w=o((function(r,n,t){var u=t.compare(n,r.value);return 0===u||1===u})),_=function(n,t,e){var o=e.get;if(n.field===r)return void 0!==t;var i=c(t,n.field,o),f=i[0],a=i[1],v=function(r){return null==r?Boolean(r)===n.value:r.hasOwnProperty(a)===n.value};return u(f,a)?f.some(v):v(f)},x=o((function(r,n){return"number"==typeof n&&n%r.value[0]===r.value[1]})),O=function(n,t,e){var o=e.get,i=c(t,n.field,o),f=i[0],a=i[1],v=function(r){var t=o(r,a);return Array.isArray(t)&&t.length===n.value};return n.field!==r&&u(f,a)?f.some(v):v(f)},N=o((function(r,n){return"string"==typeof n&&r.value.test(n)})),q=o((function(r,n,u){var e=u.compare;return t(r.value,n,e)})),z=function(r,n,t){return!q(r,n,t)},B=function(r,n,u){var e=u.compare,o=(0,u.get)(n,r.field);return Array.isArray(o)&&r.value.every((function(r){return t(o,r,e)}))},E=function(r,n,t){var u=t.interpret,e=(0,t.get)(n,r.field);return Array.isArray(e)&&e.some((function(n){return u(r.value,n)}))},M=function(r,n){return r.value.call(n)},S=i({},Object.freeze({__proto__:null,or:b,nor:m,and:d,not:g,eq:p,ne:A,lte:s,lt:h,gt:j,gte:w,exists:_,mod:x,size:O,regex:N,within:q,nin:z,all:B,elemMatch:E,where:M}),{in:q}),U=y(S);export{B as all,S as allInterpreters,d as and,l as compare,v as createGetter,y as createJsInterpreter,E as elemMatch,p as eq,_ as exists,a as getObjectField,c as getObjectFieldCursor,j as gt,w as gte,U as interpret,h as lt,s as lte,x as mod,A as ne,z as nin,m as nor,g as not,b as or,N as regex,O as size,M as where,q as within};
//# 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