@smakss/search
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@smakss/search", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Search through array and/or objects for sepcific keyword.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -20,3 +20,3 @@ # UUID | ||
``` | ||
var search = require('@smakss/search'); | ||
var Search = require('@smakss/search'); | ||
``` | ||
@@ -27,3 +27,3 @@ | ||
``` | ||
import search from '@smakss/search'; | ||
import Search from '@smakss/search'; | ||
``` | ||
@@ -38,3 +38,3 @@ | ||
- `keys` (`Array`): Keys to include or exclude in your object items. If you exclude them it will exclude them from search and search won't perform on those specific keys. And if you include them search will only perform on those desired keys and it will ignore others. | ||
- `include` (`Boolean`): A flag to determine whether the `keys` are included or excluded. | ||
- `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. | ||
@@ -48,3 +48,3 @@ ## Examples of usage | ||
search({ searchText: "john", searchItems: array }); | ||
Search({ searchText: "john", searchItems: array }); | ||
@@ -61,3 +61,3 @@ // Result: [{ lastName: "Doe", name: "John" }] | ||
search({ searchText: "john", searchItems: arr }); | ||
Search({ searchText: "john", searchItems: arr }); | ||
@@ -75,3 +75,3 @@ // Result: [{ lastName: "Doe", name: "John" }] | ||
search({ searchText: "jane", searchItems: arr }); | ||
Search({ searchText: "jane", searchItems: arr }); | ||
@@ -81,4 +81,31 @@ // Result: [{ lastName: "Doe", name: "Jane" }] | ||
**Passing a nested array with including keys:** | ||
``` | ||
const arr = [ | ||
{ name: "John", lastName: "Doe" }, | ||
{ name: "Joe", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
]; | ||
Search({ searchText: "jane", searchItems: arr, keys: ['name'] }); | ||
// Result: [{ lastName: "Doe", name: "Jane" }] | ||
``` | ||
**Passing a nested array with excluding keys:** | ||
``` | ||
const arr = [ | ||
{ name: "John", lastName: "Doe" }, | ||
{ name: "Joe", lastName: "Doe" }, | ||
[{ name: "Jane", lastName: "Doe" }] | ||
]; | ||
Search({ searchText: "jane", searchItems: arr, keys: ['name'], include: false }); | ||
// Result: [] | ||
// The result will be an empty array when nothing matches with the provided params | ||
``` | ||
## Demo | ||
You can check the [working demo](https://runkit.com/smakss/search) in runkit. |
Sorry, the diff of this file is not supported yet
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
8113
104