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

objob

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objob - npm Package Compare versions

Comparing version 2.4.1 to 2.5.0

DOCREADME.md

2

.jsdoc.json
{
"version": "2.4.0",
"version": "2.5.0",
"tags": {

@@ -4,0 +4,0 @@ "allowUnknownTags" : true

@@ -1,1 +0,19 @@

Coming soon
# Contributing
--
* Please squash your commits
* Please write tests
* Please make sure you write clear JSDOC annotations following the format you see in the rest of the codebase.
* Please make sure your you test your documentation.
* The 'flatten' and 'expand' functions will make it much easier to create recursive functions without worrying about the recursion. Ulitize them when possible.
If anything else comes to mind, it will be here. :)
## Tests
You can run all tests with mocha
npm test
## Documentation
Please make sure the documentation is correct after you make your changes. You can generate docs with jsdoc
npm run generate-docs

@@ -163,2 +163,46 @@ 'use strict';

/**
* Returns true if two objects or arrays have the same contents as one another.
*
* @example
*
* let x = {
* a: 1,
* d: {f: 4}
* }
*
* let y = {
* a: 1,
* d: {f: 4}
* }
*
* ob.equals(x, y)
* // → true
*
* ob.equals([x, x], [y, y])
* // → true
*
* @param {object|any[]} subject The object or array to compare to
* @param {object|any[]} subject2 The object or compare against
* @returns {boolean}
*/
equals: function equals(subject, subject2) {
subject = ob.flatten(subject);
subject2 = ob.flatten(subject2);
var notEqual = false;
if (Object.keys(subject).length !== Object.keys(subject2).length) {
notEqual = true;
}
var shallowSubject = (0, _functions.makeFlattenedShallow)(subject);
var shallowSubject2 = (0, _functions.makeFlattenedShallow)(subject2);
for (var key in Object.keys(shallowSubject)) {
if (shallowSubject[key] !== shallowSubject2[key]) {
notEqual = true;
}
}
return !notEqual;
},
/**
* Takes a flattened object and expands it back to a full object or array of objects.

@@ -165,0 +209,0 @@ *

{
"name": "objob",
"version": "2.4.1",
"version": "2.5.0",
"description": "A tool for controlling and manipulating javascript object fields and output.",

@@ -10,3 +10,3 @@ "main": "lib/objob.js",

"prepublish": "npm run build",
"generate-docs": "jsdoc --configure .jsdoc.json --verbose"
"generate-docs": "jsdoc --configure .jsdoc.json --verbose --readme DOCREADME.md"
},

@@ -35,5 +35,5 @@ "keywords": [

"jsdoc": "^3.4.0",
"minimal-jsdoc": "0.0.1",
"minimal-jsdoc": "^0.1.0",
"mocha": "^2.3.4"
}
}
# Ob Job (beta)
A library of deep/recursive utilities for nested objects. Many functions will be similar to the object functions in lodash but will be deep/recursive versions.
A library of deep/recursive utilities for nested objects.
```bash
import ob from 'objob';
```
Many functions will be similar to the object functions in lodash but will be deep/recursive versions.
Ob Job includes the following functions and many more with every function being a deep/recursive implementation:
* clone
* equals
* expand
* filter
* flatten
* keys
* merge
* omit
* pick
* values
* [More...](https://rawgit.com/chiedolabs/objob/master/docs/index.html)
## Installation
npm install objob
## Usage
import ob from 'objob';
## Further Reading
* [API Documentation](https://rawgit.com/chiedolabs/objob/master/docs/ob.html)
* [API Documentation](https://rawgit.com/chiedolabs/objob/master/docs/index.html)
* [Changelog](./CHANGELOG.md)

@@ -19,2 +37,6 @@ * [Contributing](./CONTRIBUTING.md)

## Roadmap
* It is on the todo list to port over all of the lodash Object functions and make them recursive. So much to do, so little time.
## Special Thanks

@@ -21,0 +43,0 @@

@@ -107,2 +107,46 @@ 'use strict';

/**
* Returns true if two objects or arrays have the same contents as one another.
*
* @example
*
* let x = {
* a: 1,
* d: {f: 4}
* }
*
* let y = {
* a: 1,
* d: {f: 4}
* }
*
* ob.equals(x, y)
* // → true
*
* ob.equals([x, x], [y, y])
* // → true
*
* @param {object|any[]} subject The object or array to compare to
* @param {object|any[]} subject2 The object or compare against
* @returns {boolean}
*/
equals: function(subject, subject2){
subject = ob.flatten(subject);
subject2 = ob.flatten(subject2);
let notEqual = false;
if(Object.keys(subject).length !== Object.keys(subject2).length) {
notEqual = true;
}
let shallowSubject = makeFlattenedShallow(subject);
let shallowSubject2 = makeFlattenedShallow(subject2);
for(let key in Object.keys(shallowSubject)) {
if(shallowSubject[key] !== shallowSubject2[key]) {
notEqual = true;
}
}
return !notEqual;
},
/**
* Takes a flattened object and expands it back to a full object or array of objects.

@@ -109,0 +153,0 @@ *

@@ -59,2 +59,7 @@ /* eslint max-nested-callbacks: 0*/

expect(ob.expand(ob.flatten(ob4))).to.deep.equal(ob4);
expect(ob.expand(ob.flatten({tmp: arr4}))).to.deep.equal({tmp: arr4});
done();
});
it('should return the expanded array', (done) => {
expect(ob.expand(ob.flatten(arr2))).to.deep.equal(arr2);

@@ -64,5 +69,5 @@ expect(ob.expand(ob.flatten(arr1))).to.deep.equal(arr1);

expect(ob.expand(ob.flatten(arr4))).to.deep.equal(arr4);
expect(ob.expand(ob.flatten({tmp: arr4}))).to.deep.equal({tmp: arr4});
expect(ob.expand(ob.flatten([[[arr4]]]))).to.deep.equal([[[arr4]]]);
done();
});
});

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