Skip to content

Commit

Permalink
feat: add is-nan and es6-object-assign (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
asukaminato0721 authored Nov 12, 2023
1 parent 617ba7e commit 2c89305
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 15 deletions.
2 changes: 2 additions & 0 deletions DOWNLOAD_STATS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand All @@ -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) |
Expand Down
2 changes: 2 additions & 0 deletions create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const autoGeneratedPackagesList = [
['array.prototype.flatmap'],
['arraybuffer.prototype.slice'],
['function.prototype.name'],
['is-nan'],
['has'],
['object-keys'],
['object.assign'],
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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@*",
Expand All @@ -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@*",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/data/es-shim-like/src/is-nan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineEsShim } from '@nolyfill/shared';

export default defineEsShim(Number.isNaN, true);
3 changes: 3 additions & 0 deletions packages/data/single-file/src/es6-object-assign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
polyfill(){}
}
2 changes: 1 addition & 1 deletion packages/generated/array-buffer-byte-length/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/array.prototype.at/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion packages/generated/array.prototype.findlast/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion packages/generated/array.prototype.findlastindex/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/generated/array.prototype.tosorted/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
9 changes: 9 additions & 0 deletions packages/generated/es6-object-assign/index.js
Original file line number Diff line number Diff line change
@@ -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;
19 changes: 19 additions & 0 deletions packages/generated/es6-object-assign/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 1 addition & 2 deletions packages/generated/internal-slot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/is-array-buffer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const is = (obj)=>{
try {
bL(obj);
return true;
} catch (_) {
} catch (e) {
return false;
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/generated/is-generator-function/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions packages/generated/is-nan/auto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
/* noop */
15 changes: 15 additions & 0 deletions packages/generated/is-nan/entry.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions packages/generated/is-nan/implementation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('./entry.js').implementation;
2 changes: 2 additions & 0 deletions packages/generated/is-nan/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('./entry.js').index();
21 changes: 21 additions & 0 deletions packages/generated/is-nan/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions packages/generated/is-nan/polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('./entry.js').polyfill;
2 changes: 2 additions & 0 deletions packages/generated/is-nan/shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('./entry.js').shim;
2 changes: 1 addition & 1 deletion packages/generated/is-shared-array-buffer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const is = (obj)=>{
try {
bL(obj);
return true;
} catch (_) {
} catch (e) {
return false;
}
};
Expand Down
10 changes: 10 additions & 0 deletions packages/generated/is-weakref/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/safe-regex-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/string.prototype.at/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion packages/generated/string.prototype.trimstart/shim.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
'use strict';

module.exports = require('./entry.js').shim;
2 changes: 1 addition & 1 deletion packages/generated/unbox-primitive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function unboxPrimitive(value) {
}
try {
return BigInt.prototype.valueOf.call(value);
} catch (_) {}
} catch (e) {}
throw new RangeError('unknown boxed primitive');
}

Expand Down
3 changes: 2 additions & 1 deletion packages/generated/which-boxed-primitive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const which = (value)=>{
try {
BigInt.prototype.valueOf.call(value);
return 'BigInt';
} catch (_) {}
} catch (e) {}
}
return undefined;
};
const _default = which;

Expand Down
2 changes: 2 additions & 0 deletions packages/tools/cli/src/all-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c89305

Please sign in to comment.