object-grep
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "object-grep", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A javascript tool for searching text in keys and content inspired by linux grep", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
# object-grep | ||
[![Build Status](https://travis-ci.com/ulitcos/object-grep.svg?branch=master)](https://travis-ci.com/ulitcos/object-grep) | ||
A javascript tool for searching inside objects inspired by linux grep | ||
A javascript tool for searching inside objects inspired by linux grep. The tool performs deep searches in javascript | ||
objects, returning back lists of keys and values for which the search clause will be executed, this is especially useful | ||
when debugging. Regular expressions are used under the hood, so you can very flexibly customize your search terms | ||
@@ -11,3 +14,5 @@ ## installation | ||
``` | ||
or | ||
```bash | ||
@@ -19,7 +24,9 @@ yarn add object-grep | ||
**targetObject**: [`object` | `array` | `function` | `string`] - a target object where all keys and property contents will be recursively checked for matching searchExpr | ||
**targetObject**: [`object` | `array` | `function` | `string`] - a target object where all keys and property contents | ||
will be recursively checked for matching searchExpr | ||
**searchExpr**: [`string` | `regexp`] - expression for checking for compliance | ||
**depth limit**?: [`number`] - the number of levels to check. objectGrep works synchronously, which can cause the browser to freeze if the object being checked is very large. The default value is 100 | ||
**depth limit**?: [`number`] - the number of levels to check. objectGrep works synchronously, which can cause the | ||
browser to freeze if the object being checked is very large. The default value is 20 | ||
@@ -38,3 +45,3 @@ ## usage | ||
} | ||
} | ||
} | ||
} | ||
@@ -61,3 +68,6 @@ }, | ||
## short view | ||
You can also use a short output format. To do this, call the `short()` method on the result. This way you will only see paths to keys and values with no data stored on those paths | ||
You can also use a short output format. To do this, call the `short()` method on the result. This way you will only see | ||
paths to keys and values with no data stored on those paths | ||
```javascript | ||
@@ -73,3 +83,3 @@ const target = { | ||
} | ||
} | ||
} | ||
} | ||
@@ -97,3 +107,3 @@ }, | ||
It can be added to the object prototype | ||
It can be added to the object prototype. This way it will be possible to call grep from any object | ||
@@ -103,10 +113,36 @@ ```javascript | ||
const target = { a: { b : { c: 'd' } } } | ||
const target = {a: {b: {c: 'd'}}} | ||
target.grep('b') // => {keys: ['a.b']} | ||
target.grep('b') // => {inKeys: {a.b: {c: 'd'}}, inValues: {}} | ||
``` | ||
You can set any name for the method if you don't like grep | ||
```javascript | ||
objectGrep.inject('deepSearch') | ||
const target = {a: {b: {c: 'd'}}} | ||
target.deepSearch('b') // => {inKeys: {a.b: {c: 'd'}}, inValues: {}} | ||
``` | ||
## revoke | ||
To cancel injection use the revoke method. To cancel injection use the revoke method. Calling revoke will return the | ||
object prototype to its original form | ||
```javascript | ||
objectGrep.inject() | ||
Object.prototype.grep // => ƒ (regex, depth) {...} | ||
objectGrep.revoke() | ||
Object.prototype.grep // => undefined | ||
``` | ||
## chrome extension | ||
You can also install a [browser extension](https://github.com/ulitcos/object-grep-chrome-extension) and use object-grep on any site without any extra effort | ||
You can also install a [browser extension](https://github.com/ulitcos/object-grep-chrome-extension) and use object-grep | ||
on any site without any extra effort | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9776
142