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

helpda

v1.0.7

Published

simple typescript utility library

Downloads

9

Readme

helpda

simple typescript utility library

Build Status npm module

getting started

$ npm install helpda

or

$ yarn add helpda

Example Usage

import { sum, map, reduce, sumArr } from 'helpda'

map([1, 2, 3], (x) => x + 1) //[2,3,4]
reduce(sum, 0, [1, 2, 3]) // 6
sumArr([2, 4, 6]) // 12

what function should i use?

| Type | Action | Function | --- | --- | --- | | Array | change every value | map | | compute based on custom function and output the final value | reduce | | flatten return a one-dimensional array, remove nesting | flatten | Object | change every value | map | Functions | memoize | memoize | | revers function args | flip | Logic | | | Math | sum two numbers | sum | | subtract two numbers | subtract | | multiple two numbers | multiple | | divide two numbers | divide | | increment number | inc | | decrement number | dec | | negate number | negate | | get random number between two args | randomN | | sum all number in array | sumArr

API

  • Array

map

Map each element of array using a passed callback function.

import { map } from 'helpda'

const array = [1, 2, 3];
const mutiple = x => x * 2;

map(array, mutiple) //[2, 4, 6]

reduce

Reduce compute based on custom function and output the final value.

import { reduce } from 'helpda'

const array = [1, 2, 3];
const sum = (a, b) => a + b

reduce(sum, 0, array) // 6

flatten

flatten return a new one-level array from nested array

import { flatten } from 'helpda'

const array = [1, 2, 3, [4, 5, [6]]];

flatten(array)) // [1, 2, 3, 4, 5, 6]
  • Object

  • Functions

flip

return a new function with two reversed args

import { flip } from 'helpda'

const divide = (a, b) = a / b)
const flipped = flip((a, b) => a / b);

divide(12, 3) // 4
flipped(12, 3) // 0.25
  • Logic

  • Math

sum

sum two numbers

import { sum } from 'helpda'

sum(2, 2) // 4

subtract

subtract second arg from first

import { subtract } from 'helpda'

subtract(4, 2) // 2

multiple

multiple two numbers

import { multiple } from 'helpda'

multiple(2, 3) // 6

divide

divide two numbers

import { divide } from 'helpda'

divide(12, 3) // 4

inc

increment number

import { inc } from 'helpda'

inc(13) // 14

dec

decrement number

import { dec } from 'helpda'

dec(13) // 12

negate

negate number

import { dec } from 'helpda'

negate(13) // -13

sumArr

sum all number in an array of numbers

import { sumArr } from 'helpda'

const array = [1, 2, 3, 4, 5];

sumArr(array) // 15

randomN

get random number

import { randomN } from 'helpda'

const min = 0;
const max = 100;

randomN(min, max) // 12..85..3..?