@smakss/search
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"name": "@smakss/search", | ||
"version": "1.2.3", | ||
"author": "SMAKSS", | ||
"bugs": { | ||
"url": "https://github.com/SMAKSS/search/issues" | ||
}, | ||
"description": "Search through array and/or objects for specific keyword.", | ||
"type": "module", | ||
"main": "./index.cjs", | ||
"exports": { | ||
@@ -11,6 +11,3 @@ "import": "./index.mjs", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SMAKSS/search.git" | ||
}, | ||
"homepage": "https://github.com/SMAKSS/search#readme", | ||
"keywords": [ | ||
@@ -30,8 +27,11 @@ "npm", | ||
], | ||
"author": "SMAKSS", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/SMAKSS/search/issues" | ||
"main": "./index.cjs", | ||
"name": "@smakss/search", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SMAKSS/search.git" | ||
}, | ||
"homepage": "https://github.com/SMAKSS/search#readme" | ||
"type": "module", | ||
"version": "1.2.4" | ||
} |
@@ -5,3 +5,3 @@ # Search | ||
Searching through arrays or objects might be easy these days with array helpers like [filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) or libraries like [_lodash](https://www.npmjs.com/package/lodash), but what if you want a lighter library and have a nested array of object and want to search into every key of your object with a specific keyword? This might be hard or frustrating sometimes, this package will help you to achieve search a keyword through each object key, array elements and/or nested arrays. Also, this package uses ES6+ syntax so if you using older standards for writing JS code you may need a transpiler for it. | ||
Searching through arrays or objects might be easy these days with array helpers like [filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) or libraries like [\_lodash](https://www.npmjs.com/package/lodash), but what if you want a lighter library and have a nested array of object and want to search into every key of your object with a specific keyword? This might be hard or frustrating sometimes, this package will help you to achieve search a keyword through each object key, array elements and/or nested arrays. Also, this package uses ES6+ syntax so if you using older standards for writing JS code you may need a transpiler for it. | ||
@@ -21,3 +21,3 @@ ## How it works? | ||
```js | ||
var Search = require('@smakss/search'); | ||
var Search = require("@smakss/search"); | ||
``` | ||
@@ -28,3 +28,3 @@ | ||
```js | ||
import Search from '@smakss/search'; | ||
import Search from "@smakss/search"; | ||
``` | ||
@@ -40,3 +40,3 @@ | ||
- `include` (`Boolean`): A flag to determine whether the `keys` are included or excluded. It will be `True` by default, which means the keys will be included. | ||
- `exact` (`Boolean`): A flag to determine whether the you are exactly looking for `searchText` string or not. It will be `False` by default, which means it will not looking for exact `searchText`. e. g. Let's say `searchText` is `5` so it will match all numbers where they include `5` *(`5`, `15`, `25`, ...)* otherwise it will only match `5` alone. This feature is only available in `v1.0.6+`. | ||
- `exact` (`Boolean`): A flag to determine whether the you are exactly looking for `searchText` string or not. It will be `False` by default, which means it will not looking for exact `searchText`. e. g. Let's say `searchText` is `5` so it will match all numbers where they include `5` _(`5`, `15`, `25`, ...)_ otherwise it will only match `5` alone. This feature is only available in `v1.0.6+`. | ||
@@ -62,3 +62,3 @@ ## Examples of usage | ||
{ name: "John", lastName: "Doe" }, | ||
{ name: "Joe", lastName: "Doe" } | ||
{ name: "Joe", lastName: "Doe" }, | ||
]; | ||
@@ -77,3 +77,3 @@ | ||
{ name: "Joe", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
[{ name: "Jane", lastName: "Doe" }], | ||
]; | ||
@@ -92,6 +92,6 @@ | ||
{ name: "Joe", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
[{ name: "Jane", lastName: "Doe" }], | ||
]; | ||
Search({ searchText: "jane", searchItems: arr, keys: ['name'] }); | ||
Search({ searchText: "jane", searchItems: arr, keys: ["name"] }); | ||
@@ -107,12 +107,18 @@ // Result: [{ lastName: "Doe", name: "Jane" }] | ||
{ name: "Joe", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
[{ name: "Jane", lastName: "Doe" }], | ||
]; | ||
Search({ searchText: "jane", searchItems: arr, keys: ['name'], include: false }); | ||
Search({ | ||
searchText: "jane", | ||
searchItems: arr, | ||
keys: ["name"], | ||
include: false, | ||
}); | ||
// Result: [] | ||
``` | ||
<sub>The result will be an empty array because we exclude the `name` key from the search so nothing will be matched with the provided params.</sub> | ||
### Passing a nested array with exact search | ||
### Passing a nested array with exact search | ||
@@ -125,3 +131,3 @@ <sub>(Only available in `v1.0.6+`)</sub> | ||
{ name: "Janet", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
[{ name: "Jane", lastName: "Doe" }], | ||
]; | ||
@@ -138,2 +144,6 @@ | ||
You can check the [working demo](https://runkit.com/smakss/5f738b7f464579001bfda2d0) in runkit. | ||
You can check the [working demo](https://runkit.com/smakss/5f738b7f464579001bfda2d0) in runkit. | ||
or | ||
[![View @smakss/search](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/smakss-search-zlqtu3?fontsize=14&hidenavigation=1&theme=dark) |
Sorry, the diff of this file is not supported yet
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
9988
140