0.0.3 • Published 5 years ago

ether-fe-common v0.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

fe-common

common kits for fe

安装

npm i ether-fe-common --save-dev

使用

import * as commmon from 'ether-fe-common';

Url

let url = new commmon.helper.Url('https://www.google.com/index?id=abc#hash');

properties:

propertytype
protocolstring
hoststring
pathstring
fullPathstring
paramsobject
hashstring

methods:

  • url.addParams(obj);
  • url.removeParams(key|arr);
  • url.replaceParams(obj);
  • url.toString();
  • url.getFullPath();
// 示例
url.addParams({
    p: 'msg'
});
url.removeParams('id');
url.replaceParams({
    p: 'new-msg'
});
url.toString();

Ls

let ls = new commmon.helper.Ls([config]);

config properties:

propertytypedefault
prefixstring#|
gcRatenumber.1

methods:

  • ls.set(key, value, expire);
  • ls.get(key).then(cb);
  • ls.remove(key|arr).then(cb);
  • ls.getOrSet(key, value).then(cb);
// 示例
ls.set('test', { msg: 'some msg' });
ls.get('test').then(data => { console.log(data) });
ls.remove('test').then(() => {});
ls.remove(['test']).then(() => {});
ls.getOrSet('test', { msg: 'other msg' }).then(data => { console.log(data) });

Ua

commmon.helper.Ua.isDealEase();  // boolean
commmon.helper.Ua.isWx();        // boolean
commmon.helper.Ua.isIOS();       // boolean
commmon.helper.Ua.isAndroid();   // boolean
commmon.helper.Ua.isIOS();       // boolean
commmon.helper.Ua.getEnv();      // string

Time

commmon.helper.Time.format(date, format);

format:

formatvalue
yyyyyear
yyyear
MMmonth
Mmonth
dddate
ddate
DDweek
Dweek
DCweek cn
hhhour
hhour
mmmunite
mmunite
sssecond
ssecond
// 示例
let date = new Date();
commmon.helper.Time.format(date, 'yyyy-MM-dd 星期DC');

Factory

methods:

  • commmon.helper.Factory.getSingle(fn);
// 示例
let fn1 = commmon.helper.Factory.getSingle(function() {
    let date = new Date();
    return date;
});
0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.1-0

5 years ago