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

a-toolbox

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-toolbox - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

39

dist/atoolbox.min.js

@@ -961,2 +961,12 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

function isSurrogatePair(msg, i) {
if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
return false;
}
if (i < 0 || i + 1 >= msg.length) {
return false;
}
return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
}
function toArray(msg, enc) {

@@ -970,10 +980,25 @@ if (Array.isArray(msg))

if (!enc) {
// Inspired by stringToUtf8ByteArray() in closure-library by Google
// https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
// Apache License 2.0
// https://github.com/google/closure-library/blob/master/LICENSE
var p = 0;
for (var i = 0; i < msg.length; i++) {
var c = msg.charCodeAt(i);
var hi = c >> 8;
var lo = c & 0xff;
if (hi)
res.push(hi, lo);
else
res.push(lo);
if (c < 128) {
res[p++] = c;
} else if (c < 2048) {
res[p++] = (c >> 6) | 192;
res[p++] = (c & 63) | 128;
} else if (isSurrogatePair(msg, i)) {
c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
res[p++] = (c >> 18) | 240;
res[p++] = ((c >> 12) & 63) | 128;
res[p++] = ((c >> 6) & 63) | 128;
res[p++] = (c & 63) | 128;
} else {
res[p++] = (c >> 12) | 224;
res[p++] = ((c >> 6) & 63) | 128;
res[p++] = (c & 63) | 128;
}
}

@@ -1261,3 +1286,3 @@ } else if (enc === 'hex') {

},{"hash.js":1}],19:[function(require,module,exports){
'use strict';var _typeof=typeof Symbol==='function'&&typeof Symbol.iterator==='symbol'?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==='function'&&obj.constructor===Symbol&&obj!==Symbol.prototype?'symbol':typeof obj};var tools={array:require('./array')};var object={merge:function merge(a,b){if(!a){a=b||{};return}if(!b){return a}for(var i in b){if(_typeof(b[i])==='object'){if(b[i]instanceof Array){a[i]=object.clone(b[i]);continue}if(!a[i]||_typeof(a[i])!=='object'){a[i]={}}object.merge(a[i],b[i])}else{a[i]=b[i]}}},clone:function clone(obj){if(obj===null||obj===undefined){return obj}var _type=obj instanceof Array?'array':typeof obj==='undefined'?'undefined':_typeof(obj);if(_type==='object'||_type==='array'){if(obj instanceof Date){return new Date(obj.getTime())}else{if(obj.clone){return obj.clone()}var _clone=_type==='array'?[]:{};for(var key in obj){_clone[key]=object.clone(obj[key])}return _clone}}return obj},getKeys:function getKeys(obj){if(Object.keys){return Object.keys(obj)}var _keys=[];for(var key in obj){_keys.push(key)}return _keys},inherits:function inherits(destination,source){if(Object.assign){Object.assign(destination,source);return}Object.getOwnPropertyNames(source).forEach(function(property){destination[property]=source[property]})},empty:function empty(obj){for(var i in obj){delete obj[i]}},raise:function raise(flat){var _raise={};var _loop=function _loop(path){var _keys=path.split('.');var _cursor=_raise;_keys.forEach(function(key,i){if(i<_keys.length-1){if(!_cursor[key]){_cursor[key]={}}_cursor=_cursor[key]}else{_cursor[key]=flat[path]}})};for(var path in flat){_loop(path)}return _raise},flat:function flat(obj){var _flat={};object._rflat(obj,'',_flat);return _flat},_rflat:function _rflat(obj,base,flat){for(var key in obj){try{if(obj[key].constructor==Object){object._rflat(obj[key],base+key+'.',flat)}else{flat[base+key]=obj[key]}}catch(e){flat[base+key]=obj[key]}}},walk:function walk(obj,path){var _steps=path.split('.');var _cursor=obj;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=_steps[Symbol.iterator](),_step2;!(_iteratorNormalCompletion=(_step2=_iterator.next()).done);_iteratorNormalCompletion=true){var _step=_step2.value;_cursor=_cursor[_step]}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator.return){_iterator.return()}}finally{if(_didIteratorError){throw _iteratorError}}}return _cursor},getByFlatKey:function getByFlatKey(obj,fkey){var _path=fkey.split('.');var _walk=obj;for(var i=0;i<_path.length;i++){if(!_walk[_path[i]]){return undefined}_walk=_walk[_path[i]]}return _walk},setByFlatKey:function setByFlatKey(obj,fkey,val){console.log(fkey);var _path=fkey.split('.').map(function(path){if(path.indexOf('[')===-1){return{t:'{}',s:path}}var _array=path.substr(0,path.length-1).split('[');return[{t:'{}',s:_array[0]},{t:'[]',s:parseInt(_array[1])}]});_path=tools.array.flat(_path);var _walk=obj;for(var i=0;i<_path.length;i++){var _step=_path[i];if(i===_path.length-1){_walk[_step.s]=val;return}if(!_walk[_step.s]){_walk[_step.s]=_path[i+1].t==='{}'?{}:[]}_walk=_walk[_step.s]}_walk=val;console.log(obj)}};module.exports=object;
'use strict';var _typeof=typeof Symbol==='function'&&typeof Symbol.iterator==='symbol'?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==='function'&&obj.constructor===Symbol&&obj!==Symbol.prototype?'symbol':typeof obj};var tools={array:require('./array')};var object={merge:function merge(a,b){if(!a){a=b||{};return}if(!b){return a}for(var i in b){if(_typeof(b[i])==='object'){if(b[i]instanceof Array){a[i]=object.clone(b[i]);continue}if(!a[i]||_typeof(a[i])!=='object'){a[i]={}}object.merge(a[i],b[i])}else{a[i]=b[i]}}},clone:function clone(obj){if(obj===null||obj===undefined){return obj}var _type=obj instanceof Array?'array':typeof obj==='undefined'?'undefined':_typeof(obj);if(_type==='object'||_type==='array'){if(obj instanceof Date){return new Date(obj.getTime())}else{if(obj.clone){return obj.clone()}var _clone=_type==='array'?[]:{};for(var key in obj){_clone[key]=object.clone(obj[key])}return _clone}}return obj},getKeys:function getKeys(obj){if(Object.keys){return Object.keys(obj)}var _keys=[];for(var key in obj){_keys.push(key)}return _keys},inherits:function inherits(destination,source){if(Object.assign){Object.assign(destination,source);return}Object.getOwnPropertyNames(source).forEach(function(property){destination[property]=source[property]})},empty:function empty(obj){for(var i in obj){delete obj[i]}},raise:function raise(flat){var _raise={};var _loop=function _loop(path){var _keys=path.split('.');var _cursor=_raise;_keys.forEach(function(key,i){if(i<_keys.length-1){if(!_cursor[key]){_cursor[key]={}}_cursor=_cursor[key]}else{_cursor[key]=flat[path]}})};for(var path in flat){_loop(path)}return _raise},flat:function flat(obj){var _flat={};object._rflat(obj,'',_flat);return _flat},_rflat:function _rflat(obj,base,flat){for(var key in obj){try{if(obj[key].constructor==Object){object._rflat(obj[key],base+key+'.',flat)}else{flat[base+key]=obj[key]}}catch(e){flat[base+key]=obj[key]}}},walk:function walk(obj,path){var _steps=path.split('.');var _cursor=obj;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=_steps[Symbol.iterator](),_step2;!(_iteratorNormalCompletion=(_step2=_iterator.next()).done);_iteratorNormalCompletion=true){var _step=_step2.value;_cursor=_cursor[_step]}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator.return){_iterator.return()}}finally{if(_didIteratorError){throw _iteratorError}}}return _cursor},getByFlatKey:function getByFlatKey(obj,fkey){var _path=fkey.split('.').map(function(path){if(path.indexOf('[')===-1){return{t:'{}',s:path}}var _array=path.substr(0,path.length-1).split('[');return[{t:'{}',s:_array[0]},{t:'[]',s:parseInt(_array[1])}]});_path=tools.array.flat(_path);var _walk=obj;for(var i=0;i<_path.length;i++){var _step=_path[i];if(i===_path.length-1){return _walk[_step.s]}if(!_walk[_step.s]){_walk[_step.s]=_path[i+1].t==='{}'?{}:[]}_walk=_walk[_step.s]}return _walk},setByFlatKey:function setByFlatKey(obj,fkey,val){var _path=fkey.split('.').map(function(path){if(path.indexOf('[')===-1){return{t:'{}',s:path}}var _array=path.substr(0,path.length-1).split('[');return[{t:'{}',s:_array[0]},{t:'[]',s:parseInt(_array[1])}]});_path=tools.array.flat(_path);var _walk=obj;for(var i=0;i<_path.length;i++){var _step=_path[i];if(i===_path.length-1){_walk[_step.s]=val;return}if(!_walk[_step.s]){_walk[_step.s]=_path[i+1].t==='{}'?{}:[]}_walk=_walk[_step.s]}_walk=val}};module.exports=object;

