Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

falcor-shapes

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

falcor-shapes - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.travis.yml

5

HISTORY.md

@@ -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 @@

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc