@goldyjs/natives
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -7,2 +7,8 @@ declare global { | ||
_stringify({ spacing } = { spacing: number }): string | ||
/** | ||
* const obj = { a: 1, b: undefined, c: null } | ||
* obj._compact() -> { a: 1 } | ||
*/ | ||
_compact(): string | ||
} | ||
@@ -9,0 +15,0 @@ } |
@@ -32,2 +32,8 @@ declare global { | ||
_stringify({ spacing } = { spacing: number }): string | ||
/** | ||
* const obj = { a: 1, b: undefined, c: null } | ||
* obj._compact() -> { a: 1 } | ||
*/ | ||
_compact(): string | ||
} | ||
@@ -34,0 +40,0 @@ } |
@@ -32,2 +32,8 @@ declare global { | ||
_stringify({ spacing } = { spacing: number }): string | ||
/** | ||
* const obj = { a: 1, b: undefined, c: null } | ||
* obj._compact() -> { a: 1 } | ||
*/ | ||
_compact(): string | ||
} | ||
@@ -34,0 +40,0 @@ } |
{ | ||
"name": "@goldyjs/natives", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"LICENSE": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Extending the native JavaScript API", |
[![semantic-release: commitizen](https://img.shields.io/badge/semantic--release-commitizen-brightgreen?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
# Array | ||
```js | ||
@@ -10,1 +11,6 @@ ;[1, 2, 3]._last() | ||
``` | ||
# Object | ||
```js | ||
obj._stringify() === JSON.stringify(obj, null, 2) | ||
``` |
@@ -5,2 +5,4 @@ describe("Natives - object", describeObject) | ||
it("stringify", itStringify) | ||
it("compact", itCompact) | ||
} | ||
@@ -14,3 +16,9 @@ | ||
function itCompact() { | ||
const obj = { a: 1, b: undefined, c: null } | ||
expect(obj._compact()).toStrictEqual({ a: 1 }) | ||
} | ||
// eslint-disable-next-line jest/no-export | ||
export {} |
@@ -14,1 +14,16 @@ import { isDev } from "../utils/env" | ||
}) | ||
Object.defineProperty(Object.prototype, "_compact", { | ||
writable: false, | ||
enumerable: false, | ||
configurable: false, | ||
value() { | ||
return Object.entries(this).reduce((acc, [key, value]) => { | ||
if (![null, undefined].includes(value)) { | ||
acc[key] = value | ||
} | ||
return acc | ||
}, {}) | ||
}, | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31296
47
655
16