0.5.0 • Published 3 years ago

rainbow-common v0.5.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

rainbow-common

NPM version Build Status codecov

English | 中文

Rainbow's JavaScript utility library

Usage

npm:

Recommended:

$ npm install rainbow-common -S
const R = require('rainbow-common');

// use core:
const { omit } = R;

// use feat:
new Date().formate('yyyy-MM-dd'); //  2020-07-07

// wxport module:
const { Storage } = R;

// use:
Storage.setItem('like', 'code', new Date(Date.now() + 1000));

setTimeout(() => {
  Storage.getItem('like'); // null
}, 1000);

CDN:

You can also get the latest version of resources through unpkg.com/rainbow-common, and use the script tag on the page to import it and start using it.

<script src="https://unpkg.com/rainbow-common"></script>

API

Core

  • getType
  • isDef
  • isUndef
  • extend
  • toFixed
  • checkType
  • hasOwn
  • shallowCopy
  • deepCopy
  • omit
  • only
  • sortBy
  • uniqueArrayObj
  • stringify
  • parse
  • throttle
  • debounce
  • once

Feat

New features of the prototype extension

  • Promise.every
  • Date.formate

Modules

Dom

  • \$
  • \$\$
  • index
  • siblings
  • every
  • getStyle
  • css
  • create
  • append
  • prepend
  • remove

Storage

LocalStorage new feature expiration time function

  • setItem
  • getItem
  • removeItem
  • clear

Event

Subscribe before publish

  • \$on
  • \$emit
  • \$off
  • \$once

Publish before subscribe

  • \$pub
  • \$sub
  • \$remove

License

MIT © yanyue404