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

simplifying

v2.2.0

Published

A lightweight library containing multiple utility functions to make your life easier when dealing with arrays and objects

Downloads

29

Readme

Simplifying JS

Image of simplifying

Build Status License: MIT npm version npm GitHub repo size npm bundle size Active GitHub tag Generic badge

A lightweight library containing multiple utility functions to make your life easier when dealing with arrays and objects.

HOW TO USE

Open the terminal and navigate to the root directory of your project. Install Simplifying:

npm i simplifying

If you do not have npm installed, you can download it here.

EXAMPLE CODE:
const array = require('simplifying');
let arr = [2, 3, 4, 3, 3, 2, 4];
console.log(array.removeDuplicates(arr));

//OUTPUT: [2, 3, 4]

Image of example code

List of all methods on array:

Method | Parameters | Use ------------ | ------------- | -------------- shuffle | array: Array | Shuffles array and returns it removeDuplicates | array: Array | Removes all duplicate elements and returns a new array pickRandom | array: Array, n: Number, unique?: Boolean | Returns an array of n random elements from array.The returned elements will be unique if true is passed in the third parameter countItem | array: Array, item: any | Returns the frequency of the passed item in the array countAll | array: Array | Returns a map which holds the frequencies of all items in the array searchItems | array: Array, item: any | Returns all positions where the given item is found removeItems | array: Array, item: any | Deletes multiple occurances of the given item toArray | x: (string, number) | Converts string or number to array of characters or digits merge | array1: Array, array2: Array, type?: string | Merge two arrays.type == 'merge-all': Keep the duplicatestype == 'common': Returns common elementsno type: Merge and remove common clean | array: Array | Removes null, undefined, '', NaN flatten | array: Array | Flattens all nested arrays inside swapByPosition | array: Array,pos1: number,pos2: number | Swaps values in pos1 and pos2 in the array swapByValues | array: Array, value1: any, value2: any | Swaps value1 and value2 in the array perform | array: Array, operation: string | Performs the said operation on the array.Allowed Operations:sum, product, min, max, average arrayToObject | array: Array | Converts an array to object slide | array: Array, steps: number, direction?: string | Shifts array by n steps in the given direction. The default direction is left range | array: Array, start: number, end: number | Returns a subarray from start to end - 1 jump | array: Array, steps: number | Returns a subarray jumping the steps mentioned isUnique | array: Array | Return true if all elements are unique in the array and false otherwise

List of all methods on array of objects:

Method | Parameters | Use ------------ | ------------- | -------------- arrayOfObjectsToObject | array: Array, keyField: string | Converts an array of objects to an object where key is keyField sortByKeyField | array: Array, keyField: string, order?: string | Sorts an array of objects based on keyField. Default sorting order is ascending. Pass 'desc' to order for reverse. getFields | array: Array, fields: Array | Returns an array of objects containing only the required fields getOneField | array: Array, field: string | Returns an array of all the values of the particular field searchByKeyField | array: Array, searchField: string, searchValue: string, reqFields?: Array | Searches the array for the given (key, value) pair and returns only the reqFields. If nothing is passed, the whole object is returned. deleteByKeyField | array: Array, field: string, value: string | Deletes an item based on the (key, value) pair getKeys | array: Array | Returns an array of all the keys inside the object. Assumes that all objects have the same keys findObjects | array: Array, func: Function | Executes the function on all objects and returns the satisfied objects

LICENSE

MIT

Author

Subham Das

Open an issue if you feel the need for a change or want to report any bugs.