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

js-useful-methods

v0.2.4

Published

Useful and helpful javascript methods library

Downloads

10

Readme

Js-Useful-Methods

Lodash, Underscore와 같은 유용한 자바스크립트 메서드 라이브러리 입니다! Implementation of Javascript Useful methods!

https://www.npmjs.com/package/js-useful-methods

Intro

기본적으로, 기본 타입(Primitive values) 관련 메서드들을 우선적으로 구현한 후, 차근차근 완성시켜보려 합니다. Basically, I will implement primitive types of methods first, and then complete the whole parts step by step.

얼추 구현이 마무리되면 실제 사용에 이해를 돕는 Documentation도 추가할 예정입니다. When the implementation is almost complete, I will also add documentation to help you understand the actual use.

Installation

Using npm:

$ npm i js-useful-methods

Using yarn:

$ yarn add js-useful-methods

In Node.js:

Ex. var _ = require('js-useful-methods').default;
_.difference([1, 2, 3], [1, 2]); // [3]

If you can use 'Import':

Ex. import _ from 'js-useful-methods';
_.flatten([1, 2, [3], [4, 5]]); // [1, 2, 3, 4, 5]

Implemented Methods

Array

  • chunk
    Parameters: (array: Array, size: Number)
    array: The array to process.
    size(optional): The length of each chunk

    Creates an array of elements split into groups the length of size.
    If array can't be split evenly, the final chunk will be the remaining elements.

  • compact
    Parameters: (array: Array)
    array: The array to compact.

    Creates an array with all falsey values removed.
    The values false, null, 0, "", undefined, and NaN are falsey.

  • concat
    Parameters: (items: Array)
    items: The values to concatenate.

    Creates a new array concatenating array with any additional arrays and/or values.
    First Parameter is the array to concatenate.

  • difference
    Parameters: (inspectArray: Array, excludeValues: ...Array)
    inspectArray: The array to inspect.
    excludeValues: The values to exclude.

    Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons.
    The order and references of result values are determined by the first array.

  • drop
    Parameters: (array: Array, dropNumber: Number)
    array: The array to query.
    dropNumber(optional): The number of elements to drop.

    Creates a slice of array with n elements dropped from the beginning.

  • dropRight
    Parameters: (array: Array, dropNumber: Number)
    array: The array to query.
    dropNumber(optional): The number of elements to drop.

    Creates a slice of array with n elements dropped from the end.

  • dropRightWhile
    Parameters: (array: Array, predicate: Function)
    array: The array to query.
    predicate(optional): The function invoked per iteration.

    Creates a slice of array excluding elements dropped from the end.
    Elements are dropped until predicate returns falsey.
    The predicate is invoked with three arguments: (value, index, array).

  • dropWhile
    Parameters: (array: Array, predicate: Function)
    array: The array to query.
    predicate(optional): The function invoked per iteration.

    Creates a slice of array excluding elements dropped from the beginning.
    Elements are dropped until predicate returns falsey.
    The predicate is invoked with three arguments: (value, index, array).

  • findIndex
    Parameters: (array: Array, predicate: Function, fromIndex: Number)
    array: The array to inspect.
    predicate(optional): The function invoked per iteration.
    fromIndex(optional): The index to search from.

    This method is like _.find except that it returns the index of the first element predicate
    returns truthy for instead of the element itself.

  • findLastIndex
    Parameters: (array: Array, predicate: Function, fromIndex: Number)
    array: The array to inspect.
    predicate(optional): The function invoked per iteration.
    fromIndex(optional): The index to search from.

    This method is like _.findIndex except that it iterates over elements of collection from right to left.

  • flatten
    Parameters: (array: Array)
    array: The array to flatten.

    Flattens array a single level deep.

  • flattenDeep
    Parameters: (array: Array)
    array: The array to flatten.

    Recursively flattens array.

  • flattenDepth
    Parameters: (array: Array, depth: Number)
    array: The array to flatten.
    depth(optional): The maximum recursion depth.

    Returns the new flattened array.

  • head
    Parameters: (array: Array)
    array: The array to query.

    Gets the first element of array.

  • indexOf
    Parameters: (array: Array, value: *, fromIndex: Number)
    array: The array to inspect.
    value: The value to search for.
    fromIndex(optional): The index to search from.

    Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons.
    If fromIndex is negative, it's used as the offset from the end of array.

  • initial
    Parameters: (array: Array)
    array: The array to query.

    Gets all but the last element of array.

  • intersection
    Parameters: (arrays: ...Array)
    array: The arrays to inspect.

    Creates an array of unique values that are included in all given arrays using SameValueZero for equality comparisons.
    The order and references of result values are determined by the first array.

  • join
    Parameters: (array: Array, seperator: String)
    array: The array to convert.
    seperator: The element separator.

    Converts all elements in array into a string separated by separator.

  • last
    Parameters: (array: Array)
    array: The array to query.

    Gets the last element of array.

  • lastIndexOf
    Parameters: (array: Array, value: *, fromIndex: Number)
    array: The array to inspect.
    value: The value to search for.
    fromIndex(optional): The index to search from.

    This method is like _.indexOf except that it iterates over elements of array from right to left.
    If fromIndex is negative, it's used as the offset from the end of array.

  • nth
    Parameters: (array: Array, n: Number)
    array: The array to query.
    n(optional): The index of the element to return.

    Gets the element at index n of array.
    If n is negative, the nth element from the end is returned.

  • pull
    Parameters: (array: Array, ...values: *)
    array: The array to modify.
    values: The values to remove.

    Removes all given values from array using SameValueZero for equality comparisons.
    Unlike _.without, this method mutates array.
    Use _.remove to remove elements from an array by predicate.

  • remove
    Parameters: (array: Array, predicate: Function)
    array: The array to modify.
    predicate: The function invoked per iteration.

    Removes all elements from array that predicate returns truthy for and returns an array of the removed elements.
    The predicate is invoked with three arguments: (value, index, array).

  • reverse
    Parameters: (array: Array)
    array: The array to modify.

    Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

  • slice
    Parameters: (array: Array, start: Number, end: Number)
    array: The array to modify.
    start(optional): The start position.
    end(optional): The end position.

    Creates a slice of array from start up to, but not including, end.
    Note: This method is used instead of Array#slice to ensure dense arrays are returned.

  • tail
    Parameters: (array: Array)
    array: The array to query.

    Gets all but the first element of array.

  • take
    Parameters: (array: Array, n: Number)
    array: The array to query.
    n(optional): The number of elements to take.

    Creates a slice of array with n elements taken from the beginning.

Etc

ETC

성능이나 구조, 더욱 깔끔한 코드에 관한 이슈는 언제나 환영입니다! Issues regarding performance, structure, and cleaner code are always welcome!