npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rocket-array

v2.1.0

Published

Rocket Array is designed to be simplest way possible to manipulate your array

Downloads

6

Readme

Rocket Array 2.1 🎉🚀

Rocket Array 2.1 is 33.6% lighter and until 20 times more faster than Rocket Array 1.5 and is designed to be simplest way possible to manipulate your array

Installation 🌍

$ npm install rocket-array

How it works ?

Initialize

require("rocket-array"); //for node.js integration

//example for this doc
const myArray = [
  "this",
  "is",
  "hello",
  "world",
  {
    name: "alice",
    infos: {
      level: 18
    }
  },
  {
    name: "bob",
    infos: {
      level: 50
    }
  },
  {
    name: "other",
    infos: {
      level: 2
    }
  },
  5,
  10,
  2,
  "this",
  "is",
  "my",
  "world"
];

Get recurrent data from array

const number = 2;
const recurrentData = myArray.recurrent(number);
//return [[{number: 2, name: "this"}, {number: 2, name: "is"}]]

| Parameter | Type | Required | Default | | --------- | ------ | -------- | ------- | | Number | Number | No | 1 |


Get data with specific type

const type = "number";
const onlyTypeString = myArray.only(type);
//return [5, 10, 2];

| Parameter | Type | Required | Default | | --------- | ------ | -------- | -------- | | Type | String | Yes | "string" |


Remove recurrents data from the array

myArray.removeRecurrents();

Add data to the beginning of your array

const data = "me";
myArray.pushBefore(data);

| Parameter | Type | Required | Default | | --------- | ---- | -------- | ---------------- | | Type | All | Yes | No Default Value |


Delete data with its position in the array

const position = 1,
  numberElement = 2;
//numberElement defines how much data should be deleted after the position
myArray.remove(position, numberElement);

| Parameter | Type | Required | Default | | ------------- | ------ | -------- | ---------------- | | Position | Number | Yes | No Default Value | | numberElement | Number | No | 1 |


Find data from the array with regex

myArray.find({
  regex: /is/,
  morethan: 5,
  lessthan: 5,
  equal: 10,
  type: "string"
});

myArray.findJSON({
  regex: /as/,
  type: "string",
  morethan: 5,
  lessthan: 5,
  equal: 10,
  where: "infos.level"
});

| Parameter | Type | Required | Default | | ---------------------------- | ------ | -------- | ---------------- | | equal | All | No | undefined | | regex | Regex | No | false | | type | String | No | false | | morethan | Number | No | false | | lessthan | Number | No | false | | where (just for .findJSON()) | String | Yes | No Default Value |


Find and remove data

//the "remove" functions do not change your Array
myArray = myArray.findAndRemove({
  regex: /is/,
  lessthan: 10,
  morethan: 9,
  equal: 10,
  type: "string"
});

//the "remove" functions do not change your Array
myArray = myArray.findAndRemoveInJSON({
  where: "name",
  regex: /is/,
  lessthan: 10,
  morethan: 9,
  type: "string"
});

| Parameter | Type | Required | Default | | ---------------------------- | ------ | -------- | ---------------- | | equal | All | No | undefined | | regex | Regex | No | false | | type | String | No | false | | morethan | Number | No | false | | lessthan | Number | No | false | | where (just for .findJSON()) | String | Yes | No Default Value |


Export and import Rarray

const local = myArray.toString(); // toString() = JSON.stringify

Search array data with multiple parameters

const params = [
  {
    where: "name",
    regex: /as/
  },
  {
    where: "infos.level",
    morethan: 5
  }
];

myArray.mufindJSON(params);

| Parameter | Type | Required | Default | | --------- | ----- | -------- | ---------------- | | Params | Array | Yes | No Default Value |


Search array data with multiple parameters and delete them

const params = [
  {
    where: "name",
    regex: /as/
  },
  {
    where: "infos.level",
    morethan: 5
  }
];

myArray.mufindAndRemoveInJSON(params);

| Parameter | Type | Required | Default | | --------- | ----- | -------- | ---------------- | | Params | Array | Yes | No Default Value |