@zenstackhq/common-helpers 3.0.0-alpha.9 → 3.0.0-beta.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.
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/is-plain-object.ts","../src/lower-case-first.ts","../src/param-case.ts","../src/sleep.ts","../src/tiny-invariant.ts","../src/upper-case-first.ts"],"sourcesContent":["export * from './is-plain-object';\nexport * from './lower-case-first';\nexport * from './param-case';\nexport * from './sleep';\nexport * from './tiny-invariant';\nexport * from './upper-case-first';\n","function isObject(o: unknown) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nexport function isPlainObject(o: unknown) {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = (o as { constructor: unknown }).constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = (ctor as { prototype: unknown }).prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n","export function lowerCaseFirst(input: string) {\n return input.charAt(0).toLowerCase() + input.slice(1);\n}\n","const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;\nconst DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\nexport function paramCase(input: string) {\n const result = input\n .replace(DEFAULT_SPLIT_REGEXP_1,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/is-plain-object.ts","../src/lower-case-first.ts","../src/param-case.ts","../src/sleep.ts","../src/tiny-invariant.ts","../src/upper-case-first.ts"],"sourcesContent":["export * from './is-plain-object';\nexport * from './lower-case-first';\nexport * from './param-case';\nexport * from './sleep';\nexport * from './tiny-invariant';\nexport * from './upper-case-first';\n","function isObject(o: unknown) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nexport function isPlainObject(o: unknown) {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = (o as { constructor: unknown }).constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = (ctor as { prototype: unknown }).prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n","export function lowerCaseFirst(input: string) {\n return input.charAt(0).toLowerCase() + input.slice(1);\n}\n","const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;\nconst DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\nexport function paramCase(input: string) {\n const result = input\n .replace(DEFAULT_SPLIT_REGEXP_1, '$1\\0$2')\n .replace(DEFAULT_SPLIT_REGEXP_2, '$1\\0$2')\n .replace(DEFAULT_STRIP_REGEXP, '\\0');\n\n let start = 0;\n let end = result.length;\n\n while (result.charAt(start) === '\\0') start++;\n while (result.charAt(end - 1) === '\\0') end--;\n\n return result\n .slice(start, end)\n .split('\\0')\n .map((str) => str.toLowerCase())\n .join('-');\n}\n","export function sleep(timeout: number) {\n return new Promise<void>((resolve) => {\n setTimeout(() => resolve(), timeout);\n });\n}\n","const isProduction = process.env['NODE_ENV'] === 'production';\nconst prefix = 'Invariant failed';\n\nexport function invariant(condition: unknown, message?: string): asserts condition {\n if (condition) {\n return;\n }\n\n if (isProduction) {\n throw new Error(prefix);\n }\n\n throw new Error(message ? `${prefix}: ${message}` : prefix);\n}\n","export function upperCaseFirst(input: string) {\n return input.charAt(0).toUpperCase() + input.slice(1);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA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AAMC,SAAS;AAER,SAASC,UAAUC,WAAoBC,SAAgB;AAC1D,MAAID,WAAW;AACX;EACJ;AAEA,MAAIL,cAAc;AACd,UAAM,IAAIO,MAAMJ,MAAAA;EACpB;AAEA,QAAM,IAAII,MAAMD,UAAU,GAAGH,MAAAA,KAAWG,OAAAA,KAAYH,MAAAA;AACxD;AAVgBC;;;ACHT,SAASI,eAAeC,OAAa;AACxC,SAAOA,MAAMC,OAAO,CAAA,EAAGC,YAAW,IAAKF,MAAMG,MAAM,CAAA;AACvD;AAFgBJ;","names":["isObject","o","Object","prototype","toString","call","isPlainObject","ctor","undefined","prot","hasOwnProperty","lowerCaseFirst","input","charAt","toLowerCase","slice","DEFAULT_SPLIT_REGEXP_1","DEFAULT_SPLIT_REGEXP_2","DEFAULT_STRIP_REGEXP","paramCase","input","result","replace","start","end","length","charAt","slice","split","map","str","toLowerCase","join","sleep","timeout","Promise","resolve","setTimeout","isProduction","process","env","prefix","invariant","condition","message","Error","upperCaseFirst","input","charAt","toUpperCase","slice"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-plain-object.ts","../src/lower-case-first.ts","../src/param-case.ts","../src/sleep.ts","../src/tiny-invariant.ts","../src/upper-case-first.ts"],"sourcesContent":["function isObject(o: unknown) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nexport function isPlainObject(o: unknown) {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = (o as { constructor: unknown }).constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = (ctor as { prototype: unknown }).prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n","export function lowerCaseFirst(input: string) {\n return input.charAt(0).toLowerCase() + input.slice(1);\n}\n","const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;\nconst DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\nexport function paramCase(input: string) {\n const result = input\n .replace(DEFAULT_SPLIT_REGEXP_1,
|
|
1
|
+
{"version":3,"sources":["../src/is-plain-object.ts","../src/lower-case-first.ts","../src/param-case.ts","../src/sleep.ts","../src/tiny-invariant.ts","../src/upper-case-first.ts"],"sourcesContent":["function isObject(o: unknown) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nexport function isPlainObject(o: unknown) {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = (o as { constructor: unknown }).constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = (ctor as { prototype: unknown }).prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n","export function lowerCaseFirst(input: string) {\n return input.charAt(0).toLowerCase() + input.slice(1);\n}\n","const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;\nconst DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\nexport function paramCase(input: string) {\n const result = input\n .replace(DEFAULT_SPLIT_REGEXP_1, '$1\\0$2')\n .replace(DEFAULT_SPLIT_REGEXP_2, '$1\\0$2')\n .replace(DEFAULT_STRIP_REGEXP, '\\0');\n\n let start = 0;\n let end = result.length;\n\n while (result.charAt(start) === '\\0') start++;\n while (result.charAt(end - 1) === '\\0') end--;\n\n return result\n .slice(start, end)\n .split('\\0')\n .map((str) => str.toLowerCase())\n .join('-');\n}\n","export function sleep(timeout: number) {\n return new Promise<void>((resolve) => {\n setTimeout(() => resolve(), timeout);\n });\n}\n","const isProduction = process.env['NODE_ENV'] === 'production';\nconst prefix = 'Invariant failed';\n\nexport function invariant(condition: unknown, message?: string): asserts condition {\n if (condition) {\n return;\n }\n\n if (isProduction) {\n throw new Error(prefix);\n }\n\n throw new Error(message ? `${prefix}: ${message}` : prefix);\n}\n","export function upperCaseFirst(input: string) {\n return input.charAt(0).toUpperCase() + input.slice(1);\n}\n"],"mappings":";;;;AAAA,SAASA,SAASC,GAAU;AACxB,SAAOC,OAAOC,UAAUC,SAASC,KAAKJ,CAAAA,MAAO;AACjD;AAFSD;AAIF,SAASM,cAAcL,GAAU;AACpC,MAAID,SAASC,CAAAA,MAAO,MAAO,QAAO;AAGlC,QAAMM,OAAQN,EAA+B;AAC7C,MAAIM,SAASC,OAAW,QAAO;AAG/B,QAAMC,OAAQF,KAAgCJ;AAC9C,MAAIH,SAASS,IAAAA,MAAU,MAAO,QAAO;AAGrC,MAAIP,OAAOC,UAAUO,eAAeL,KAAKI,MAAM,eAAA,MAAqB,OAAO;AACvE,WAAO;EACX;AAGA,SAAO;AACX;AAlBgBH;;;ACJT,SAASK,eAAeC,OAAa;AACxC,SAAOA,MAAMC,OAAO,CAAA,EAAGC,YAAW,IAAKF,MAAMG,MAAM,CAAA;AACvD;AAFgBJ;;;ACAhB,IAAMK,yBAAyB;AAC/B,IAAMC,yBAAyB;AAC/B,IAAMC,uBAAuB;AAEtB,SAASC,UAAUC,OAAa;AACnC,QAAMC,SAASD,MACVE,QAAQN,wBAAwB,QAAA,EAChCM,QAAQL,wBAAwB,QAAA,EAChCK,QAAQJ,sBAAsB,IAAA;AAEnC,MAAIK,QAAQ;AACZ,MAAIC,MAAMH,OAAOI;AAEjB,SAAOJ,OAAOK,OAAOH,KAAAA,MAAW,KAAMA;AACtC,SAAOF,OAAOK,OAAOF,MAAM,CAAA,MAAO,KAAMA;AAExC,SAAOH,OACFM,MAAMJ,OAAOC,GAAAA,EACbI,MAAM,IAAA,EACNC,IAAI,CAACC,QAAQA,IAAIC,YAAW,CAAA,EAC5BC,KAAK,GAAA;AACd;AAjBgBb;;;ACJT,SAASc,MAAMC,SAAe;AACjC,SAAO,IAAIC,QAAc,CAACC,YAAAA;AACtBC,eAAW,MAAMD,QAAAA,GAAWF,OAAAA;EAChC,CAAA;AACJ;AAJgBD;;;ACAhB,IAAMK,eAAeC,QAAQC,IAAI,UAAA,MAAgB;AACjD,IAAMC,SAAS;AAER,SAASC,UAAUC,WAAoBC,SAAgB;AAC1D,MAAID,WAAW;AACX;EACJ;AAEA,MAAIL,cAAc;AACd,UAAM,IAAIO,MAAMJ,MAAAA;EACpB;AAEA,QAAM,IAAII,MAAMD,UAAU,GAAGH,MAAAA,KAAWG,OAAAA,KAAYH,MAAAA;AACxD;AAVgBC;;;ACHT,SAASI,eAAeC,OAAa;AACxC,SAAOA,MAAMC,OAAO,CAAA,EAAGC,YAAW,IAAKF,MAAMG,MAAM,CAAA;AACvD;AAFgBJ;","names":["isObject","o","Object","prototype","toString","call","isPlainObject","ctor","undefined","prot","hasOwnProperty","lowerCaseFirst","input","charAt","toLowerCase","slice","DEFAULT_SPLIT_REGEXP_1","DEFAULT_SPLIT_REGEXP_2","DEFAULT_STRIP_REGEXP","paramCase","input","result","replace","start","end","length","charAt","slice","split","map","str","toLowerCase","join","sleep","timeout","Promise","resolve","setTimeout","isProduction","process","env","prefix","invariant","condition","message","Error","upperCaseFirst","input","charAt","toUpperCase","slice"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/common-helpers",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "ZenStack Common Helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@zenstackhq/typescript-config": "3.0.0-
|
|
26
|
-
"@zenstackhq/eslint-config": "3.0.0-
|
|
25
|
+
"@zenstackhq/typescript-config": "3.0.0-beta.1",
|
|
26
|
+
"@zenstackhq/eslint-config": "3.0.0-beta.1"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "tsup-node",
|
|
29
|
+
"build": "tsc --noEmit && tsup-node",
|
|
30
30
|
"watch": "tsup-node --watch",
|
|
31
31
|
"lint": "eslint src --ext ts",
|
|
32
32
|
"pack": "pnpm pack"
|