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 0.1.2 to 0.1.3

44

main.js

@@ -308,2 +308,46 @@ /* global Blob File FormData $ */

})
},
/**
* flat keys in object
* @param {object} obj
* @returns {object}
* @example { a: { a1: 1, a2: 2 }, b: 3 } >> { 'a.a1': 1, 'a.a2': 2, 'b': 3 }
*/
flat: function (obj) {
const _flat = {}
const _f = function (obj, base) {
for (const key in obj) {
try {
if (obj[key].constructor == Object) {
_f(obj[key], base + key + '.')
} else {
_flat[base + key] = obj[key]
}
} catch (e) {
_flat[base + key] = obj[key]
}
}
}
_f(obj, '')
return _flat
},
/**
* get value in object using a flat key
* @param {object} obj
* @param {string} fkey
* @returns {object}
* @example tools.object.getByFlatKey({ a: { b: {c: 1} } }, 'a.b.c') >> 1
*/
getByFlatKey: function (obj, fkey) {
let _path = fkey.split('.')
let _walk = obj
for (let i = 0; i < _path.length; i++) {
if (!_walk[_path[i]]) {
return undefined
}
_walk = _walk[_path[i]]
}
return _walk
}

@@ -310,0 +354,0 @@ },

2

package.json
{
"name": "a-toolbox",
"version": "0.1.2",
"version": "0.1.3",
"description": "basic lightweight tools",

@@ -5,0 +5,0 @@ "main": "main.js",

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