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

enumerate-properties

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enumerate-properties - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

documentation.md

45

lib/enumerate-properties.js

@@ -1,3 +0,13 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.8.0
module.exports = {
/*
* # enumerate(object, callback)
*
* Enumerates properties in a JSON object and callback
* each as a dot notation format
*
* @param {Object} object The object on which to iterate
* @param {Function} callback Callback function called for each property
*/
enumerate: function(object, callback) {

@@ -13,3 +23,3 @@ var walk;

val = obj[prop];
if (walk(val, stack + '.' + prop)) {
if (walk(val, "" + stack + "." + prop)) {
str = '';

@@ -27,5 +37,16 @@ if (stack) {

},
/*
* # getAtPath(object, path)
*
* Retrieve nested value from a JSON object given
* the dot notation of it's property
*
* @param {Object} object The object on which to get a value
* @param {String} path Dot notation of the property to get
* @return {* | null}
*/
getAtPath: function(object, path) {
var i, props, _i, _len;
if (path === null) {
if ((path == null) || (object == null)) {
return null;

@@ -36,3 +57,3 @@ }

i = props[_i];
if (!object || typeof object !== 'object') {
if (object[i] == null) {
return null;

@@ -42,7 +63,15 @@ }

}
if (object === void 0) {
return null;
}
return object;
},
/*
* # setAtPath(object, path, value)
*
* Set nested value of a JSON object to the given
* dot notation path
*
* @param {Object} object The object on which to set
* @param {String} path Dot notation of the property to set
* @param {*} value Value to set
*/
setAtPath: function(object, path, value) {

@@ -53,3 +82,3 @@ var i, len, parts, _i;

for (i = _i = 0; 0 <= len ? _i < len : _i > len; i = 0 <= len ? ++_i : --_i) {
if (!object[parts[i]]) {
if (object[parts[i]] == null) {
object[parts[i]] = {};

@@ -56,0 +85,0 @@ }

8

package.json
{
"name": "enumerate-properties",
"author": "Thibault Charbonnier <thibaultcha@me.com>",
"version": "1.0.0",
"version": "1.1.0",
"description": "Enumerates, get and set objects properties in a dot notation format",

@@ -23,8 +23,8 @@ "keywords": [

"dependencies": {
"coffee-script": "1.6.x"
"coffee-script": "~1.8.0"
},
"devDependencies": {
"mocha": "1.1.x",
"should": "2.1.x"
"mocha": "~1.21.4",
"should": "~4.0.4"
}
}

@@ -13,15 +13,18 @@ # node-enumerate-properties

### Usage
### Documentation
See [documentation.md](documentation.md)
### Example
```javascript
var properties = require('enumerate-properties')
obj =
{ foo: 'bar'
, bar: 'foo'
, nested:
{ foo: 'bar'
, bar: 'foo'
}
, foobar: 'barfoo'
obj = {
foo: 'bar',
bar: 'foo',
nested: {
foo: 'bar',
bar: 'foo'
},
foobar: 'barfoo'
}

@@ -28,0 +31,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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