@natlibfi/es6-shims

ES6 shims that use native implementation if available

Usage no npm install needed!

<script type="module">
  import natlibfiEs6Shims from 'https://cdn.skypack.dev/@natlibfi/es6-shims';
</script>

README

ES6 shims NPM Version Build Status Test Coverage

A collection of ES6 shims that use native implementations if available.

If you are looking for ES6 polyfills check out es6-polyfills.

List of shims

  • Array
    • Array.prototype.find
    • Array.prototype.findIndex

Installation

Clone the sources and install the package (In the source directory) on command line using npm:

npm install

Testing

Run the following NPM script to lint, test and check coverage of the code:


npm run check

Usage

Individual shims can be found inside the containing object's directory, e.g. lib/shims/array/

AMD


define(['es6-shims/lib/shims/array'], function(shim_array) {

  // index === 1
  var index = shim_array.find([1, 2, 3], function(element) {
    return element === 2;
  });

});


Browser globals


  // index === 1
  var index = es6_shim_array.find([1, 2, 3], function(element) {
    return element === 2;
  });

});


Node.js


  var shim_array = require('es6-shims/lib/shims/array');
  // index === 1
  var index = shim_array.find([1, 2, 3], function(element) {
    return element === 2;
  });


License and copyright

Copyright (c) 2016-2017 University Of Helsinki (The National Library Of Finland)

This project's source code is licensed under the terms of GNU Lesser General Public License Version 3 or any later version.