Giter Site home page Giter Site logo

very-array's Introduction

Such array library

Very Array Build Status

Install

npm install very-array --save

bower install very-array

Usage:

var va = require('very-array'); // only for server side

va([1,2,3]).where(function (i) { return i > 1; }); // [2, 3]

Functions:

  • skip:

    va([1, 2, 3])
        .skip(1); // [2, 3]
  • take:

    va([1, 2, 3])
        .take(2); // [1, 2]
  • sum:

    va([{ a: 1 }, { a: 2 }, { a: 3 }])
        .sum(function (i) { return i.a; }); // 6
  • select:

    va([{ a: 1 }, { a: 2 }, { a: 3 }])
        .select(function (i) { return i.a; }) // [1, 2, 3]
  • selectMany:

    va([{ a: [1, 2] }, { a: [3] }, { a: [4, 5, 6] }])
        .selectMany(function (i) { return i.a; }) // [1, 2, 3, 4, 5, 6]
  • contains:

    va([1, 2, 3])
        .contains(1); // true
  • all:

    va([1, 2, 3])
        .all(function (i) { return i > 0; }); // true
  • any:

    va([1, 2, 3])
        .any(function (i) { return i > 2; }); // true
  • where:

    va([1, 2, 3])
        .where(function (i) { return i > 2; }); // [3]
  • first:

    va([1, 2, 3])
        .first(function (i) { return i > 1; }); // [2]
  • last:

    va([1, 2, 3])
        .last(); // 3
  • distinct:

    va([1, 1, 2, 3, 3])
        .distinct(); // [1, 2, 3]
  • groupBy:

    va([{ a: 1 }, { a: 1 }, { a: 2 }, { a: 3 }])
        .groupBy(function (i) { return i.a; }); //Array[2], Array[1], Array[1]
  • orderBy:

    va([{ a: 2 }, { a: 1 }, { a: 3 }])
        .orderBy(function (i) { return i.a; }); // [{ a: 1 }, { a: 2 }, { a: 3 }]
  • orderByDescending:

    va([{ a: 1 }, { a: 2 }, { a: 3 }])
        .orderByDescending(function (i) { return i.a; }); // [{ a: 3 }, { a: 2 }, { a: 1 }]
  • forEach:

    va([1, 2, 3])
        .forEach(function (item, index) { console.log(item) }); // 1, 2, 3

Extension:

va.extends(Array);

[1, 2, 3].sum() // 6

very-array's People

Contributors

nescalante avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.