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

helfer

v0.1.0

Published

useful helper functions

Downloads

13

Readme

helfer

NPM Package Build Status Dependencies

useful helper functions

helfer is german for helper

a place for helper functions that are generic enough to be used in more than one of my npm packages but specific enough not to be present in utility libraries like lodash. it aims to have no dependencies, which means that it must reimplement some lodash functions (findIndex for example) that some helfer functions depend on.

at the moment it contains mostly string and array helpers.

see a list of all functions below.

this is a work in progress. it is well tested but the API should not be considered stable. for the moment i'll make breaking changes between versions without warning. i might extract sets of functions into separate packages in the future.

npm install helfer
bower install helfer
var helfer = require('helfer');

lib/helfer.js supports AMD.
if AMD is not available it sets the global variable helfer.

also look at the tests (and code) for documentation.

string

  • camelToSnake('camelCase') -> 'camel_case'
  • snakeToCamel('snake_case') -> 'snakeCase'
  • camelToHyphen('camelCase') -> 'camel-case'
  • hyphenToCamel('hyphen-delimited') -> 'hyphenDelimited'
  • colonToSnake('colon:delimited') -> 'colon_delimited'
  • snakeToColon('snake_case') -> 'snake:case'
  • hyphenColonToCamelSnake('hyphen:colon-to:camel-snake') -> 'hyphen_colonTo_camelSnake'
  • camelSnakeToHyphenColon('camel_snakeTo_hyphenColon') -> 'camel:snake-to:hyphen-colon'
  • uppercaseFirstLetter('foo') -> 'Foo'
  • lowercaseFirstLetter('FOO') -> 'fOO'
  • splitCamelcase('oneTwoThree') -> ['one', 'two', 'three']
  • joinCamelcase(['One', 'two', 'three']) -> 'oneTwoThree'
  • splitUnderscore('one_two_three') -> ['one', 'two', 'three']
  • joinUnderscore(['one', 'two', 'three']) -> 'one_two_three'
  • splitUppercaseUnderscore('ONE_TWO_THREE') -> ['one', 'two', 'three']
  • joinUppercaseUnderscore(['one', 'two', 'three']) -> 'ONE_TWO_THREE'

array

  • coerceToArray(array | value | null | undefined) -> always returns an array. returns arg if it is an array. returns [arg] otherwise. returns [] if arg is null or undefined.
  • findIndex(array, predicate) -> returns the index of the first array element for which predicate returns true. otherwise returns -1.
  • findIndexWhereProperty(objects, property) returns the index of the first of objects for which property is not undefined. otherwise returns -1.
  • findIndexOfSequence(array, sequence) -> returns the index of the first occurence of sequence in array. otherwise returns -1
  • splitArrayWhere(array, predicate) -> split array into two parts: the first part contains all elements up to (but not including) the first element for which predicate returned true. the second part contains all elements from (and including) the first element for which preducate returned true.
  • splitArrayWhereSequence(array, sequence) -> split array on each occurence of sequence in array

object

  • inherits(constructor, superConstructor) makes an object that has superConstructor as its prototype the prototype of constructor (portable). useful to create error hierarchies that can work with bluebird.catch and helfer.isError.

function

  • parseFunctionArguments(function(a, b, c) {}) -> ['a', 'b', 'c'] the names of the functions arguments
  • identity(value) -> returns value

predicate

  • isObject(value) -> returns boolean whether value is an object
  • isUndefined(value) -> returns boolean whether value is undefined
  • isNull(value) -> returns boolean whether value is null
  • isExisting(value) -> returns boolean whether value is neither null nor undefined
  • isThenable(value) -> returns boolean whether value is a thenable (promise)
  • isError(value) -> returns boolean whether value is instanceof Error

license: MIT