Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@es-shims/api

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-shims/api - npm Package Compare versions

Comparing version 2.5.1 to 3.0.0

api.mjs

14

autoTest.js

@@ -5,10 +5,10 @@ #!/usr/bin/env node

var assert = require('assert');
var path = require('path');
const assert = require('assert');
const path = require('path');
var args = process.argv.slice(2); // remove node, and script name
const args = process.argv.slice(2); // remove node, and script name
assert.equal(args, 0, 'wrong number of arguments; expected 0');
var fakeShim = require('./fakeShim');
const fakeShim = require('./fakeShim');
assert.equal(fakeShim.calls.length, 0, 'shim was not yet called');

@@ -18,9 +18,9 @@

var autoPath = path.join(process.cwd(), './auto');
const autoPath = path.join(process.cwd(), './auto');
console.log('## Requiring ' + autoPath + '...');
console.log(`## Requiring ${autoPath}...`);
require(autoPath);
console.log('## shim was called ' + fakeShim.calls.length + ' times');
console.log(`## shim was called ${fakeShim.calls.length} times`);

@@ -27,0 +27,0 @@ assert.equal(fakeShim.calls.length, 1, 'shim was called once');

@@ -8,2 +8,16 @@ # Changelog

## [v3.0.0](https://github.com/es-shims/es-shim-api/compare/v2.5.1...v3.0.0) - 2024-09-19
### Commits
- [Breaking] require node 20.17 [`84bb1ec`](https://github.com/es-shims/es-shim-api/commit/84bb1ec39e3231f6430a778b9155c67a362f1141)
- [Refactor] use `pargs` and ESM [`21e483c`](https://github.com/es-shims/es-shim-api/commit/21e483cf99f8da0f818f2953b496ecef8a9562c3)
- [New] add types [`3caf579`](https://github.com/es-shims/es-shim-api/commit/3caf579f4445723fd18c9b6f54f8f54c5910653e)
- [Docs] update shims list [`531e6f1`](https://github.com/es-shims/es-shim-api/commit/531e6f19b7778a6a240f0d8f1c70fcb44345eb13)
- [Breaking] condense some booleans into enum `type` arg [`d205d23`](https://github.com/es-shims/es-shim-api/commit/d205d23b982292d1de7a78d9cbcddd085289533d)
- [Breaking] remove expando properties from the index [`27975e1`](https://github.com/es-shims/es-shim-api/commit/27975e1be92e0f0ea70b05f255ce973899a2349c)
- [Deps] remove some unneeded packages [`64bb6cd`](https://github.com/es-shims/es-shim-api/commit/64bb6cdc05318155960a8fae698a85d49c2c957c)
- [Deps] update `semver` [`abd2974`](https://github.com/es-shims/es-shim-api/commit/abd2974ad15009e6265581a9fb67003a2fe42485)
- [Breaking] add `exports` [`f57bc0a`](https://github.com/es-shims/es-shim-api/commit/f57bc0a13ae8ff4ab34ef3a38f29e0ee5300c3eb)
## [v2.5.1](https://github.com/es-shims/es-shim-api/compare/v2.5.0...v2.5.1) - 2024-09-04

@@ -10,0 +24,0 @@

'use strict';
var calls = [];
var shim = function fakeShim() {
calls.push([this, Array.prototype.slice.call(arguments)]);
/** @type {[unknown, unknown[]][]} */
const calls = [];
/** @type {{ calls: typeof calls } & ((this: unknown) => void)} */
const shim = function fakeShim(...args) {
calls.push([this, args]);
};

@@ -7,0 +9,0 @@ shim.calls = calls;

@@ -5,35 +5,34 @@ #!/usr/bin/env node

var assert = require('assert');
var path = require('path');
const assert = require('assert');
const path = require('path');
var args = process.argv.slice(2); // remove node, and script name
const args = process.argv.slice(2); // remove node, and script name
assert.equal(args, 0, 'wrong number of arguments; expected 0');
var fakeShim = require('./fakeShim');
const fakeShim = require('./fakeShim');
assert.equal(fakeShim.calls.length, 0, 'shims are not yet called');
var subPackages = require(process.cwd());
subPackages.forEach(function (subPackage) {
/** @type {string[]} */
const subPackages = require(process.cwd());
subPackages.forEach((subPackage) => {
require.cache[require.resolve(path.join(process.cwd(), subPackage, 'shim'))] = require.cache[require.resolve('./fakeShim')];
});
var autoPath = path.join(process.cwd(), './auto');
const autoPath = path.join(process.cwd(), './auto');
console.log('## Requiring root ' + autoPath + '...');
console.log(`## Requiring root ${autoPath}...`);
require(autoPath);
subPackages.forEach(function (subPackage) {
subPackages.forEach((subPackage) => {
require(path.join(process.cwd(), subPackage, 'auto'));
});
console.log('## shims were called ' + fakeShim.calls.length + ' times');
console.log(`## shims were called ${fakeShim.calls.length} times`);
assert.equal(fakeShim.calls.length, subPackages.length * 2, 'shim was called twice per sub-package');
var expectedCalls = subPackages.map(function () {
return [undefined, []];
});
const expectedCalls = subPackages.map(() => [undefined, []]);
assert.deepEqual(fakeShim.calls, expectedCalls.concat(expectedCalls), 'all shims were invoked with no receiver or arguments');
console.log('## all shims were invoked with no receiver or arguments');
{
"name": "@es-shims/api",
"version": "2.5.1",
"version": "3.0.0",
"author": "Jordan Harband",

@@ -10,4 +10,9 @@ "funding": {

"bin": {
"es-shim-api": "api.js"
"es-shim-api": "api.mjs"
},
"main": false,
"exports": {
"./package.json": "./package.json"
},
"types": "index.d.ts",
"license": "MIT",

@@ -24,3 +29,4 @@ "scripts": {

"tests-only": "echo 'no tests yet :-('",
"lint": "eslint ."
"lint": "eslint --ext=js,mjs .",
"postlint": "tsc && attw -P"
},

@@ -45,38 +51,28 @@ "repository": {

"dependencies": {
"array-includes": "^3.1.8",
"array.prototype.flatmap": "^1.3.2",
"object-inspect": "^1.13.2",
"object-keys": "^1.1.1",
"object.groupby": "^1.0.3",
"semver": "^7.6.3",
"tape": "^5.8.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.4",
"@ljharb/eslint-config": "^21.1.1",
"@ljharb/tsconfig": "^0.2.0",
"@types/node": "^20.16.5",
"@types/object-inspect": "^1.13.0",
"@types/object.groupby": "^1.0.4",
"@types/semver": "^7.5.8",
"@types/tape": "^5.6.4",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"in-publish": "^2.0.1",
"make-arrow-function": "^1.2.0",
"make-generator-function": "^2.0.0",
"npmignore": "^0.3.1",
"safe-publish-latest": "^2.0.0"
"safe-publish-latest": "^2.0.0",
"typescript": "next"
},
"testling": {
"files": "test.js",
"browsers": [
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2"
]
"files": "test.js"
},
"engines": {
"node": ">= 0.4"
"node": "^20.17 || >= 22.9"
},

@@ -94,5 +90,6 @@ "auto-changelog": {

"ignore": [
".github/workflows"
".github/workflows",
"shims.md"
]
}
}

@@ -11,9 +11,10 @@ # es-shim API <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

## API Contract
For any given “es-shim API”-compliant package `foo`, the following invariants must hold:
For any given “es-shim API v3”-compliant package `foo`, the following invariants must hold:
- This package will run in an environment supporting the oldest JS version in which the spec’s semantics are achievable - ES3, ES5, and/or ES6. The package should indicate its minimum level of required environment support in its README.
- The package must attempt to support `node`/`io.js`, all versions of all ES3-compliant browsers or later, Web Workers, and `node-webkit`. Other environments are a plus, but not expected.
- `require('foo')` is a spec-compliant JS or native function. However, if the function’s behavior depends on a receiver (a “this” value), then the first argument to this function will be used as that receiver. The package should indicate if this is the case in its README.
- `require('foo').implementation` or `require('foo/implementation')` is a spec-compliant JS function, that will depend on a receiver (a “this” value) as the spec requires.
- `require('foo').getPolyfill` or `require('foo/polyfill')` is a function that when invoked, will return the most compliant and performant function that it can - if a native version is available, and does not violate the spec, then the native function will be returned - otherwise, either the `implementation`, or a custom, wrapped version of the native function, will be returned. This is also the result that will be used as the default export.
- `require('foo').shim` or `require('foo/shim')` is a function that when invoked, will call `getPolyfill`, and if the polyfill doesn’t match the built-in value, will install it into the global environment.
- In the case of static methods like `Promise.all` that depend on their receiver without a fallback, the index must ensure that receiverless invocation acts as if the static method was called on its original object, but must also allow `.call`/`.bind`/`.apply` to alter the receiver when relevant.
- `require('foo/implementation')` is a spec-compliant JS function, that will depend on a receiver (a “this” value) as the spec requires.
- `require('foo/polyfill')` is a function that when invoked, will return the most compliant and performant function that it can - if a native version is available, and does not violate the spec, then the native function will be returned - otherwise, either the `implementation`, or a custom, wrapped version of the native function, will be returned. This is also the result that will be used as the default export.
- `require('foo/shim')` is a function that when invoked, will call `getPolyfill`, and if the polyfill doesn’t match the built-in value, will install it into the global environment.
- `require('foo/auto')` will automatically invoke the `shim` method.

@@ -34,5 +35,5 @@ - The only place the package may modify the environment is within its `shim` method.

## Recommended dependencies
- Please use the [es-abstract][es-abstract-url] module to ensure spec-compliant behavior via the spec’s internal abstract operations.
- Please use the [define-properties][define-properties-url] module to trivially define non-enumerable properties, where supported.
- Please use the [call-bind][call-bind-url] module to cache references to all builtin methods, to be robust against later modification of the environment.
- Please use the [es-abstract][es-abstract-url] package to ensure spec-compliant behavior via the spec’s internal abstract operations.
- Please use the [define-properties][define-properties-url] package to trivially define non-enumerable properties, where supported.
- Please use the [call-bind][call-bind-url] package to cache references to all builtin methods, to be robust against later modification of the environment.

@@ -50,3 +51,3 @@

Pass `--bound` to indicate that the function the package is implementing depends on having a receiver (a “this” value).
Pass `--bound` to indicate that the function the package is implementing depends on having a receiver (a “this” value). In particular, this applies to something that is a prototype method, or a static method that depends on its receiver.

@@ -53,0 +54,0 @@ ## Example

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc