New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

deep-props.get

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-props.get - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

21

CHANGELOG.md
Changelog
=========
<a name="0.1.1"></a>
## [0.1.1](https://github.com/jpcx/deep-props.get/tree/0.1.1) (2018-05-10)
__Since: [deep-props 0.2.1](https://github.com/jpcx/deep-props/blob/0.2.1/CHANGELOG.md#0.2.1)__
| __[Changes since 0.1.0](https://github.com/jpcx/deep-props.get/compare/0.1.0...0.1.1)__ | [Release Notes](https://github.com/jpcx/deep-props.get/releases/tag/0.1.1) | [README](https://github.com/jpcx/deep-props.get/tree/0.1.1/README.md) |
| --- | --- | --- |
| [Source Code (zip)](https://github.com/jpcx/deep-props.get/archive/0.1.1.zip) | [Source Code (tar.gz)](https://github.com/jpcx/deep-props.get/archive/0.1.1.tar.gz) |
| --- | --- |
#### Bugfixes
+ __docs:__ Fixed critical documentation issues.
+ __docs:__ Added Set to description and NPM tags.
+ __docs:__ Fixed examples.
+ __docs:__ Fixed inability to update parent or sibling modules without updating documentation.
+ __NPM:__ Added newline to end of package.json.
#### Features
+ __NPM:__ Added package-lock.json.
<a name="0.1.0"></a>

@@ -5,0 +26,0 @@ ## [0.1.0](https://github.com/jpcx/deep-props.get/tree/0.1.0) (2018-05-09)

71

index.js

@@ -12,2 +12,43 @@ /**

/**
* Custom dataset for use as a <a href="#~Container">Container</a>. May be accessed via valid customizer functions.
*
* @typedef {*} deep-props.get~Custom
* @example
* (() => {
* class CustomDataStructure {
* constructor(array) {
* this.get = i => array[i]
* this.getValues = () => array
* this.push = x => array.push(x)
* }
* }
* return new CustomDataStructure([ 'foo', 'bar' ])
* })()
*/
/**
* Key used for accessing a child property within a container. When its value is <code>'__proto__'</code>, it is used as a stand-in for <code>Object.getPrototypeOf()</code>.
*
* @typedef {(string|deep-props.get~Container)} deep-props.get~Key
*/
/**
* Container object used as a target for child property extraction.
*
* @typedef {(Object|Array|Map|WeakMap|Set|WeakSet|deep-props.get~Custom)} deep-props.get~Container
*/
/**
* A non-primitive <a href="#~Container">Container</a> which represents the root of a given path.
*
* @typedef {deep-props.get~Container} deep-props.get~Host
*/
/**
* Generator object which yields stepwise operation results.
*
* @typedef {Object} deep-props.get~ResultGenerator
*/
/**
* Current reference to a given level of the path; parent to the next key along the path.

@@ -26,3 +67,3 @@ * <ul>

*
* @typedef {(deep-props~Container|string|undefined)} deep-props.get~Target
* @typedef {(deep-props.get~Container|string|undefined)} deep-props.get~Target
*/

@@ -40,3 +81,3 @@

* @param {deep-props.get~Target} target - Current data being analyzed
* @param {deep-props~Key} key - Next key along the path
* @param {deep-props.get~Key} key - Next key along the path
* @returns {deep-props.get~Target} Value to pass along to the search function as the next Target. If undefined, will fall back on using standard extraction methods to find the next Target.

@@ -83,3 +124,3 @@ * @example

*
* @typedef {deep-props~Key[]|string} deep-props.get~Path
* @typedef {deep-props.get~Key[]|string} deep-props.get~Path
* @example

@@ -98,3 +139,3 @@ * [ 'foo', 'bar', 'baz' ]

* @param {deep-props.get~Target} target - Target of Key search.
* @param {deep-props~Key} key - Key to find in target.
* @param {deep-props.get~Key} key - Key to find in target.
* @returns {deep-props.get~Target} New target from key or undefined if not found.

@@ -135,3 +176,3 @@ * @example

* @param {deep-props.get~Target} target - Target of Key search.
* @param {deep-props~Key} key - Key to find in target.
* @param {deep-props.get~Key} key - Key to find in target.
* @returns {deep-props.get~Target} New target from key or undefined if not found.

@@ -154,3 +195,3 @@ * @example

* @param {deep-props.get~Target} target - Target of Key search.
* @param {deep-props~Key} key - Key to find in target.
* @param {deep-props.get~Key} key - Key to find in target.
* @returns {deep-props.get~Target} New target from key or undefined if not found.

@@ -172,6 +213,6 @@ * @example

* @memberof deep-props.get
* @param {deep-props.get~Target} target - Target object.
* @param {deep-props~Key} key - Access key.
* @param {deep-props.get~Options} opt - Execution settings.
* @returns {deep-props.get~Target} New target, final value, or undefined.
* @param {deep-props.get~Target} target - Target object.
* @param {deep-props.get~Key} key - Access key.
* @param {deep-props.get~Options} opt - Execution settings.
* @returns {deep-props.get~Target} New target, final value, or undefined.
* @example

@@ -210,3 +251,3 @@ * // all return 'bar'

* @memberof deep-props.get
* @param {deep-props~Host} host - Base container dataset to search within.
* @param {deep-props.get~Host} host - Base container dataset to search within.
* @param {deep-props.get~Path} path - Path to desired property.

@@ -254,6 +295,6 @@ * @param {deep-props.get~Options} opt - Execution settings.

* @module get
* @param {deep-props~Host} host - Container to search within.
* @param {deep-props.get~Host} host - Container to search within.
* @param {deep-props.get~Path} path - Path to desired property.
* @param {deep-props.get~Options} [opt={}] - Execution settings.
* @returns {(deep-props.get~Target|deep-props~ResultGenerator)} Endpoint of path - the result of the search. Target is undefined if not found. If <code>opt.gen === true</code>, returns a generator that yields each search step.
* @returns {(deep-props.get~Target|deep-props.get~ResultGenerator)} Endpoint of path - the result of the search. Target is undefined if not found. If <code>opt.gen === true</code>, returns a generator that yields each search step.
* @example

@@ -290,3 +331,3 @@ * // Nested object and array extraction

*
* const nest = new NonNativeDataStructure[{ foo: { bar: testAB } }]
* const nest = new NonNativeDataStructure([{ foo: { bar: testAB } }])
*

@@ -300,3 +341,3 @@ * // returns undefined

* if (target instanceof NonNativeDataStructure) {
* return target.retrieve(next)
* return target.retrieve(key)
* }

@@ -303,0 +344,0 @@ * if (target instanceof ArrayBuffer && target.byteLength === 16) {

{
"name": "deep-props.get",
"version": "0.1.0",
"description": "Retrieves a nested property from a data source by iterating over a supplied path. Supports Objects, Arrays, Maps, Weakmaps, and JSON strings automatically. Supports the use of a custom extraction function to handle unsupported datasets.",
"version": "0.1.1",
"description": "Retrieves a nested property from a data source by iterating over a supplied path. Supports Objects, Arrays, Maps, Sets, WeakMaps, and JSON strings automatically. Supports the use of a custom extraction function to handle unsupported datasets.",
"engines": {

@@ -22,2 +22,3 @@ "node": ">=8.7.0"

"map",
"set",
"weakmap",

@@ -47,2 +48,2 @@ "json",

}
}
}

@@ -1,12 +0,12 @@

# [deep-props](https://github.com/jpcx/deep-props/blob/0.2.0/README.md).get
# [deep-props](https://github.com/jpcx/deep-props/blob/master/README.md).get
[![NPM](https://nodei.co/npm/deep-props.get.png)](https://nodei.co/npm/deep-props.get/)
Retrieves a nested property from a data source by iterating over a supplied path. Supports Objects, Arrays, Maps, Weakmaps, and JSON strings automatically. Supports the use of a custom extraction function to handle unsupported datasets.
Retrieves a nested property from a data source by iterating over a supplied path. Supports Objects, Arrays, Maps, Sets, WeakMaps, and JSON strings automatically. Supports the use of a custom extraction function to handle unsupported datasets.
Any unsupported data structure may be accessed by supplying a customizer function. See [<code>this example</code>](#customizer_example).
See the [usage examples](#usage) for an overview of different types of data structures.
## Getting Started
The following installation, testing, and deployment instructions assume that deep-props.extract will be installed as a standalone module. For instructions on how to install and test all deep-props modules, please [refer to the main README](https://github.com/jpcx/deep-props/blob/0.2.0/README.md). Functionality of the module remains the same in both cases.
The following installation, testing, and deployment instructions assume that deep-props.extract will be installed as a standalone module. For instructions on how to install and test all deep-props modules, please [refer to the main README](https://github.com/jpcx/deep-props/blob/master/README.md). Functionality of the module remains the same in both cases.

@@ -37,14 +37,28 @@ ### Prerequisites

<a name="usage"></a>
### Usage
**Nested object extraction**
***Note:*** For string paths using standard settings, '.' is considered the same as '[' and ']'. See [<code>Options</code>](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Options) for instructions for customizing this behavior.
**Nested Object Extraction**
```js
const nest = { foo: { bar: { baz: 'qux' } } }
// returns 'qux'
// Both return 'qux'
get(nest, 'foo.bar.baz')
get(nest, [ 'foo', 'bar', 'baz' ])
```
**Nested Map extraction**
**Nested Array Extraction**
```js
const nest = [ [ [ 'foo' ] ] ]
// Both return 'foo'
get(nest, '0.0.0')
get(nest, [ '0', '0', '0' ])
```
**Nested Map Extraction**
```js
const nest = new Map().set(

@@ -60,6 +74,66 @@ 'foo', new Map().set(

// returns 'quz'
// Both return 'quz'
get(nest, 'foo.bar.baz.qux')
get(nest, [ 'foo', 'bar', 'baz', 'qux' ])
```
**Nested Map Extraction with Non-Primitive Keys**
```js
const keyA = { foo: 'bar' }
const keyB = { qux: 'quz' }
const keyC = { quux: 'quuz' }
const nest = new Map().set(
keyA, new Map().set(
keyB, new Map().set(
keyC, 'thud'
)
)
)
// Returns 'thud'
// Note: this path must be an array of Object references.
get(nest, [ keyA, keyB, keyC ])
```
**Nested WeakMap Extraction**
```js
const keyA = { foo: 'bar' }
const keyB = { qux: 'quz' }
const keyC = { quux: 'quuz' }
const nest = new WeakMap().set(
keyA, new WeakMap().set(
keyB, new WeakMap().set(
keyC, 'thud'
)
)
)
// Returns 'thud'
// Note: this path must be an array of Object references.
get(nest, [ keyA, keyB, keyC ])
```
**Nested Set Extraction**
```js
const setA = new Set()
const setB = new Set()
const setC = new Set()
const nest = new Set().add(
setA.add(
setB.add(
setC.add('foo')
)
)
)
// All return 'foo'
// Note: values may be accessed via insertion order or actual references.
get(nest, '0.0.0.0')
get(nest, [ 0, 0, 0, 0 ])
get(nest, [ setA, setB, setC, 0 ])
```
**Extraction from JSON**

@@ -96,3 +170,3 @@ ```js

// Array path is required here, because wmKey needs to be a reference
get(data, ['foo', 0, 'bar', wmKey, 'baz', 0, 'qux'])
get(nest, ['foo', 0, 'bar', wmKey, 'baz', 0, 'qux'])
```

@@ -102,3 +176,3 @@

**Usage of a custom extraction function (see [<code>Options</code>](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md#~Options) and [<code>GetCustomizer</code>](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md#~GetCustomizer))**
**Usage of a custom extraction function (see [<code>Options</code>](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Options) and [<code>GetCustomizer</code>](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~GetCustomizer))**
```js

@@ -117,3 +191,3 @@ // Creation of a sample custom data structure which uses a 'retrieve' method for data access.

const nest = new NonNativeDataStructure[{ foo: { bar: testAB } }]
const nest = new NonNativeDataStructure([{ foo: { bar: testAB } }])

@@ -125,5 +199,5 @@ // returns undefined

get(nest, '0.foo.bar[0]', {
customizer: (target, key) => {
getCustomizer: (target, key) => {
if (target instanceof NonNativeDataStructure) {
return target.retrieve(next)
return target.retrieve(key)
}

@@ -140,4 +214,4 @@ if (target instanceof ArrayBuffer && target.byteLength === 16) {

### See:
* [API Docs](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/API.md)
* [Global Docs](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md)
+ [API Docs](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/API.md)
+ [Global Docs](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md)

@@ -152,9 +226,9 @@ ### Module: get

| --- | --- | --- | --- | --- |
| `host` | [deep-props~Host](https://github.com/jpcx/deep-props/blob/0.2.0/docs/global.md#~Host) | | | Container to search within. |
| `path` | [deep-props.get~Path](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md#~Path) | | | Path to desired property. |
| `opt` | [deep-props.get~Options](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md#~Options) | \<optional> | {} | Execution settings. |
| `host` | [deep-props.get~Host](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Host) | | | Container to search within. |
| `path` | [deep-props.get~Path](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Path) | | | Path to desired property. |
| `opt` | [deep-props.get~Options](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Options) | \<optional> | {} | Execution settings. |
Source:
* [deep-props.get/index.js](https://github.com/jpcx/deep-props.get/blob/0.1.0/index.js), [line 241](https://github.com/jpcx/deep-props.get/blob/0.1.0/index.js#L241)
* [deep-props.get/index.js](https://github.com/jpcx/deep-props.get/blob/0.1.1/index.js), [line 282](https://github.com/jpcx/deep-props.get/blob/0.1.1/index.js#L282)

@@ -167,3 +241,3 @@ ##### Returns:

[deep-props.get~Target](https://github.com/jpcx/deep-props.get/blob/0.1.0/docs/global.md#~Target) | [deep-props~ResultGenerator](https://github.com/jpcx/deep-props/blob/0.2.0/docs/global.md#~ResultGenerator)
[deep-props.get~Target](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~Target) | [deep-props.get~ResultGenerator](https://github.com/jpcx/deep-props.get/blob/0.1.1/docs/global.md#~ResultGenerator)

@@ -174,3 +248,3 @@ #

Versioned using [SemVer](http://semver.org/). For available versions, see the [Changelog](https://github.com/jpcx/deep-props.get/blob/0.1.0/CHANGELOG.md).
Versioned using [SemVer](http://semver.org/). For available versions, see the [Changelog](https://github.com/jpcx/deep-props.get/blob/0.1.1/CHANGELOG.md).

@@ -183,6 +257,6 @@ ## Contribution

* **Justin Collier** - [jpcx](https://github.com/jpcx)
+ **Justin Collier** - [jpcx](https://github.com/jpcx)
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/jpcx/deep-props.get/blob/0.1.0/LICENSE) file for details
This project is licensed under the MIT License - see the [LICENSE](https://github.com/jpcx/deep-props.get/blob/0.1.1/LICENSE) file for details
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