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

funckit

v2.0.0

Published

FuncKit is a granular ES6 library for individual functional methods. This allows you to include the methods nessesary for your project with out including a wide unnecessary rage of library attachments.

Downloads

33

Readme

README

FuncKit is a granular ES6 library for individual functional methods. This allows you to include the methods nessesary for your project with out including a wide unnecessary rage of library attachments.

NPM Installation

$ npm install funckit -save

Method Importing

import assignDeep from 'funckit\object\assignDeep';
import chunk from 'funckit\array\chunk';

Array:Chunk

Splits array into chunks using the specified size.

Usage:

chunk([1,2,3,4,5,6,7,8,9, 10], 3)

Output:

=> [[1,2,3],[4,5,6],[7,8,9],[10]]

Array:Compact

Removes and null, false and undefined values from the passed array

Usage:

compact(1,false, undefined,null,2)

Output:

=> [1,2]

Array:Compress

Takes in multiple array types and merges into a new array accordingly

Usage:

compress([1,2,3,4],[5,6,7],[8,9,10])

Output:

=> [[1,2,3,4],[5,6,7],[8,9,10]]

Array:Diff

Retuns the difference between two arrays

Usage:

diff([1,2,3,4],[1,2,3,4,5,6,7])

Output:

=> [5,6,7]

Array:First

Returns the first value of passed array

Usage:

first([1,2,3,4])

Output:

=> 1

Array:Flatten

Flattens nested arrays

Usage:

flatten([1,[2],[[3]]])

Output:

=> [1,2,3]

Array:Intersection

Takes in multiple array types and returns all values contained in every array

Usage:

intersection([1,2,3,4],[2,3,4],[1,2,2,3,3])

Output:

=> [2,3]

Array:Last

Retuns the last value of the passed in array

Usage:

last([1,2,3,4,5])

Output"

=> 5

Array:Merge

Merges all values from all passed in array arugments in to the onw array

Usage:

merge([1,2,3,4],[5,6,7,8],[9,10])

Output:

=> [1,2,3,4,5,6,7,8,9,10]

Array:Occurrences

Returns the amount of occurrences of a value in the passed array

Usage"

occurrences([1,2,1,2,1,2,1],2)

Output:

=> 3

Array:Pick

Returns the array value by index if it exists in the given array

Usage"

pick(['John', 'Is', 'King'], 2)

Output:

=> 'King'

Array:Range

Returns the values of an array between the start and end arguments

Usage:

range([1,2,3,4,5,6,7,8,9], 4, 9)

Output:

=> [5,6,7,8,9]

Array:Shuffle

Returns all the values from the passed array in a randomised order

Usage:

shuffle([1,2,3,4,5,6])

Output:

=> [2,5,4,1,3,6]

Array:Unique

Removes all dublicate entries from the passed array

Usage:

unique([1,1,1,2,2,3])

Output:

=> [1,2,3]

Array:Without

Removes all specified values from the passed array

Usage:

without(['John', 'Cambo', 'Dan', 'Tom']], 'Tom', 'Dan');

Output:

=> ['John', 'Cambo']

Collection:HasMany

Joins entries from one collection to multiple others using a primary and foreign key to identify the relationship

Usage:

const people = [
  {
    id: 2,
    name: 'steff',
    age: 27,
  }
]

const addresses = [
  {
    id: 1,
    person_id: 2,
    postcode: 'l12pa'
  }
];

const info = [
  {
    id: 1,
    person_id: 2,
    bio: 'Steff loves his ginger locks.'
  }
];

hasMany(people, 'id', 'person_id', addresses, info)

Output:

=> [{
 id: 2,
 name: 'steff',
 age: 27,
 address: {
   id: 1,
   person_id: 2,
   postcode: 'l12pa'
 },
 info: {
   id: 1,
   person_id: 2,
   bio: 'Steff loves his ginger locks.'
 }
}]

Collection:HasOne

Joins entries from one collection to another using a primary and foreign key to identify the relationship

Usage:

const people = [
  {
    id: 2,
    name: 'steff',
    age: 27,
  }
 ]

const addresses = [
  {
    id: 1,
    person_id: 2,
    postcode: 'l12pa'
  }
];

hasOne(people, addresses, 'id', 'person_id', 'address')

Output:

=> [{
  id: 2,
  name: 'steff',
  age: 27,
  address: {
    id: 1,
    person_id: 2,
    postcode: 'l12pa'
  }
}]

Collection:Pluck

Plucks and returns all instances of the specified property in a collection of objects.

Usage:

let people = [
  {
    name: 'John Hopley',
    height: '6ft 6"',
    age 32,
   }
   {
     name: 'Cambo',
     height: '5ft 1"',
     age 54
   }
];

pluck(people, 'name');

Output:

=> ['John Hopley', 'Cambo']

Collection:Where

Takes in a collection returns only the items that watch the conditions (object:param2)

Usage:

let people = [
  {
    name: 'John Hopley',
    jobcode: 12,
    office: 'Liverpool'
  },
  {
    name: 'Lee Easeman',
    jobcode: 12,
    office: 'London'
  },
  {
    name: 'Eric Jones',
    jobcode: 14,
    office: 'Liverpool'
  }
];

where(people, {jobcode: 14, office: 'Liverpool'})

Output:

=> [{
  name: 'Eric Jones',
  jobcode: 14,
  office: 'Liverpool'
}]

Number:Between

Returns a random number between the min and max given in arguments

Usage:

between(5,10)

Output:

=> 6

Number: Is Number

Returns true is the passed argument is type of number

Usage:

isNumber(5)
isNumber('5')

Output:

=> true
=> false

Object: Deep Assign

Extends recursively over multidimensional objects using Object.assign.

Usage:

deepAssign({
  name: 'John',
  age: 25,
  info: {
    email: null,
  }
}, {
  info: {
    email: '[email protected]',
    address: {
      postcode: 'xxxx'
    }
  }
})

Output:

=> {
 name: 'John',
 age: 25,
 info: {
 email: '[email protected]',
 address: {
   postcode: 'xxxx'
 }
}

Object: Clone

Returns clone of immutable object

Usage:

clone({name: 'John Hopley'})

Output:

=> {name: 'John Hopley'}

Object: Is Object

Checks if the passed in argument is type of Object

Usage:

isObject({});

Output:

=> true

Object: Object Flatten

Recursively flatten multidimensional objects

Usage:

objectFlatten({
  name: 'John Hopley',
  address: {
    postcode: 'xxxx',
    city: 'Liverpool'
  }
});

Output:

=> {
  '/name': 'John Hopley',
  '/address/postcode': 'xxxx',
  '/address/city': 'Liverpool',
}

Object: types

Returns an object describing the property types of passed object

Usage:

types({
  doSomething: () => {},
  doNothing: false,
  count: 5,
  trigger: 'click',
  meta: {}
})

Output:

=> {
  doSomething: 'function'
  doNothing: 'boolean',
  count: 'number',
  trigger: 'string',
  meta: 'object'
}