utilz.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

utilz.js

version PRs Welcome license size

Some utilities for JavaScript.

Usage

npm install utilz.js

Features

Enum

Enum class is an enumeration class that can be used to define a set of constants. In order to use enumeration in native JS.

import { Enum } from 'utilz.js';

// new a Enum instance
const StatusEnum = new Enum([
  { key: 'PENDING', value: 1 },
  { key: 'FULFILL', value: 2 },
  { key: 'REJECT', value: 3 },
]);

// get value by key
StatusEnum['PENDING']; // 1
StatusEnum['FULFILL']; // 2
StatusEnum['REJECT']; // 3

// get EnumElement by value
StatusEnum.get(1); // { key: 'PENDING', value: 1 }
StatusEnum.get(2); // { key: 'FULFILL', value: 2 }
StatusEnum.get(3); // { key: 'REJECT', value: 3 }

// get all keys
StatusEnum.getArray();
/*
 ** return:
[
  { key: 'PENDING', value: 1 },
  { key: 'FULFILL', value: 2 },
  { key: 'REJECT', value: 3 },
]
*/

// get all values
StatusEnum.getObject();
/*
 ** return:
{
  1: { key: 'PENDING', value: 1 },
  2: { key: 'FULFILL', value: 2 },
  3: { key: 'REJECT', value: 3 },
}
*/

fetch

  • TODO

License

utilz.js is released under the MIT License. See the bundled LICENSE file for details.

Package Sidebar

Install

npm i utilz.js

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

6.31 kB

Total Files

7

Last publish

Collaborators

  • liruifengv