diff --git a/DOWNLOAD_STATS.md b/DOWNLOAD_STATS.md index 5f860c2c..d0c11042 100644 --- a/DOWNLOAD_STATS.md +++ b/DOWNLOAD_STATS.md @@ -21,6 +21,7 @@ | `@nolyfill/es-aggregate-error` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es-aggregate-error.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es-aggregate-error) | | `@nolyfill/es-iterator-helpers` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es-iterator-helpers.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es-iterator-helpers) | | `@nolyfill/es-set-tostringtag` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es-set-tostringtag.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es-set-tostringtag) | +| `@nolyfill/es6-object-assign` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es6-object-assign.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es6-object-assign) | | `@nolyfill/function-bind` | [![npm](https://img.shields.io/npm/dt/@nolyfill/function-bind.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/function-bind) | | `@nolyfill/function.prototype.name` | [![npm](https://img.shields.io/npm/dt/@nolyfill/function.prototype.name.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/function.prototype.name) | | `@nolyfill/get-symbol-description` | [![npm](https://img.shields.io/npm/dt/@nolyfill/get-symbol-description.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/get-symbol-description) | @@ -37,6 +38,7 @@ | `@nolyfill/is-array-buffer` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-array-buffer.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-array-buffer) | | `@nolyfill/is-date-object` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-date-object.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-date-object) | | `@nolyfill/is-generator-function` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-generator-function.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-generator-function) | +| `@nolyfill/is-nan` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-nan.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-nan) | | `@nolyfill/is-regex` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-regex.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-regex) | | `@nolyfill/is-shared-array-buffer` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-shared-array-buffer.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-shared-array-buffer) | | `@nolyfill/is-string` | [![npm](https://img.shields.io/npm/dt/@nolyfill/is-string.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/is-string) | diff --git a/create.ts b/create.ts index b8892b6e..1ec11e6c 100644 --- a/create.ts +++ b/create.ts @@ -43,6 +43,7 @@ const autoGeneratedPackagesList = [ ['array.prototype.flatmap'], ['arraybuffer.prototype.slice'], ['function.prototype.name'], + ['is-nan'], ['has'], ['object-keys'], ['object.assign'], @@ -94,6 +95,7 @@ const singleFilePackagesList = [ ['iterator.prototype'], ['available-typed-arrays'], ['which-typed-array', { '@nolyfill/shared': 'workspace:*' }], + ['es6-object-assign'], ['which-boxed-primitive'], ['unbox-primitive'], ['is-regex'], diff --git a/package.json b/package.json index e9e46885..52503bd9 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "es-aggregate-error": "workspace:@nolyfill/es-aggregate-error@*", "es-iterator-helpers": "workspace:@nolyfill/es-iterator-helpers@*", "es-set-tostringtag": "workspace:@nolyfill/es-set-tostringtag@*", + "es6-object-assign": "workspace:@nolyfill/es6-object-assign@*", "function-bind": "workspace:@nolyfill/function-bind@*", "function.prototype.name": "workspace:@nolyfill/function.prototype.name@*", "get-symbol-description": "workspace:@nolyfill/get-symbol-description@*", @@ -72,6 +73,7 @@ "is-array-buffer": "workspace:@nolyfill/is-array-buffer@*", "is-date-object": "workspace:@nolyfill/is-date-object@*", "is-generator-function": "workspace:@nolyfill/is-generator-function@*", + "is-nan": "workspace:@nolyfill/is-nan@*", "is-regex": "workspace:@nolyfill/is-regex@*", "is-shared-array-buffer": "workspace:@nolyfill/is-shared-array-buffer@*", "is-string": "workspace:@nolyfill/is-string@*", @@ -140,6 +142,7 @@ "es-aggregate-error": "npm:@nolyfill/es-aggregate-error@latest", "es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@latest", "es-set-tostringtag": "npm:@nolyfill/es-set-tostringtag@latest", + "es6-object-assign": "npm:@nolyfill/es6-object-assign@latest", "function-bind": "npm:@nolyfill/function-bind@latest", "function.prototype.name": "npm:@nolyfill/function.prototype.name@latest", "get-symbol-description": "npm:@nolyfill/get-symbol-description@latest", @@ -156,6 +159,7 @@ "is-array-buffer": "npm:@nolyfill/is-array-buffer@latest", "is-date-object": "npm:@nolyfill/is-date-object@latest", "is-generator-function": "npm:@nolyfill/is-generator-function@latest", + "is-nan": "npm:@nolyfill/is-nan@latest", "is-regex": "npm:@nolyfill/is-regex@latest", "is-shared-array-buffer": "npm:@nolyfill/is-shared-array-buffer@latest", "is-string": "npm:@nolyfill/is-string@latest", diff --git a/packages/data/es-shim-like/src/is-nan.ts b/packages/data/es-shim-like/src/is-nan.ts new file mode 100644 index 00000000..06433050 --- /dev/null +++ b/packages/data/es-shim-like/src/is-nan.ts @@ -0,0 +1,3 @@ +import { defineEsShim } from '@nolyfill/shared'; + +export default defineEsShim(Number.isNaN, true); diff --git a/packages/data/single-file/src/es6-object-assign.ts b/packages/data/single-file/src/es6-object-assign.ts new file mode 100644 index 00000000..3fb862cb --- /dev/null +++ b/packages/data/single-file/src/es6-object-assign.ts @@ -0,0 +1,3 @@ +module.exports = { + polyfill(){} +} \ No newline at end of file diff --git a/packages/generated/array-buffer-byte-length/index.js b/packages/generated/array-buffer-byte-length/index.js index 1d374139..611da540 100644 --- a/packages/generated/array-buffer-byte-length/index.js +++ b/packages/generated/array-buffer-byte-length/index.js @@ -17,7 +17,7 @@ function _interop_require_default(obj) { } const bL = (0, _shared.uncurryThis)(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get); const is = (ab)=>{ - if (!(0, _isarraybuffer.default)(ab)) return NaN; + if (!(0, _isarraybuffer.default)(ab)) return Number.NaN; return bL(ab); }; const _default = is; diff --git a/packages/generated/array.prototype.at/entry.js b/packages/generated/array.prototype.at/entry.js index 63df44cd..ef4074d4 100644 --- a/packages/generated/array.prototype.at/entry.js +++ b/packages/generated/array.prototype.at/entry.js @@ -12,7 +12,7 @@ const _shared = require("@nolyfill/shared"); const implementation = Array.prototype.at || function at(n) { n = Math.trunc(n) || 0; if (n < 0) n += this.length; - if (n < 0 || n >= this.length) return undefined; + if (n < 0 || n >= this.length) return; return this[n]; }; const _default = (0, _shared.defineEsShim)(implementation); diff --git a/packages/generated/array.prototype.findlast/entry.js b/packages/generated/array.prototype.findlast/entry.js index 825da34b..1f3c32c7 100644 --- a/packages/generated/array.prototype.findlast/entry.js +++ b/packages/generated/array.prototype.findlast/entry.js @@ -9,11 +9,13 @@ Object.defineProperty(exports, "default", { } }); const _shared = require("@nolyfill/shared"); -const implementation = Array.prototype.findLast || function(callback, thisArg) { +// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- polyfill +const implementation = Array.prototype.findLast || function findLast(callback, thisArg) { for(let i = this.length - 1; i >= 0; i--){ const value = this[i]; if (callback.call(thisArg, value, i, this)) return value; } + return undefined; }; const _default = (0, _shared.defineEsShim)(implementation); diff --git a/packages/generated/array.prototype.findlastindex/entry.js b/packages/generated/array.prototype.findlastindex/entry.js index 866c3e12..76552be4 100644 --- a/packages/generated/array.prototype.findlastindex/entry.js +++ b/packages/generated/array.prototype.findlastindex/entry.js @@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", { } }); const _shared = require("@nolyfill/shared"); -const implementation = Array.prototype.findLastIndex || function(callback, thisArg) { +const implementation = Array.prototype.findLastIndex || function findLastIndex(callback, thisArg) { for(let i = this.length - 1; i >= 0; i--){ if (callback.call(thisArg, this[i], i, this)) return i; } diff --git a/packages/generated/array.prototype.tosorted/entry.js b/packages/generated/array.prototype.tosorted/entry.js index b67ddfd9..14887ea9 100644 --- a/packages/generated/array.prototype.tosorted/entry.js +++ b/packages/generated/array.prototype.tosorted/entry.js @@ -9,10 +9,10 @@ Object.defineProperty(exports, "default", { } }); const _shared = require("@nolyfill/shared"); -const implementation = Array.prototype.toSorted || function(compareFn) { +const implementation = Array.prototype.toSorted || function toSorted(compareFn) { const o = Object(this); const l = Number(o.length); - const a = Array.from(l); + const a = new Array(l); for(let i = 0; i < l; i++){ a[i] = o[i]; } diff --git a/packages/generated/es6-object-assign/index.js b/packages/generated/es6-object-assign/index.js new file mode 100644 index 00000000..02abae9c --- /dev/null +++ b/packages/generated/es6-object-assign/index.js @@ -0,0 +1,9 @@ +"use strict"; +module.exports = { + polyfill () {} +}; + +if ((typeof exports.default === 'object' && exports.default !== null) || typeof exports.default === 'function') { + Object.assign(exports.default, exports); +} +module.exports = exports.default; diff --git a/packages/generated/es6-object-assign/package.json b/packages/generated/es6-object-assign/package.json new file mode 100644 index 00000000..6c1a7700 --- /dev/null +++ b/packages/generated/es6-object-assign/package.json @@ -0,0 +1,19 @@ +{ + "name": "@nolyfill/es6-object-assign", + "version": "1.0.22", + "repository": { + "type": "git", + "url": "https://github.com/SukkaW/nolyfill", + "directory": "packages/generated/es6-object-assign" + }, + "main": "./index.js", + "license": "MIT", + "files": [ + "*.js" + ], + "scripts": {}, + "dependencies": {}, + "engines": { + "node": ">=12.4.0" + } +} diff --git a/packages/generated/internal-slot/index.js b/packages/generated/internal-slot/index.js index 2fdbf4fe..870f239e 100644 --- a/packages/generated/internal-slot/index.js +++ b/packages/generated/internal-slot/index.js @@ -14,10 +14,9 @@ const has = (O, slot)=>{ return !!slots && Object.hasOwn(slots, `$${slot}`); }; const get = (O, slot)=>{ - var _slots; check(O, slot); const slots = channel.get(O); - return (_slots = slots) === null || _slots === void 0 ? void 0 : _slots[`$${slot}`]; + return slots === null || slots === void 0 ? void 0 : slots[`$${slot}`]; }; const set = (O, slot, V)=>{ check(O, slot); diff --git a/packages/generated/is-array-buffer/index.js b/packages/generated/is-array-buffer/index.js index 7497dc68..351f1f9c 100644 --- a/packages/generated/is-array-buffer/index.js +++ b/packages/generated/is-array-buffer/index.js @@ -17,7 +17,7 @@ const is = (obj)=>{ try { bL(obj); return true; - } catch (_) { + } catch (e) { return false; } }; diff --git a/packages/generated/is-generator-function/index.js b/packages/generated/is-generator-function/index.js index 8b1dead3..d7b9cf0a 100644 --- a/packages/generated/is-generator-function/index.js +++ b/packages/generated/is-generator-function/index.js @@ -11,6 +11,7 @@ Object.defineProperty(exports, "default", { const isFnRegex = /^\s*(?:function)?\*/; // Node.js has full native support for generators since Node.js 6.4.0, so we don't need eval const GeneratorFunction = Object.getPrototypeOf(function*() {}); +// eslint-disable-next-line @typescript-eslint/ban-types -- any function function isGeneratorFunction(fn) { if (typeof fn !== 'function') return false; if (isFnRegex.test(Function.prototype.toString.call(fn))) return true; diff --git a/packages/generated/is-nan/auto.js b/packages/generated/is-nan/auto.js new file mode 100644 index 00000000..318c0bb9 --- /dev/null +++ b/packages/generated/is-nan/auto.js @@ -0,0 +1,2 @@ +'use strict'; +/* noop */ diff --git a/packages/generated/is-nan/entry.js b/packages/generated/is-nan/entry.js new file mode 100644 index 00000000..6f9a00e3 --- /dev/null +++ b/packages/generated/is-nan/entry.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { + return _default; + } +}); +const _shared = require("@nolyfill/shared"); +const _default = (0, _shared.defineEsShim)(Number.isNaN, true); + +Object.assign(exports.default, exports); +module.exports = exports.default; diff --git a/packages/generated/is-nan/implementation.js b/packages/generated/is-nan/implementation.js new file mode 100644 index 00000000..34019673 --- /dev/null +++ b/packages/generated/is-nan/implementation.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').implementation; diff --git a/packages/generated/is-nan/index.js b/packages/generated/is-nan/index.js new file mode 100644 index 00000000..563021d7 --- /dev/null +++ b/packages/generated/is-nan/index.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').index(); diff --git a/packages/generated/is-nan/package.json b/packages/generated/is-nan/package.json new file mode 100644 index 00000000..0471cede --- /dev/null +++ b/packages/generated/is-nan/package.json @@ -0,0 +1,21 @@ +{ + "name": "@nolyfill/is-nan", + "version": "1.0.22", + "repository": { + "type": "git", + "url": "https://github.com/SukkaW/nolyfill", + "directory": "packages/generated/is-nan" + }, + "main": "./index.js", + "license": "MIT", + "files": [ + "*.js" + ], + "scripts": {}, + "dependencies": { + "@nolyfill/shared": "workspace:*" + }, + "engines": { + "node": ">=12.4.0" + } +} diff --git a/packages/generated/is-nan/polyfill.js b/packages/generated/is-nan/polyfill.js new file mode 100644 index 00000000..4166abf3 --- /dev/null +++ b/packages/generated/is-nan/polyfill.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').polyfill; diff --git a/packages/generated/is-nan/shim.js b/packages/generated/is-nan/shim.js new file mode 100644 index 00000000..301a98bd --- /dev/null +++ b/packages/generated/is-nan/shim.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').shim; diff --git a/packages/generated/is-shared-array-buffer/index.js b/packages/generated/is-shared-array-buffer/index.js index f0bed380..ebee7135 100644 --- a/packages/generated/is-shared-array-buffer/index.js +++ b/packages/generated/is-shared-array-buffer/index.js @@ -17,7 +17,7 @@ const is = (obj)=>{ try { bL(obj); return true; - } catch (_) { + } catch (e) { return false; } }; diff --git a/packages/generated/is-weakref/index.js b/packages/generated/is-weakref/index.js index 6ea9b186..369fdd93 100644 --- a/packages/generated/is-weakref/index.js +++ b/packages/generated/is-weakref/index.js @@ -1,4 +1,13 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { + return _default; + } +}); const is = (value)=>{ if (typeof WeakRef === 'undefined') return false; if (!value || typeof value !== 'object') return false; @@ -9,6 +18,7 @@ const is = (value)=>{ return false; } }; +const _default = is; if ((typeof exports.default === 'object' && exports.default !== null) || typeof exports.default === 'function') { Object.assign(exports.default, exports); diff --git a/packages/generated/safe-regex-test/index.js b/packages/generated/safe-regex-test/index.js index 07a330d4..c30e12b1 100644 --- a/packages/generated/safe-regex-test/index.js +++ b/packages/generated/safe-regex-test/index.js @@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", { }); const safeRegexTest = (r)=>{ if (!r || typeof r !== 'object' && typeof r !== 'function' || Object.prototype.toString.call(r) !== '[object RegExp]') { - throw new TypeError('\`regex\` must be a RegExp'); + throw new TypeError('`regex` must be a RegExp'); } return (s)=>RegExp.prototype.exec.call(r, s) !== null; }; diff --git a/packages/generated/string.prototype.at/entry.js b/packages/generated/string.prototype.at/entry.js index 4a838d83..81bcc5fe 100644 --- a/packages/generated/string.prototype.at/entry.js +++ b/packages/generated/string.prototype.at/entry.js @@ -12,7 +12,7 @@ const _shared = require("@nolyfill/shared"); const implementation = String.prototype.at || function at(n) { n = Math.trunc(n) || 0; if (n < 0) n += this.length; - if (n < 0 || n >= this.length) return undefined; + if (n < 0 || n >= this.length) return; return String.prototype.charAt.call(this, n); }; const _default = (0, _shared.defineEsShim)(implementation); diff --git a/packages/generated/string.prototype.trimstart/shim.js b/packages/generated/string.prototype.trimstart/shim.js index 26e98762..301a98bd 100644 --- a/packages/generated/string.prototype.trimstart/shim.js +++ b/packages/generated/string.prototype.trimstart/shim.js @@ -1,3 +1,2 @@ 'use strict'; - module.exports = require('./entry.js').shim; diff --git a/packages/generated/unbox-primitive/index.js b/packages/generated/unbox-primitive/index.js index dda12069..2e7a946a 100644 --- a/packages/generated/unbox-primitive/index.js +++ b/packages/generated/unbox-primitive/index.js @@ -26,7 +26,7 @@ function unboxPrimitive(value) { } try { return BigInt.prototype.valueOf.call(value); - } catch (_) {} + } catch (e) {} throw new RangeError('unknown boxed primitive'); } diff --git a/packages/generated/which-boxed-primitive/index.js b/packages/generated/which-boxed-primitive/index.js index 42b6675d..122192da 100644 --- a/packages/generated/which-boxed-primitive/index.js +++ b/packages/generated/which-boxed-primitive/index.js @@ -24,8 +24,9 @@ const which = (value)=>{ try { BigInt.prototype.valueOf.call(value); return 'BigInt'; - } catch (_) {} + } catch (e) {} } + return undefined; }; const _default = which; diff --git a/packages/tools/cli/src/all-packages.ts b/packages/tools/cli/src/all-packages.ts index b19b6814..084651bb 100644 --- a/packages/tools/cli/src/all-packages.ts +++ b/packages/tools/cli/src/all-packages.ts @@ -20,6 +20,7 @@ export const allPackages = [ "es-aggregate-error", "es-iterator-helpers", "es-set-tostringtag", + "es6-object-assign", "function-bind", "function.prototype.name", "get-symbol-description", @@ -36,6 +37,7 @@ export const allPackages = [ "is-array-buffer", "is-date-object", "is-generator-function", + "is-nan", "is-regex", "is-shared-array-buffer", "is-string", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e7810569..a922939b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,6 +24,7 @@ overrides: es-aggregate-error: workspace:@nolyfill/es-aggregate-error@* es-iterator-helpers: workspace:@nolyfill/es-iterator-helpers@* es-set-tostringtag: workspace:@nolyfill/es-set-tostringtag@* + es6-object-assign: workspace:@nolyfill/es6-object-assign@* function-bind: workspace:@nolyfill/function-bind@* function.prototype.name: workspace:@nolyfill/function.prototype.name@* get-symbol-description: workspace:@nolyfill/get-symbol-description@* @@ -40,6 +41,7 @@ overrides: is-array-buffer: workspace:@nolyfill/is-array-buffer@* is-date-object: workspace:@nolyfill/is-date-object@* is-generator-function: workspace:@nolyfill/is-generator-function@* + is-nan: workspace:@nolyfill/is-nan@* is-regex: workspace:@nolyfill/is-regex@* is-shared-array-buffer: workspace:@nolyfill/is-shared-array-buffer@* is-string: workspace:@nolyfill/is-string@* @@ -271,6 +273,8 @@ importers: packages/generated/es-set-tostringtag: {} + packages/generated/es6-object-assign: {} + packages/generated/function.prototype.name: dependencies: '@nolyfill/shared': @@ -317,6 +321,12 @@ importers: packages/generated/is-generator-function: {} + packages/generated/is-nan: + dependencies: + '@nolyfill/shared': + specifier: workspace:* + version: link:../../tools/shared + packages/generated/is-regex: {} packages/generated/is-shared-array-buffer: