JavaScript helpers for use within the Ops client.


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @leiops/helpers in KB



npm npm

A collection of JavaScript helper functions.


import { startCase } from '@leiops/helpers'

export const filterName = name => startCase(startCase(name.split(" ")[0]))


This library provides an adapter function which allows you to augment and customize our helpers.

We keep a libraries directory for external code which we've altered slightly to fit our needs. This is the perfect place for our configuration file. The directory structure looks something like this:


You could also place this directly within a helpers directory and treat it like internal code.

adapter.js takes advantage of several of the features explained in the following sections, so we won't go into that now.

import { adapter } from '../../node_modules/@leiops/helpers'
import { sortUsers } from './sortUsers.js'

export default adapter({
  // add your own helpers to the library
  inject: {
  // access helpers already in the library using different names
  alias: {
    arrangeUsers: 'sortUsers',

Note that all injections and aliases will overwrite existing functions.

Finally, you can provide an alias in your webpack configuration:

  resolve: {
    alias: {
      'helpers': './libraries/helpers/adapter',

Helper Structure

helper(...args, options={})

Args is the arbitrary number of arguments a helper needs to to its work, and options is an object of configuration flags or other settings.

Helpers should be complete with their own jsdoc-style documentation, or at least a simple comment above describing what they expect and return.

 * Creates an array of given `length`, where each item is the specified `filler` or null.
 * @param {number} [number=0] The desired length of the array.
 * @param {any} [any=null] What to fill the array with.
 * @returns {array} Returns the constructed array.

export function constructArray(length=0, filler=null) {
  const result = []
  for (let i = 0; i < length; i++) result.push(filler)
  return result

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.