| {"version":3,"file":"dnull.js","sources":["../src/dnull.ts"],"sourcesContent":["type PlainObj = { [key: PropertyKey]: any };\n\nconst isPlainObject = (value: unknown): value is PlainObj => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value))\n return false;\n const proto = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n};\n\nexport type DNull<T> = T extends null\n ? undefined\n : T extends PlainObj\n ? { [K in keyof T]: DNull<T[K]> }\n : T extends Array<infer U>\n ? DNull<U>[]\n : T;\n\nexport const dnull = <T>(src: T): DNull<T> => {\n if (src === null) return void 0 as DNull<T>;\n if (isPlainObject(src)) {\n const clone = Object.create(null);\n for (const [key, value] of Object.entries(src)) {\n clone[key] = dnull(value);\n }\n return clone as DNull<T>;\n }\n if (Array.isArray(src)) {\n return (src as unknown[]).map(dnull) as DNull<T>;\n }\n return src as DNull<T>;\n};\n"],"names":["isPlainObject","value","proto","dnull","src","clone","key"],"mappings":"oEAEA,MAAMA,EAAiBC,GAAsC,CAC3D,GAAI,OAAOA,GAAU,UAAYA,IAAU,MAAQ,MAAM,QAAQA,CAAK,EACpE,MAAO,GACT,MAAMC,EAAQ,OAAO,eAAeD,CAAK,EACzC,OAAOC,IAAU,MAAQA,IAAU,OAAO,SAC5C,EAUaC,EAAYC,GAAqB,CAC5C,GAAIA,IAAQ,KACZ,CAAA,GAAIJ,EAAcI,CAAG,EAAG,CACtB,MAAMC,EAAQ,OAAO,OAAO,IAAI,EAChC,SAAW,CAACC,EAAKL,CAAK,IAAK,OAAO,QAAQG,CAAG,EAC3CC,EAAMC,GAAOH,EAAMF,CAAK,EAE1B,OAAOI,CACT,CACA,OAAI,MAAM,QAAQD,CAAG,EACXA,EAAkB,IAAID,CAAK,EAE9BC,CACT,CAAA"} |
| {"version":3,"file":"dnull.mjs","sources":["../src/dnull.ts"],"sourcesContent":["type PlainObj = { [key: PropertyKey]: any };\n\nconst isPlainObject = (value: unknown): value is PlainObj => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value))\n return false;\n const proto = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n};\n\nexport type DNull<T> = T extends null\n ? undefined\n : T extends PlainObj\n ? { [K in keyof T]: DNull<T[K]> }\n : T extends Array<infer U>\n ? DNull<U>[]\n : T;\n\nexport const dnull = <T>(src: T): DNull<T> => {\n if (src === null) return void 0 as DNull<T>;\n if (isPlainObject(src)) {\n const clone = Object.create(null);\n for (const [key, value] of Object.entries(src)) {\n clone[key] = dnull(value);\n }\n return clone as DNull<T>;\n }\n if (Array.isArray(src)) {\n return (src as unknown[]).map(dnull) as DNull<T>;\n }\n return src as DNull<T>;\n};\n"],"names":["isPlainObject","value","proto","dnull","src","clone","key"],"mappings":"AAEA,MAAMA,EAAiBC,GAAsC,CAC3D,GAAI,OAAOA,GAAU,UAAYA,IAAU,MAAQ,MAAM,QAAQA,CAAK,EACpE,MAAO,GACT,MAAMC,EAAQ,OAAO,eAAeD,CAAK,EACzC,OAAOC,IAAU,MAAQA,IAAU,OAAO,SAC5C,EAUaC,EAAYC,GAAqB,CAC5C,GAAIA,IAAQ,KACZ,CAAA,GAAIJ,EAAcI,CAAG,EAAG,CACtB,MAAMC,EAAQ,OAAO,OAAO,IAAI,EAChC,SAAW,CAACC,EAAKL,CAAK,IAAK,OAAO,QAAQG,CAAG,EAC3CC,EAAMC,GAAOH,EAAMF,CAAK,EAE1B,OAAOI,CACT,CACA,OAAI,MAAM,QAAQD,CAAG,EACXA,EAAkB,IAAID,CAAK,EAE9BC,CACT,CAAA"} |
+9
-1
@@ -1,1 +0,9 @@ | ||
| export * from './dnull.ts'; | ||
| declare type PlainObj = { | ||
| [key: PropertyKey]: any; | ||
| }; | ||
| declare type DNull<T> = T extends null ? undefined : T extends PlainObj ? { | ||
| [K in keyof T]: DNull<T[K]>; | ||
| } : T extends Array<infer U> ? DNull<U>[] : T; | ||
| declare const dnull: <T>(src: T) => DNull<T>; | ||
| export { DNull, dnull }; |
+2
-1
@@ -1,1 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./dnull.ts");Object.keys(t).forEach(function(e){e!=="default"&&!exports.hasOwnProperty(e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}); | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const o=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const r=Object.getPrototypeOf(t);return r===null||r===Object.prototype},n=t=>{if(t!==null){if(o(t)){const r=Object.create(null);for(const[e,l]of Object.entries(t))r[e]=n(l);return r}return Array.isArray(t)?t.map(n):t}};exports.dnull=n; | ||
| //# sourceMappingURL=dnull.js.map |
+2
-1
@@ -1,1 +0,2 @@ | ||
| export*from"./dnull.ts"; | ||
| const l=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const r=Object.getPrototypeOf(t);return r===null||r===Object.prototype},n=t=>{if(t!==null){if(l(t)){const r=Object.create(null);for(const[o,c]of Object.entries(t))r[o]=n(c);return r}return Array.isArray(t)?t.map(n):t}};export{n as dnull}; | ||
| //# sourceMappingURL=dnull.mjs.map |
+0
-0
@@ -0,0 +0,0 @@ MIT License Copyright (c) 2021 Gabriel Vaquer |
+19
-19
| { | ||
| "name": "dnull", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "Replace null with undefined on any value", | ||
@@ -23,22 +23,22 @@ "main": "dist/dnull.js", | ||
| "devDependencies": { | ||
| "@types/jest": "^27.4.0", | ||
| "@types/node": "^17.0.8", | ||
| "@typescript-eslint/eslint-plugin": "^5.9.0", | ||
| "@typescript-eslint/parser": "^5.9.0", | ||
| "esbuild": "^0.14.11", | ||
| "eslint": "^8.6.0", | ||
| "eslint-config-prettier": "^8.3.0", | ||
| "eslint-plugin-prettier": "^4.0.0", | ||
| "husky": "^7.0.4", | ||
| "@types/jest": "^28.1.8", | ||
| "@types/node": "^18.7.13", | ||
| "@typescript-eslint/eslint-plugin": "^5.35.1", | ||
| "@typescript-eslint/parser": "^5.35.1", | ||
| "esbuild": "^0.15.5", | ||
| "eslint": "^8.23.0", | ||
| "eslint-config-prettier": "^8.5.0", | ||
| "eslint-plugin-prettier": "^4.2.1", | ||
| "husky": "^8.0.1", | ||
| "is-ci": "^3.0.1", | ||
| "jest": "^27.4.7", | ||
| "lint-staged": "^12.1.7", | ||
| "pinst": "^2.1.6", | ||
| "prettier": "^2.5.1", | ||
| "jest": "^29.0.1", | ||
| "lint-staged": "^13.0.3", | ||
| "pinst": "^3.0.0", | ||
| "prettier": "^2.7.1", | ||
| "rimraf": "^3.0.2", | ||
| "rollup": "^2.63.0", | ||
| "rollup-plugin-dts": "^4.1.0", | ||
| "rollup-plugin-esbuild": "^4.8.2", | ||
| "ts-jest": "^27.1.2", | ||
| "typescript": "^4.5.4" | ||
| "rollup": "^2.78.1", | ||
| "rollup-plugin-dts": "^4.2.2", | ||
| "rollup-plugin-esbuild": "^4.10.1", | ||
| "ts-jest": "^28.0.8", | ||
| "typescript": "^4.8.2" | ||
| }, | ||
@@ -45,0 +45,0 @@ "repository": { |
+0
-0
@@ -0,0 +0,0 @@ # dnull |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6908
114.2%8
33.33%14
366.67%0
-100%1
Infinity%