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

data-stapler

v1.5.0

Published

Easily manipulate arrays, objects, and strings!

Downloads

8

Readme

data-stapler allows you to do fun things with your Node.JS arrays, objects, and strings!

Install

npm i data-stapler

Basic Example

Example: Merging 2 objects together. For this we are going to be using the stapler.merge() async function.

let Stapler = require('data-stapler');
let stapler = new Stapler();

let myObj1 = {
    "NODE": "IS FUN"
}

let myObj2 = {
    "NOT": "LYING"
}


stapler.mergeObject(myObj1, myObj2)
.then((combined) => console.log(combined)); // Will log: { NODE: "IS FUN", "NOT": "LYING" }

Merging 2 arrays.

let Stapler = require('data-stapler');
let stapler = new Stapler();
let a1 = ["Hello", "world", "What a beautiful"];
let a2 = ["day", "today!"];

stapler.mergeArray(a1, a2)
.then((combined) => console.log(combined)); // Will log: [ 'Hello', 'world', 'What a beautiful', 'day', 'today!' ]

Staple Functionality

Use this to staple as many objects and arrays as you want!

let Stapler = require('data-stapler');
let stapler = new Stapler();

let myObj1 = {
    "NODE": "IS FUN"
}

let myObj2 = {
    "NOT": "LYING"
}

let myObj3 = {
    "THIS": "IS COOL!"
}


let a1 = ["Hello", "world", "What a beautiful"];
let a2 = ["day", "today!"];
let a3 = ["I love", "pickles!"]

stapler.stapleObject([myObj1, myObj2, myObj3])
.then((combinedo) => console.log(combinedo));

stapler.stapleArray([a1, a2, a3])
.then((combinedarr) => console.log(combinedarr));

Configuration

You can configure your stapler instance to allow a minimum and maximum amount of arrays/objects to allow to be stapled at once.

let Stapler = require('data-stapler');
const staplerconfig = {
    min: 3, //Minimum of 3 staples
    max: 8 // Maximum of 8 staples
}
let stapler = new Stapler(staplerconfig);

Preferring async over object [Promise]

If you prefer against promises, you can always use async functions. Example:

let Stapler = require('data-stapler');
const staplerconfig = {
    min: 1, //Minimum of 1 staples
    max: 60 // Maximum of 60 staples
}
let stapler = new Stapler(staplerconfig);

async function staple(stuff) {
    let resp = await stapler.stapleArray(stuff);
    return resp;
}

let something = await staple([["Yes"], ["Sir"]])
console.log(something) // WIll log: ["Yes", "Sir"]

String Operation

You can convert arrays to strings and strings to arrays!

let Stapler = require('data-stapler');
let stapler = new Stapler({ min: 1, max: 500 });


let a4 = ["N", "o", "d", "e"];


let hi = "Node is the best lang ever!"


stapler.arrayToString(a4)
.then((newstr) => console.log(newstr)); // Will log: "Node"


stapler.stringToArray(hi)
.then((newarr) => console.log(newarr)); /* Will log:
[
  'N', 'o', 'd', 'e', ' ', 'i',
  's', ' ', 't', 'h', 'e', ' ',
  'b', 'e', 's', 't', ' ', 'l',
  'a', 'n', 'g', ' ', 'e', 'v',
  'e', 'r', '!'
]

*/

Author

Tyler K.

More features coming soon!