@sanity/util 5.13.0-next.30 → 5.13.0-next.34
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/lib/content.d.ts +1 -0
- package/lib/content.js.map +1 -1
- package/package.json +5 -5
package/lib/content.d.ts
CHANGED
package/lib/content.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sources":["../src/content/hasOwn.ts","../src/content/isDeepEmpty.ts","../src/content/isShallowEmptyObject.ts","../src/content/randomKey.ts","../src/content/resolveJSType.ts","../src/content/resolveTypeName.ts"],"sourcesContent":["export default Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty)\n","import hasOwn from './hasOwn'\n\nfunction isDeepEmptyObject(value: {[key: string]: any}): boolean {\n for (const key in value) {\n if (key === '_type' || key === '_key') {\n continue\n }\n if (hasOwn(value, key) && !isDeepEmpty(value[key])) {\n return false\n }\n }\n return true\n}\n\nfunction isDeepEmptyArray(value: unknown[]): boolean {\n for (let i = 0; i < value.length; i++) {\n if (!isDeepEmpty(value[i])) {\n return false\n }\n }\n return true\n}\n\n/**\n * Looks at the value and determines if it is deeply empty while not considering _type and _key attributes on objects.\n * A value will be considered deeply empty if it is:\n * - undefined or null\n * - an object where all property values are deeply empty\n * - an array where all items are deeply empty\n * @param value - the value to check for deep emptiness\n */\nexport function isDeepEmpty(value: unknown): boolean {\n if (value === undefined || value === null) {\n return true\n }\n const type = typeof value\n\n if (Array.isArray(value)) {\n return isDeepEmptyArray(value)\n }\n if (type === 'object') {\n return isDeepEmptyObject(value)\n }\n return false\n}\n\n/**\n * @deprecated Use `isDeepEmpty` instead\n * todo: remove in v4\n */\nexport const isEmptyArray = isDeepEmptyArray\n
|
|
1
|
+
{"version":3,"file":"content.js","sources":["../src/content/hasOwn.ts","../src/content/isDeepEmpty.ts","../src/content/isShallowEmptyObject.ts","../src/content/randomKey.ts","../src/content/resolveJSType.ts","../src/content/resolveTypeName.ts"],"sourcesContent":["export default Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty)\n","import hasOwn from './hasOwn'\n\nfunction isDeepEmptyObject(value: {[key: string]: any}): boolean {\n for (const key in value) {\n if (key === '_type' || key === '_key') {\n continue\n }\n if (hasOwn(value, key) && !isDeepEmpty(value[key])) {\n return false\n }\n }\n return true\n}\n\nfunction isDeepEmptyArray(value: unknown[]): boolean {\n for (let i = 0; i < value.length; i++) {\n if (!isDeepEmpty(value[i])) {\n return false\n }\n }\n return true\n}\n\n/**\n * Looks at the value and determines if it is deeply empty while not considering _type and _key attributes on objects.\n * A value will be considered deeply empty if it is:\n * - undefined or null\n * - an object where all property values are deeply empty\n * - an array where all items are deeply empty\n * @param value - the value to check for deep emptiness\n */\nexport function isDeepEmpty(value: unknown): boolean {\n if (value === undefined || value === null) {\n return true\n }\n const type = typeof value\n\n if (Array.isArray(value)) {\n return isDeepEmptyArray(value)\n }\n if (type === 'object') {\n return isDeepEmptyObject(value)\n }\n return false\n}\n\n/**\n * @deprecated Use `isDeepEmpty` instead\n * todo: remove in v4\n */\nexport const isEmptyArray = isDeepEmptyArray\n/* eslint-disable tsdoc/syntax */\n/**\n * @deprecated Use `isDeepEmpty` instead\n * todo: remove in v4\n * @alias\n */\n/* eslint-enable tsdoc/syntax */\n\nexport const isEmpty = isDeepEmpty\n\n/**\n * @deprecated Use `isDeepEmpty` instead\n * todo: remove in v4\n */\nexport const isEmptyObject = isDeepEmptyObject\n","import hasOwn from './hasOwn'\n\nexport function isShallowEmptyObject(value: {[key: string]: unknown}): boolean {\n for (const key in value) {\n if (key === '_type' || key === '_key') {\n continue\n }\n if (hasOwn(value, key) && value[key] !== undefined) {\n return false\n }\n }\n return true\n}\n","const getByteHexTable = (() => {\n let table: string[]\n return () => {\n if (table) {\n return table\n }\n\n table = []\n for (let i = 0; i < 256; ++i) {\n table[i] = (i + 0x100).toString(16).slice(1)\n }\n return table\n }\n})()\n\n// WHATWG crypto RNG - https://w3c.github.io/webcrypto/Overview.html\nfunction whatwgRNG(length = 16) {\n const rnds8 = new Uint8Array(length)\n crypto.getRandomValues(rnds8)\n return rnds8\n}\n\nexport function randomKey(length?: number): string {\n const table = getByteHexTable()\n return whatwgRNG(length)\n .reduce((str, n) => str + table[n], '')\n .slice(0, length)\n}\n","const toString = Object.prototype.toString\n// Copied from https://github.com/ForbesLindesay/type-of, but inlined to have fine grained control\n\nexport function resolveJSType(val: unknown) {\n switch (toString.call(val)) {\n case '[object Function]':\n return 'function'\n case '[object Date]':\n return 'date'\n case '[object RegExp]':\n return 'regexp'\n case '[object Arguments]':\n return 'arguments'\n case '[object Array]':\n return 'array'\n case '[object String]':\n return 'string'\n default:\n }\n\n if (typeof val == 'object' && val && typeof (val as any).length == 'number') {\n try {\n if (typeof (val as any).callee == 'function') {\n return 'arguments'\n }\n } catch (ex) {\n if (ex instanceof TypeError) {\n return 'arguments'\n }\n }\n }\n\n if (val === null) {\n return 'null'\n }\n\n if (val === undefined) {\n return 'undefined'\n }\n\n if (val && (val as any).nodeType === 1) {\n return 'element'\n }\n\n if (val === Object(val)) {\n return 'object'\n }\n\n return typeof val\n}\n","import {resolveJSType} from './resolveJSType'\n\nexport function resolveTypeName(value: unknown): string {\n const jsType = resolveJSType(value)\n if (jsType !== 'object') {\n return jsType\n }\n\n const obj = value as Record<string, unknown> & {_type?: string}\n return ('_type' in obj && obj._type) || jsType\n}\n"],"names":[],"mappings":"AAAA,IAAA,SAAe,OAAO,UAAU,eAAe,KAAK,KAAK,OAAO,UAAU,cAAc;ACExF,SAAS,kBAAkB,OAAsC;AAC/D,aAAW,OAAO;AAChB,QAAI,EAAA,QAAQ,WAAW,QAAQ,WAG3B,OAAO,OAAO,GAAG,KAAK,CAAC,YAAY,MAAM,GAAG,CAAC;AAC/C,aAAO;AAGX,SAAO;AACT;AAEA,SAAS,iBAAiB,OAA2B;AACnD,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ;AAChC,QAAI,CAAC,YAAY,MAAM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,OAAO,OAAO,YAAY,OAAO,OAAQ,IAAY,UAAU;AACjE,QAAI;AACF,UAAI,OAAQ,IAAY,UAAU;AAChC,eAAO;AAAA,IAEX,SAAS,IAAI;AACX,UAAI,cAAc;AAChB,eAAO;AAAA,IAEX;AAGF,SAAI,QAAQ,OACH,SAGL,QAAQ,SACH,cAGL,OAAQ,IAAY,aAAa,IAC5B,YAGL,QAAQ,OAAO,GAAG,IACb,WAGF,OAAO;AAChB;AC/CO,SAAS,gBAAgB,OAAwB;AACtD,QAAM,SAAS,cAAc,KAAK;AAClC,MAAI,WAAW;AACb,WAAO;AAGT,QAAM,MAAM;AACZ,SAAQ,WAAW,OAAO,IAAI,SAAU;AAC1C;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/util",
|
|
3
|
-
"version": "5.13.0-next.
|
|
3
|
+
"version": "5.13.0-next.34+c07fa96934",
|
|
4
4
|
"description": "Utilities shared across projects of Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"eslint": "^9.39.2",
|
|
83
83
|
"rimraf": "^5.0.10",
|
|
84
84
|
"vitest": "^4.0.18",
|
|
85
|
-
"@repo/eslint-config": "5.13.0-next.
|
|
86
|
-
"@repo/
|
|
87
|
-
"@repo/tsconfig": "5.13.0-next.
|
|
88
|
-
"@repo/
|
|
85
|
+
"@repo/eslint-config": "5.13.0-next.34+c07fa96934",
|
|
86
|
+
"@repo/test-config": "5.13.0-next.34+c07fa96934",
|
|
87
|
+
"@repo/tsconfig": "5.13.0-next.34+c07fa96934",
|
|
88
|
+
"@repo/package.config": "5.13.0-next.34+c07fa96934"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=20.19 <22 || >=22.12"
|