All Projects → heyui → hey-utils

heyui / hey-utils

Licence: MIT license
js-utils

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to hey-utils

agon
🦉 my golang utilities, log json config and other
Stars: ✭ 12 (-47.83%)
Mutual labels:  utils
timestampy
🕒 Bunch of utilities useful when working with UNIX timestamps
Stars: ✭ 21 (-8.7%)
Mutual labels:  utils
geojson-python-utils
Python helper functions for manipulating GeoJSON
Stars: ✭ 86 (+273.91%)
Mutual labels:  utils
dd
This package will add the dd and dump helpers to your Phalcon application.
Stars: ✭ 17 (-26.09%)
Mutual labels:  utils
autils
Awesome frontend utils library
Stars: ✭ 17 (-26.09%)
Mutual labels:  utils
android-library
Android开发基础库
Stars: ✭ 14 (-39.13%)
Mutual labels:  utils
util
封装了一些Java常用的功能
Stars: ✭ 19 (-17.39%)
Mutual labels:  utils
type-predicates
A comprehensive collection of type-guards, type assertions and related utils
Stars: ✭ 44 (+91.3%)
Mutual labels:  utils
utils.js
Fast, small and purely functional utility library
Stars: ✭ 132 (+473.91%)
Mutual labels:  utils
borax
📓 Python3工具集合库——中国农历/中文数字/设计模式/树形结构
Stars: ✭ 57 (+147.83%)
Mutual labels:  utils
Y-BP
YFE Team 前端最佳实践
Stars: ✭ 28 (+21.74%)
Mutual labels:  utils
csa-misc-utils
Miscellaneous samples, documents, how-tos, utilities, scripts, and other CSA tidbits
Stars: ✭ 79 (+243.48%)
Mutual labels:  utils
cmn-utils
公共函数&请求封装
Stars: ✭ 43 (+86.96%)
Mutual labels:  utils
permissionUtil
Simple permission helper
Stars: ✭ 64 (+178.26%)
Mutual labels:  utils
ThemeApplyTools
MIUI 无 root 主题工具
Stars: ✭ 31 (+34.78%)
Mutual labels:  utils
java-sdk
一些常用的java sdk和工具类(日期工具类,分布式锁,redis缓存,二叉树,反射工具类,线程池,对称/非对称/分段加解密,json序列化,http工具,雪花算法,字符串相似度,集合操作工具,xml解析,重试Retry工具类,Jvm监控等)
Stars: ✭ 26 (+13.04%)
Mutual labels:  utils
useful
🇨🇭 A collection of useful functions for working in Elixir
Stars: ✭ 21 (-8.7%)
Mutual labels:  utils
jPublic
在我们开发项目的时候,无论项目规模大小,在所难免会写一些工具型函数来解决一些问题,随着项目开发和维护的时间越来越长,这些工具型函数会越来越多,同时还会穿插在各个项目的各模块或者文件当中,使得项目变的越来越臃肿,也不方便复用和维护。这时我们就会提取出一个类似的工具库或者基础库作为项目基础依赖,在项目中重复利用起来。 为了这样的工具库或类库更易扩展、易维护、易复用和更加稳定,我们就需要更好的去管理完善工具库。
Stars: ✭ 39 (+69.57%)
Mutual labels:  utils
ViseUtils
整理的系列基础工具类,包含辅助工具、加密解密、数据转换、IO操作、系统工具等。
Stars: ✭ 73 (+217.39%)
Mutual labels:  utils
aws-sdk-extra
The AWS SDK + a handful of extra convenience methods.
Stars: ✭ 18 (-21.74%)
Mutual labels:  utils

hey-utils

判断类型

isObject

isArray

isDate

isNumber

isString

isBoolean

isFunction

isNull

isPlainObject

数值计算

替换js数学计算中产生的错误,比如:0.09999999 + 0.00000001

add(arg1, arg2)

加法

sub(arg1, arg2)

减法

mul(arg1, arg2)

乘法

div(arg1, arg2)

除法

对象复制,合并,赋值

extend

用一个或多个其他对象来扩展一个对象,返回被扩展的对象。
如果第一个参数设置为true,则返回一个深层次的副本,递归地复制找到的任何对象。
否则的话,副本会与原对象共享结构。 未定义的属性将不会被复制,然而从对象的原型继承的属性将会被复制。

utils.extend({},{a:1},{b:2});
//结果
{
  a:1,
  b:2
}

freeze

深度冻结对象 Object.freeze的深度实现 例:utils.freeze({a:1});

copy

深度拷贝对象
Object.assign的深度实现 例:utils.copy({a:1});

getKeyValue

获取深度path的对象值

  utils.getKeyValue({id:{v:'a'},b:2},"id.v");
  //'a'
  utils.getKeyValue({id:{v:['a','b']},b:2},"id.v[1]");
  //'b'

setKeyValue

对深度path的对象赋值

  utils.setKeyValue({id:{v:1},b:2}, 'id.v', 2);
  //{id:{v:2},b:2}
  utils.setKeyValue({id:{v:['a','b']},b:2}, "id.v[1]", 'c');
  //{id:{v:['a','c']},b:2}

toArray, toObject

toArray

将object转换成array.
toArray(object,keyName,valueName)
例:

  utils.toArray({a:1,b:1},'key','value');

  //结果
  [{
    key:'a',
    value:1
  },{
    key:'b',
    value:1
  }]


  utils.toArray({a:{b:2,d:4},b:{c:2,e:5}},'id');

  //结果
  [{
    id:'a',
    b:2,
    d:4
  },{
    id:'b',
    c:2,
    e:5
  }]

toObject

将array转换成object.
例:

  utils.toObject(['a','b','c']);

  //结果
  {
    a:'a',
    b:'b',
    c:'c'
  }

  utils.toObject([{id:'a',b:2},{id:'b',b:2}],'id');

  //结果
  {
    a:{
      id:'a',
      b:2
    },
    b:{
      id:'b',
      b:2
    }
  }


  utils.toObject([{id:'a',b:2},{id:'b',b:2}],'id',true);

  //结果
  {
    a:{
      id:'a',
      b:2,
      count:0
    },
    b:{
      id:'b',
      b:2,
      count:1
    }
  }

saveLocal(name, value)

保存本地localStorage

getLocal(name,type)

获取本地localStorage,如果type=='json',这转换出json对象。

getLocal2Json(name)

获取本地localStorage,并转换出json对象。

removeLocal(name)

删除本地localStorage。

saveCookie(name, value, domain, path, minSec)

保存本地cookie,path默认为/,minSec默认无限

getCookie(name)

保存获取cookie

clearCookie(domain, path)

清除所有cookie

removeCookie(name, domain, path)

删除cookie

toSimpleArray(data, key)

获取对应的key数组

toggleValue(list, value)

如果数组存在这个值,则删除,如果没有,则添加

padLeft(str, size)

左边填充0

removeCookie(name, path)

删除cookie,path默认为/

dictMapping({value, dict, connector, keyField='key', titleField='value'})

let a = [{ title: '选择0', key: 0 }, { title: '选择1', key: 'a1', other: '其他值' }, { title: '选择2', key: 'a2' }, { title: '选择3', key: 'a3' }];

utils.dictMapping({value: 'a1', dict: a, titleField: 'title'})
//'选择1'
utils.dictMapping({value: ['a1', 'a2'], dict: a, titleField: 'title'})
//'选择1, 选择2'
utils.dictMapping({value: 'a1|a2', dict: a, titleField: 'title', connector: '|'})
//'选择1, 选择2'

uuid()

生成唯一值

getURLParam(path, search)

获取url参数,例:aa.com?a=1

utils.getURLParam('a', window.location.search)  //1

getAuthor

获取author, 配合umock系统

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].