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

get-object

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

get-object - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

35

.verbrc.md

@@ -5,19 +5,7 @@ # {%= name %} {%= badge("fury") %}

## Install
{%= include("install") %}
## Related project
## Run tests
- [get-value](https://github.com/jonschlinkert/get-value)
- [get-property](https://github.com/jonschlinkert/get-property)
```bash
npm test
```
## Run benchmarks
This implementation is between 50% and 100% faster than other implementations I tested.
```bash
node benchmark
```
## Usage

@@ -38,2 +26,19 @@

## Install
{%= include("install") %}
## Run tests
```bash
npm test
```
## Run benchmarks
This implementation is between 50% and 250% faster than other implementations I tested.
```bash
node benchmark
```
## Author

@@ -40,0 +45,0 @@ {%= include("author") %}

@@ -10,7 +10,13 @@ /*!

var isObject = require('isobject');
module.exports = function get(o, lookup) {
if (typeof o !== 'object') {
return null;
if (o == null || !isObject(o)) {
return {};
}
if (lookup == null) {
return o;
}
var seg = lookup.split('.');

@@ -17,0 +23,0 @@ var len = seg.length;

{
"name": "get-object",
"description": "Get a object from a property on a nested object.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/jonschlinkert/get-object",

@@ -69,3 +69,6 @@ "author": {

"value"
]
],
"dependencies": {
"isobject": "^0.2.0"
}
}

@@ -6,2 +6,22 @@ # get-object [![NPM version](https://badge.fury.io/js/get-object.svg)](http://badge.fury.io/js/get-object)

## Related project
- [get-value](https://github.com/jonschlinkert/get-value)
- [get-property](https://github.com/jonschlinkert/get-property)
## Usage
```js
var get = require('get-object');
get({a: 'a', b: {c: 'd'}}, 'a')
//=> 'a'
get({a: 'a', b: {c: 'd'}}, 'b.c')
//=> 'd'
get({a: {b: 'c', c: {d: 'e', e: 'f', g: {h: 'i'}}}}, 'a.c.g.h')
//=> 'i'
```
## Install

@@ -22,3 +42,3 @@ #### Install with [npm](npmjs.org):

This implementation is between 50% and 100% faster than other implementations I tested.
This implementation is between 50% and 250% faster than other implementations I tested.

@@ -29,17 +49,2 @@ ```bash

## Usage
```js
var get = require('get-object');
get({a: 'a', b: {c: 'd'}}, 'a')
//=> 'a'
get({a: 'a', b: {c: 'd'}}, 'b.c')
//=> 'd'
get({a: {b: 'c', c: {d: 'e', e: 'f', g: {h: 'i'}}}}, 'a.c.g.h')
//=> 'i'
```
## Author

@@ -58,2 +63,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 06, 2014._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 08, 2014._

@@ -15,6 +15,3 @@ /*!

it('should get a value only.', function () {
get({a: 'a', b: {c: 'd'}}, 'a').should.eql('a');
});
it('should get a value only.', function () {
get({a: 'aaa', b: {c: 'd'}}, 'a').should.eql('aaa');
get({a: 'a', b: {c: 'd'}}, 'b.c').should.eql('d');

@@ -30,3 +27,37 @@ });

});
it('should use property paths to get nested values from the source object.', function () {
var fixture = {
a: {locals : {name: {first: 'Brian'}}},
b: {locals : {name: {last: 'Woodward'}}}
};
get(fixture, 'a.locals.name').should.eql({first: 'Brian'});
get(fixture, 'b.locals.name').should.eql({last: 'Woodward'});
get(fixture, 'b.locals.name.last').should.eql('Woodward');
});
it('should return an empty object if the path is not found', function () {
var fixture = {};
get(fixture, 'a.locals.name').should.eql({});
get(fixture, 'b.locals.name').should.eql({});
});
it('should get the specified property.', function () {
get({a: 'aaa', b: 'b'}, 'a').should.eql('aaa');
get({first: 'Jon', last: 'Schlinkert'}, 'first').should.eql('Jon');
get({locals: {a: 'a'}, options: {b: 'b'}}, 'locals').should.eql({a: 'a'});
});
it('should return the entire object if no property is passed.', function () {
get({a: 'a', b: {c: 'd'}}).should.eql({a: 'a', b: {c: 'd'}});
});
it('should get the value of a deeply nested property.', function () {
get({a: {b: 'c', c: {d: 'e', e: 'f', g: {h: 'i'}}}}, 'a.c.g.h').should.eql('i');
});
it('should return an empty object if the first value is null.', function () {
get(null, 'a.c.g.h').should.eql({});
});
});
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