Skip to content

Latest commit

 

History

History
122 lines (76 loc) · 3.39 KB

README.md

File metadata and controls

122 lines (76 loc) · 3.39 KB

License: MIT npm version last version release date Jest:coverage minified size

Synopsis

Sparray.js is an Open source arrays toolkit library for Javascript.

  • Only 1 small dependency to check inputs variables
  • Very lightweight
  • Thoroughly tested
  • Works in Javascript, Typescript and Node.js
  • Can be used as CommonJS or EcmaScrypt module
  • Written in Typescript

Support

  • node: 14

This is the oldest targeted versions. The library should work properly on older versions of Node.js but we do not support it officially.

Installation

$ npm i @dwtechs/sparray

Usage

ES6 / TypeScript

import { chunk } from "@dwtechs/sparray";

function chunkArray(req, res, next) {
  req.chunks = chunk(req.body.rows, null);
  next();
}

export {
  chunkArray,
};

CommonJS

const sp = require("@dwtechs/sparray");

function chunk(req, res, next) {
  req.chunks = sp.chunk(req.body.rows, null);
  next();
}

module.exports = {
  chunk,
};

API Reference

let chunkSize = 100 //Default value

getChunkSize(): number {}

setChunkSize(size: number): number {}

chunk(rows: any[], size?: number = chunkSize): any[] {}

checkCommonValues(a: any[], b: any[]): boolean {}

getCommonValues(a: any[], b: any[]): any[] {}

// Flatten a chunked array
flatten(chunks: any[]): any[] {}

// delete a list of properties
deleteProps(arr: Record<string, any>[], props: string[]): Record<string, any>[] {}

Contributors

Sparray.js is still in development and we would be glad to get all the help you can provide. To contribute please read contributor.md for detailed installation guide.

Stack

Purpose Choice Motivation
repository Github hosting for software development version control using Git
package manager npm default node.js package manager
language TypeScript static type checking along with the latest ECMAScript features
module bundler Rollup advanced module bundler for ES6 modules
unit testing Jest delightful testing with a focus on simplicity