falcor-shapes
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,6 @@ | ||
# 1.0.1 (2015-08-23) | ||
* add travis-ci | ||
* update readme | ||
# 1.0.0 (2015-08-23) | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "falcor-shapes", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "object-based falcor pathset generator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# falcor-shapes | ||
falcor-shapes is a convenience function for [falcor paths](http://netflix.github.io/falcor/documentation/paths.html). | ||
falcor-shapes is a convenience function for generating [Falcor](http://netflix.github.io/falcor/) | ||
[PathSets](http://netflix.github.io/falcor/documentation/paths.html). | ||
It converts a "Shape" into an array of falcor PathSets. | ||
It converts a "Shape" into an array of Falcor PathSets. | ||
@@ -45,11 +46,15 @@ For example: | ||
## Shape documentation | ||
It also allows you to split up the list of what fields you need across multiple files (similar to GraphQL/Relay in React). | ||
A shape is a recursive structure. Each shape is a JavaScript object with keys and values. | ||
## What is a "Shape"? | ||
`{ <key>:true }` is a leaf value, and becomes the path `[ '<key>' ]` | ||
`$` is a special key that expects an array: `{ $: [ <range>, <subtree> ] }` and becomes `[ <range>, <subtree> ]` | ||
A shape is a recursive structure that resembles the JavaScript structure you're expecting. Shapes are simply JavaScript | ||
objects with keys and values. If a value is a nested JavaScript object, it will be expanded into multiple PathSets. | ||
Examples: | ||
* `{ <key>: true }` is a leaf value, and becomes the path `[ '<key>' ]` | ||
* `{ <key>: <Shape> }` recurses | ||
* `$` is a special key that expects an array: `{ $: [ <range>, <Shape> ] }` and becomes `[ <range>, <Shape> ]` | ||
Example: | ||
```js | ||
@@ -82,2 +87,4 @@ { | ||
See more examples in [test/test.js](test/test.js). | ||
## Usage | ||
@@ -106,9 +113,12 @@ | ||
model.get.apply(model, sets).then( ... ) | ||
``` | ||
// We can make a helper function to simplify this: | ||
function getShape(model, shape) { | ||
We can make a helper function to simplify this: | ||
```js | ||
function getWithShape(shape) { | ||
return model.get.apply(model, shape) | ||
} | ||
getShape(model, { | ||
getWithShape({ | ||
people: { | ||
@@ -145,3 +155,3 @@ length: true, | ||
Feel free to submit PRs! | ||
Feel free to submit pull requests! | ||
@@ -148,0 +158,0 @@ ## License |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33311
18
156
1