Package detail

array.prototype.tosorted

es-shims75.6mMIT1.1.4

An ESnext spec-compliant Array.prototype.toSorted shim/polyfill/replacement that works as far down as ES3.

javascript, ecmascript, shim, polyfill

readme

array.prototype.tosorted Version Badge

dependency status dev dependency status License Downloads

npm badge

An ESnext spec-compliant Array.prototype.toSorted shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.

Because Array.prototype.toSorted depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Getting started

npm install --save array.prototype.tosorted

Usage/Examples

var toSorted = require('array.prototype.tosorted');
var assert = require('assert');

var input = [5, 4, 3, 2, 1, 0];

var output = toSorted(input);

assert.deepEqual(output, [0, 1, 2, 3, 4, 5]);
assert.notEqual(output, input);
assert.deepEqual(input, [5, 4, 3, 2, 1, 0]);
var toSorted = require('array.prototype.tosorted');
var assert = require('assert');
/* when Array#toSorted is not present */
delete Array.prototype.toSorted;
var shimmed = toSorted.shim();

assert.equal(shimmed, toSorted.getPolyfill());
assert.deepEqual(input.toSorted(), toSorted(input));
var toSorted = require('array.prototype.tosorted');
var assert = require('assert');
/* when Array#toSorted is present */
var shimmed = toSorted.shim();

assert.equal(shimmed, Array.prototype.toSorted);
assert.deepEqual(input.toSorted(), toSorted(input));

Tests

Simply clone the repo, npm install, and run npm test

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.1.4 - 2024-06-02

Fixed

  • [Refactor] update implementation to match latest spec #3

Commits

  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, hasown, tape 159d118
  • [Deps] update call-bind, es-abstract, es-errors 7d32e67
  • [meta] add missing engines.node b49466b

v1.1.3 - 2024-02-04

Commits

  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic 6c089a5
  • [Deps] update call-bind, define-properties, es-abstract, es-shim-unscopables, get-intrinsic d096b56
  • [Dev Deps] update aud, npmignore, tape 43cea6d
  • [Dev Deps] use hasown instead of has cefe5dc
  • [Dev Deps] update tape ad8446e

v1.1.2 - 2023-09-07

Commits

  • [actions] use reusable workflows b3d4f1d
  • [Deps] update define-properties, es-abstract, get-intrinsic 35ce967
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape 1a17c6a

v1.1.1 - 2022-11-03

Commits

  • [Deps] update es-abstract, get-intrinsic b10a2a3
  • [actions] update rebase action to use reusable workflow 8f49d78
  • [Dev Deps] update aud, tape 2d2741b

v1.1.0 - 2022-08-14

Commits

v1.0.0 - 2022-03-31

Commits

  • initial implementation, tests, readme a2882bf
  • Initial commit f9d05c4
  • [meta] do not publish workflow files ceed80a
  • [Tests] temporarily use actions instead of composable workflows 496789b
  • npm init 9405760
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape 474180c
  • [meta] add version script 49a3b80
  • Only apps should have lockfiles 0db3a5a
  • [Deps] update es-abstract 35de1c5