@axmine/helper

3.0.3 • Public • Published

@axmine/helper

个人项目辅助方法集

NPM Version GitHub license size-image

安装

npm i @axmine/helper -S

ES6

// ts
import { cookie } from '@axmine/helper/lib/cookie';

// js
import helper from '@axmine/helper';

CommonJS

var helper = require('@axmine/helper');

直接引入

<script src="helper.js"></script>

方法名 或 对象

名称 用途 说明 返回值
cookie.set(
    key: string,
    value: any,
    expireDays: number
)
存储cookie expireDays单位为天数 boolean
cookie.get(key: string) 取出cookie -- boolean
cookie.remove(key: string) 删除cookie -- boolean
new Storage(
type:     'localStorage'|'sessionStorage' = 'localStorage'
)
同cookie的方法 -- 同上
random(
    min: number = 0,
    max: number = 1,
    result: 'float'|'int' = 'float'
)
取随机数 result为 int 时
只返回随机的整数
number
getType(data:any) 获取参数的类型 -- string
date.format(
    data: number|string,
    format: string = 'y-m-d h:i'
)
通过时间戳返回日期

通过日期返回时间戳
data为数字时,必须为秒数,不支持毫秒
data为字符串时,必须为规范的日期字串
string | number

更新日志

2021.04.07:

  1. 主要语言已转至typescript,用ts把要用的主要方法都重写了

开发说明

// 打包
npm run build

// 测试
npm run test

License

MIT

/@axmine/helper/

    Package Sidebar

    Install

    npm i @axmine/helper

    Weekly Downloads

    4

    Version

    3.0.3

    License

    MIT

    Unpacked Size

    31.8 kB

    Total Files

    15

    Last publish

    Collaborators

    • yocss