0.1.28 • Published 3 years ago

@aistarfish/utils v0.1.28

Weekly downloads
1
License
ISC
Repository
-
Last release
3 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

3 years ago

0.1.28

3 years ago

0.1.26

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.22

3 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago