Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hey-utils

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hey-utils - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

package.json
{
"name": "hey-utils",
"version": "0.0.6",
"version": "0.0.7",
"description": "js-utils, js, util",

@@ -5,0 +5,0 @@ "main": "build/utils.js",

@@ -25,3 +25,3 @@ # hey-utils

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

@@ -37,3 +37,3 @@ {

Object.freeze的深度实现
例:<code>Utils.freeze({a:1});</code>
例:<code>utils.freeze({a:1});</code>

@@ -43,13 +43,22 @@ ### copy

Object.assign的深度实现
例:<code>Utils.copy({a:1});</code>
例:<code>utils.copy({a:1});</code>
### valueForKeypath
获取深度path的对象值
例:<code>Utils.valueForKeypath(obj,'a.b.c.d');</code>
```js
utils.valueForKeypath({id:{v:'a'},b:2},"id.v");
//'a'
utils.valueForKeypath({id:{v:['a','b']},b:2},"id.v[1]");
//'b'
```
### setValueForKeypath
对深度path的对象赋值
例:<code>Utils.setValueForKeypath(obj,'a.b.c.d',1);</code>
```js
utils.setValueForKeypath({id:{v:1},b:2}, 'id.v', 2);
//{id:{v:2},b:2}
utils.setValueForKeypath({id:{v:['a','b']},b:2}, "id.v[1]", 'c');
//{id:{v:['a','c']},b:2}
```
## toArray, toObject

@@ -62,3 +71,3 @@

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

@@ -75,3 +84,3 @@ //结果

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

@@ -95,3 +104,3 @@ //结果

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

@@ -105,3 +114,3 @@ //结果

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

@@ -121,3 +130,3 @@ //结果

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

@@ -162,1 +171,4 @@ //结果

删除cookie,path默认为/
## uuid()
生成唯一值

@@ -314,4 +314,10 @@ (function (global, factory) {

},
uuid() {
const s4 = ()=>{
return Math.floor( ( 1 + Math.random ) * 0x10000 ).toString( 16 ).substring( 1 );
};
return s4 + s4 + '-' + s4 + '-' + s4 + '-' + s4 + '-' + s4 + s4 + s4;
}
}
return heyUtils;
}));
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc