Name: es-shim-api
Owner: ECMAScript Shims
Description: API contract, and rudimentary tests, for modules that conform to the *es-shim API*
Created: 2015-08-16 04:10:13.0
Updated: 2018-05-11 02:10:53.0
Pushed: 2017-12-30 21:43:05.0
Homepage: null
Size: 54
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
For any given ?es-shim API?-compliant package foo
, the following invariants must hold:
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.require('foo/auto')
will automatically invoke the shim
method.shim
method.npm test
must run the package?s tests.require
d.require('foo'); delete Function.prototype.call;
must not alter the behavior of foo
.var bind = require('function-bind'); var slice = bind.call(Function.call, Array.prototype.slice); slice([1], 1);
? this technique works in ES3 environments, and will ensure that modifying Array.prototype
will not interfere with the package.Prominently in the package?s README, please include the following markdown:
package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/).
Please modify ?ES3? as needed to the level of support, and please update the spec link so it points directly to the most relevant section of the spec it complies with.
Very simple and shallow tests that a package follows the es-shim API
.
Pass --bound
to indicate that the function the package is implementing depends on having a receiver (a ?this? value).
him-api object-assign
him-api array-includes --bound
Simply clone the repo, npm install
, and run npm test