Comparing version 1.0.0-alpha2 to 1.0.0-alpha3
{ | ||
"name": "quizas", | ||
"version": "1.0.0-alpha2", | ||
"version": "1.0.0-alpha3", | ||
"description": "A sort-of monad for reading values from objects", | ||
"main": "index.js", | ||
"main": "src/quizas", | ||
"directories": { | ||
@@ -7,0 +7,0 @@ "test": "test" |
# quizas | ||
A sort-of monad thing for reading objects | ||
A sort-of [Moand](https://en.wikipedia.org/wiki/Monad_(functional_programming)) type thing for reading objects. Bascially a way to avoid doing a ton if `if` statements to check the data is the way you expect it to be before using it. Quizas will endevaour to do these checks for you and return something without errors. | ||
## Installation | ||
npm i --save quizas | ||
## Usage | ||
### Get value | ||
``` | ||
quizas(obj, 'path.to.value').value; | ||
``` | ||
### Check if value exists | ||
``` | ||
quizas(obj, 'path.to.value').hasValue; | ||
``` | ||
### Grab nth item in array | ||
As it's javascript you can just pass the index and it will magically just work | ||
``` | ||
quizas(obj, 'array.4.value').value; | ||
``` | ||
### Loop through array, grabbing the props you need | ||
``` | ||
quizas(obj, 'path.to.array').pluck('foo', 'bar', 'deeply.nested.property'); | ||
``` | ||
### Loop through array, renaming the props to something better | ||
``` | ||
quizas(obj, 'path.to.array').pluck(['foo', 'name'], ['bar', 'email'], ['deeply.nested.property', 'flattened']); | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38
376704
10