Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

norjs/array

Repository files navigation

Build Status

Obsolete Notice: We're moving out of using @norjs/array (originally nor-array) since newest Node.js has a faster standard implementation than a raw while loop, now at 2019. (It wasn't very fast 2014.)

@norjs/array

Optimized Array Utility Library.

Installation

Install using NPM: npm install nor-array

Example Usage

var ARR = require('nor-array');

var a = [1, 2, 3, 4];

ARR(a).forEach(function(v) {
	console.log(v);
});

Our implementation is was about 50% faster than the standard Array.prototype.forEach().

Compatibility with standard Array methods

Our implementations are not fully compatible with ECMAScript implementations of Array operations.

Most notably because our implementation expects:

  • Array is a dense (NOT sparse -- there must be no holes!)
  • Assumes that indexes are between zero (0) and array.length: 0 <= i < array.length
  • Does not support thisArg, call o.callback.bind(o) instead
  • The array indexes do not change while our .forEach() is running

This assumption is the reason why it is faster.

Function Reference

Sample usage Description
 ARRAY(a).valueOf() Returns the original array
ARRAY(a).forEach(..) See Array.prototype.forEach()
ARRAY(a).map(..) See Array.prototype.map()
ARRAY(a).filter(..) See Array.prototype.filter()
ARRAY(a).find(..) See Array.prototype.find()
ARRAY(a).findIndex(..) See Array.prototype.findIndex()
ARRAY(a).every(..) See Array.prototype.every()
ARRAY(a).some(..) See Array.prototype.some()
ARRAY(a).concat(..) See Array.prototype.concat()
ARRAY(a).indexOf(..) See Array.prototype.indexOf()
ARRAY(a).lastIndexOf(..) See Array.prototype.lastIndexOf()
ARRAY(a).join(..) See Array.prototype.join()
ARRAY(a).reduce(..) See Array.prototype.reduce()

License

The MIT style license, see LICENSE.

Commercial Support

You can buy commercial support from Sendanor.

About

Array utils for JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published