@robert.tools/eleventy-filter-by-prop
v1.0.0
Published
Get all items with a specific prop.
Maintainers
Readme
🗂️ @robert.tools/eleventy-filter-by-prop
Get all items with a specific prop.
📜 Usage
🟢 Installation
npm install @robert.tools/eleventy-filter-by-prop📝 Sample usage
import byProp from '@robert.tools/eleventy-filter-by-prop';📜 Usage
{{ [{ type: 'ok'}] | byProp('type', 'ok') }} {# result: [{ type: 'ok'}] #}
{{ [{ type: 'ok'}] | byProp('type', 'fail') }} {# result: [] #}
// invert: everything which does not match the value
{{ [{ type: 'ok'}] | byProp('type', 'fail', true) }} {# result: [{ type: 'ok'}] #}
// use objects
{{ { a: { type: 'ok'} , b: { type: 'fail'} } | byProp('type', 'ok') }} {# result: [{ type: 'ok'}] #}
// everything with property 'type'
{{ [{ type: 'ok'}, { foo: 2 }] | byProp('type') }} {# result: [{ type: 'ok'}] #}🗃️ commands
After an npm install with npm i the following commands are available:
- initialize placeholders:
npm run init <semantic> - release a new version:
npm run release <semantic>
⚖️ Notes
This software is hand-crafted, test-driven and assisted by AI tools. I know each line of my code. ✌️
| Tool | Comment | | ------------- | ------------- | | | Test-driven development with Jest | | | Part of the robert.tools ecosystem | | | Code completion | | | chatGPT research |
