Skip to content

Commit

Permalink
removed the _ as key option, since the spread operator (...object) works
Browse files Browse the repository at this point in the history
much better, this keeps the complexity down.
Added docblocks and removed tabs
  • Loading branch information
poef committed Sep 7, 2023
1 parent 79908ea commit 403bd37
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 220 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.nyc_output
package-lock.json
*~
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,20 @@ from(data)
})
```

There is a special key value '\_', that means that you want to promote the values of the filter object on the right hand, to its parent object. This allows you to something like this:
You can also use the spread operator to include different fragments, like this:

```javascript
const names = {
name: _,
lastName: _
}

from(data)
.select({
_: names,
...names,
foo: 'bar'
})
```

Using the '\_' key, you can now create reusable fragments, like in GraphQL, and merge the results into one result object.

<a name="where"></a>
### where()

Expand Down Expand Up @@ -309,7 +306,6 @@ from(data)
})
```


<a name="contributions"></a>
## Contributions

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "array-where-select",
"version": "0.3.3",
"version": "0.4.0",
"description": "Allows GraphQL-like functionality on Javascript arrays of objects.",
"type": "module",
"author": "Auke van Slooten <[email protected]>",
Expand All @@ -24,6 +24,7 @@
"url": "https://github.com/muze-nl/array-where-select.git"
},
"devDependencies": {
"eslint": "^8.48.0",
"tap": "~16.3.7"
}
}
Loading

0 comments on commit 403bd37

Please sign in to comment.