0.1.28 • Published 4 years ago

@aistarfish/utils v0.1.28

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

frontend-utils

介绍

前端工具库

发布

npm run build

getUrlParams

返回 url 参数

const params = getUrlParams('?aaa=bbb'); // { aaa: 'bbb' }

fetch

对 fetch 进行了一些封装处理

// post
fetch('http://example.com', {
  method: 'post',
  data: { name: '张三', account: '12345' },
}).then((res) => {
if (res && res.code === 'SUCCESS') {
  ...
}
...
}).catch(err => console.log(err));

// get
fetch('http://example.com', {
  method: 'get',
  data: { name: '张三', account: '12345' },
}).then((res) => {
if (res && res.code === 'SUCCESS') {
  ...
}
...
}).catch(err => console.log(err));

pointer

链式调用,避免报错:Uncaught TypeError: Cannot read property 'xxx' of undefined

const a = { a: { b: { c : 1 } } };
pointer(a).b.c(); // 1
pointer(a).c.c(); // undefined

showEllipsis

超出一定字数显示...

const str = '一个矢量图标管理平台,可以用字体代替繁多的小图片。';
showEllipsis(str, 4) // 一个矢量...

log

使用 console.log 打印对象,如果是对象使用 JSON.parse(JSON.stringify(xx)) 深拷贝,

const a = { a: { b: { c : 1 } } };
log(a); // { a: { b: { c : 1 } } }

stringify parse

qs 中的 stringify parse

debounce throttle isObject

lodash 中的 debounce throttle isObject

0.1.27

4 years ago

0.1.28

4 years ago

0.1.26

4 years ago

0.1.23

4 years ago

0.1.24

4 years ago

0.1.25

4 years ago

0.1.22

4 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.10

6 years ago

0.1.11

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago