https://github.com/jednano/truthy-keys
Creates an array of the own enumerable property names of an object for which the values are truthy.
https://github.com/jednano/truthy-keys
keys npm-package object truthy
Last synced: 16 days ago
JSON representation
Creates an array of the own enumerable property names of an object for which the values are truthy.
- Host: GitHub
- URL: https://github.com/jednano/truthy-keys
- Owner: jednano
- License: mit
- Created: 2017-09-29T17:06:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-22T04:19:54.000Z (over 7 years ago)
- Last Synced: 2024-12-28T12:43:35.174Z (10 months ago)
- Topics: keys, npm-package, object, truthy
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/truthy-keys
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# truthy-keys
[](https://www.npmjs.org/package/truthy-keys)
[](https://www.npmjs.org/package/truthy-keys)
[](https://travis-ci.org/jedmao/truthy-keys)
[](https://gemnasium.com/github.com/jedmao/truthy-keys)[](https://nodei.co/npm/truthy-keys/)
Creates an array of the own enumerable property names of an object for which the values are truthy.
## Installation
```
$ npm install truthy-keys
```## Usage examples
```ts
truthyKeys({ foo: true, bar: false });
// ["foo"]truthyKeys('foo');
// ["0", "1", "2"]truthyKeys(/* any falsey value */);
// []truthyKeys(42);
// []
```See [the tests](https://github.com/jedmao/truthy-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.