You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

array-sugar

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-sugar

adds last, first, contains, isEmpty and empty to array utilizing Object.defineProperty

0.0.7
Source
npmnpm
Version published
Weekly downloads
117
15.84%
Maintainers
1
Weekly downloads
 
Created
Source

array-sugar

Tired of not having a last property on array in Javascript? Tired of not having contains method? This little script solves those by adding a bit of sugar: var array = [1, 2, 3]; array.contains(o) instead array.indexOf(o) != -1 array.clear() instead array.length = 0 array.isEmpty instead array.length == 0 array.first instead array[0] array.last instead array[array.length-1]

Usable in any environment that supports Object.defineProperty(oldest would probably be IE9).

Available through npm and bower, just require(or include in index.html) and you should be good to go.

npm install array-sugar
bower install array-sugar

Tests via nodeunit included.

Missing any sugar? Please do submit a pull or feature request.

Keywords

array

FAQs

Package last updated on 06 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts