https://github.com/jednano/truthy-strings-keys
Filters an array, keeping only truthy string values.
https://github.com/jednano/truthy-strings-keys
array filter npm-package strings truthy
Last synced: about 1 month ago
JSON representation
Filters an array, keeping only truthy string values.
- Host: GitHub
- URL: https://github.com/jednano/truthy-strings-keys
- Owner: jednano
- License: mit
- Created: 2017-09-29T20:43:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-22T04:44:33.000Z (over 7 years ago)
- Last Synced: 2025-08-09T17:54:53.970Z (about 2 months ago)
- Topics: array, filter, npm-package, strings, truthy
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/truthy-strings-keys
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# truthy-strings-keys
[](https://www.npmjs.org/package/truthy-strings-keys)
[](https://www.npmjs.org/package/truthy-strings-keys)
[](https://travis-ci.org/jedmao/truthy-strings-keys)
[](https://gemnasium.com/github.com/jedmao/truthy-strings-keys)[](https://nodei.co/npm/truthy-strings-keys/)
Resolves a simple string or a potentially deeply nested structure of primitive
values into a simple string array.## Installation
```
$ npm install truthy-strings-keys
```## Usage
### `truthyStringsKeys( deepArray [, options] )`
```ts
const deepArray = [
'foo', [
{
bar: true,
baz: null,
},
],
'foo',
'qux',
[
[
[
{
corge: undefined,
garpley: -1,
},
],
],
],
];truthyStringsKeys(deepArray);
// ["foo", "bar", "foo", "qux", "garpley"]truthyStringsKeys(deepArray, { unique: true });
// ["foo", "bar", "qux", "garpley"]
```See [the tests](https://github.com/jedmao/truthy-strings-keys/blob/master/src/index.test.ts).
## Testing
Run the following command:
```
$ npm test
```This will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.
### Watching
For much faster development cycles, run the following commands in 2 separate processes:
```
$ npm run build:watch
```Compiles TypeScript source into the `./dist` folder and watches for changes.
```
$ npm run watch
```Runs the tests in the `./dist` folder and watches for changes.