Comparing version 0.1.0 to 0.1.1
10
index.js
@@ -12,2 +12,6 @@ /*! | ||
function isValidKey(key) { | ||
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype'; | ||
} | ||
/** | ||
@@ -44,7 +48,9 @@ * Defines a getter function on an object using property path notation. | ||
if (!~prop.indexOf('.')) { | ||
defineProperty(obj, prop, getter); | ||
if (isValidKey(prop)) { | ||
defineProperty(obj, prop, getter); | ||
} | ||
return obj; | ||
} | ||
var keys = prop.split('.'); | ||
var keys = prop.split('.').filter(isValidKey); | ||
var last = keys.pop(); | ||
@@ -51,0 +57,0 @@ var target = obj; |
{ | ||
"name": "set-getter", | ||
"description": "Create nested getter properties and any intermediary dot notation (`'a.b.c'`) paths", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/doowb/set-getter", | ||
@@ -6,0 +6,0 @@ "author": "Brian Woodward (https://github.com/doowb)", |
@@ -1,5 +0,7 @@ | ||
# set-getter [](https://www.npmjs.com/package/set-getter) [](https://npmjs.org/package/set-getter) [](https://travis-ci.org/doowb/set-getter) | ||
# set-getter [](https://www.npmjs.com/package/set-getter) [](https://npmjs.org/package/set-getter) [](https://npmjs.org/package/set-getter) [](https://travis-ci.org/doowb/set-getter) | ||
> Create nested getter properties and any intermediary dot notation (`'a.b.c'`) paths | ||
Please consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support. | ||
## Install | ||
@@ -10,3 +12,3 @@ | ||
```sh | ||
$ npm install set-getter --save | ||
$ npm install --save set-getter | ||
``` | ||
@@ -51,3 +53,3 @@ | ||
### [setGetter](index.js#L27) | ||
### [setGetter](index.js#L31) | ||
@@ -71,42 +73,50 @@ Defines a getter function on an object using property path notation. | ||
## Contributing | ||
## About | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/set-getter/issues/new). | ||
<details> | ||
<summary><strong>Contributing</strong></summary> | ||
## Building docs | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
</details> | ||
```sh | ||
$ npm install verb && npm run docs | ||
``` | ||
<details> | ||
<summary><strong>Running Tests</strong></summary> | ||
Or, if [verb](https://github.com/verbose/verb) is installed globally: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ verb | ||
$ npm install && npm test | ||
``` | ||
## Running tests | ||
</details> | ||
Install dev dependencies: | ||
<details> | ||
<summary><strong>Building docs</strong></summary> | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
## Author | ||
</details> | ||
### Author | ||
**Brian Woodward** | ||
* [github/doowb](https://github.com/doowb) | ||
* [twitter/doowb](http://twitter.com/doowb) | ||
* [GitHub Profile](https://github.com/doowb) | ||
* [Twitter Profile](https://twitter.com/doowb) | ||
* [LinkedIn Profile](https://linkedin.com/in/woodwardbrian) | ||
## License | ||
### License | ||
Copyright © 2016, [Brian Woodward](https://github.com/doowb). | ||
Released under the [MIT license](https://github.com/doowb/set-getter/blob/master/LICENSE). | ||
Copyright © 2021, [Brian Woodward](https://github.com/doowb). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 29, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on June 18, 2021._ |
7420
75
119