@@ -1264,0 +1289,0 @@ },{"./array":16}],20:[function(require,module,exports){

6

index.js

@@ -1,2 +0,3 @@

module.exports = {array: require('./array'),
module.exports = {
array: require('./array'),
fs: require('./fs'),

@@ -11,2 +12,3 @@ hash: require('./hash'),

time: require('./time'),
util: require('./util')}
util: require('./util')
}

@@ -208,2 +208,3 @@ const tools = {

*/
/*
getByFlatKey: function (obj, fkey) {

@@ -220,2 +221,27 @@ let _path = fkey.split('.')

},
*/
getByFlatKey: function (obj, fkey) {
let _path = fkey
.split('.')
.map((path) => {
if (path.indexOf('[') === -1) {
return {t: '{}', s: path}
}
const _array = path.substr(0, path.length - 1).split('[')
return [{t: '{}', s: _array[0]}, {t: '[]', s: parseInt(_array[1])}]
})
_path = tools.array.flat(_path)
let _walk = obj
for (let i = 0; i < _path.length; i++) {
let _step = _path[i]
if (i === _path.length - 1) {
return _walk[_step.s]
}
if (!_walk[_step.s]) {
_walk[_step.s] = _path[i + 1].t === '{}' ? {} : []
}
_walk = _walk[_step.s]
}
return _walk
},

@@ -234,3 +260,2 @@ /**

setByFlatKey: function (obj, fkey, val) {
console.log(fkey)
let _path = fkey

@@ -259,3 +284,2 @@ .split('.')

_walk = val
console.log(obj)
}

@@ -262,0 +286,0 @@ }

{
"name": "a-toolbox",
"version": "1.7.1",
"version": "1.7.2",
"description": "javascript lightweight basic tools for node.js and browser",
"main": "index.js",
"dependencies": {
"hash.js": "^1.1.5"
"hash.js": "^1.1.7"
},
"devDependencies": {
"natives": "^1.1.6",
"babel": "^6.23.0",

@@ -17,3 +16,3 @@ "babel-core": "^6.26.3",

"browserify": "^16.2.2",
"fs-extra": "^7.0.0",
"fs-extra": "^8.1.0",
"gulp": "^3.9.1",

@@ -24,5 +23,5 @@ "gulp-buffer": "^0",

"ink-docstrap": "^1",
"natives": "^1.1.6",
"pre-commit": "^1",
"standard": "^11.0.1",
"tap": "^12.0.1",
"standard": "^14.3.1",
"vinyl-source-stream": "^1"

@@ -29,0 +28,0 @@ },

@@ -457,3 +457,2 @@ # a-toolbox

````js
tools.object.raise({ 'a.a1': 1, 'a.a2': 2, 'b': 3 })

@@ -476,2 +475,5 @@ // > { a: { a1: 1, a2: 2 }, b: 3 }

// > 1
tools.object.getByFlatKey({ a: { b: [{c: 1}] } }, 'a.b[0].c')
// > 1
````

@@ -493,2 +495,6 @@

// > a = { a: { b: {c: 1} } }
let a = {}
tools.object.setByFlatKey(a, 'a.b[0].c', 1)
// > a = { a: { b: [{c: 1}] } }
````

@@ -908,2 +914,6 @@

v. 1.7.2
- add ``object.getByFlatKey`` support also Array
v. 1.7.1

@@ -943,2 +953,3 @@

- [ ] string.caseCamel, string.casePascal
- [ ] object.walk test, doc

@@ -945,0 +956,0 @@ - [ ] travis CI / node, browser

@@ -208,2 +208,3 @@ const tools = {

*/
/*
getByFlatKey: function (obj, fkey) {

@@ -220,2 +221,27 @@ let _path = fkey.split('.')

},
*/
getByFlatKey: function (obj, fkey) {
let _path = fkey
.split('.')
.map((path) => {
if (path.indexOf('[') === -1) {
return {t: '{}', s: path}
}
const _array = path.substr(0, path.length - 1).split('[')
return [{t: '{}', s: _array[0]}, {t: '[]', s: parseInt(_array[1])}]
})
_path = tools.array.flat(_path)
let _walk = obj
for (let i = 0; i < _path.length; i++) {
let _step = _path[i]
if (i === _path.length - 1) {
return _walk[_step.s]
}
if (!_walk[_step.s]) {
_walk[_step.s] = _path[i + 1].t === '{}' ? {} : []
}
_walk = _walk[_step.s]
}
return _walk
},

@@ -234,3 +260,2 @@ /**

setByFlatKey: function (obj, fkey, val) {
console.log(fkey)
let _path = fkey

@@ -259,3 +284,2 @@ .split('.')

_walk = val
console.log(obj)
}

@@ -262,0 +286,0 @@ }

Sorry, the diff of this file is not supported yet

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