common-utils-pkg
TypeScript icon, indicating that this package has built-in type declarations

4.1.1 • Public • Published

Common Utilities Package

A package of commonly used JavaScript utilities.

Site | Docs

Package Details

npm version node version build coverage downloads

Repo Details

open issues open prs code size contributors

🎉 v4 is here

v4 is just migrating the code base to TypeScript. Kindly refer to the changelog for more info.

v3 is here

Version 3 introduces a code-breaking change. Each method is exported independently instead of having them under a "category utility". Read more on how to use it here.

Installation

NPM

npm i --save common-utils-pkg

Yarn

yarn add common-utils-pkg

Usage

ES6

// Specific methods

import { randomPastelColor } from 'common-utils-pkg';
randomPastelColor();
// All methods

import * as UTILS from 'common-utils-pkg';
UTILS.randomPastelColor();

Browser

<script src="https://unpkg.com/common-utils-pkg"></script>
<script>
  // Specific methods

  const randomPastelColor = window['common-utils-pkg].randomPastelColor;
  randomPastelColor();
</script>
<script>
  // All methods

  const UTILS = window['common-utils-pkg'];
  UTILS.randomPastelColor();
</script>

Read more about the usage here

Available Methods

Read more about the methods available here

Features

Contributing

1.Create a folder under src/ and name the folder with the same name as the method.

2.Create methodName.js and methodName.spec.js

The full directory should look like this:

src/
  methodName/
    - methodName.js
    - methodName.spec.js

3.If the method you are authoring has expected parameters then import expects

import expects from '../expects/expects';

Wrap your exported function with expects

export default expects(
  methodName,
  'methodName',
  { // required parameters
    0: 'string', // 1st parameter is required and is a string
    1: 'number', // 2nd parameter is required and is a number
  },
  { // optional parameters
    2: 'number' // 3rd parameter is optional but is a number
  }
)

Package Sidebar

Install

npm i common-utils-pkg

Weekly Downloads

2

Version

4.1.1

License

ISC

Unpacked Size

46.9 kB

Total Files

73

Last publish

Collaborators

  • iamdevlinph