Socket
Socket
Sign inDemoInstall

array-sugar

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
26
decreased by-10.34%
Maintainers
1
Install size
37.4 kB
Created
Weekly downloads
 

Readme

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:

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.

npm install array-sugar
bower install array-sugar

Tests via nodeunit included.

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

Keywords

FAQs

Last updated on 05 Oct 2013

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc