protean

An ever changing set of utilities.

Protean

An ever changing set of utilities.

% npm install protean
Protean Falcor ## Classes CollectionSourceProteanClass CompositeSourceProteanClass JSONGraphEnvelopeProxyProteanClass NoCacheSourceProteanClass PartitionedSourceProteanClass ProxiedSourceProteanClass StorageSourceProteanClass ProteanClass : function StorageProteanClass StoreProteanClass CollectionProteanClass FiniteStateMachineSubject LinkedListProteanClass RecordProteanClass ## Typedefs onNextFunction : function onErrorFunction : function onCompletedFunction : function Observable Observer Disposable SubjectObservable DataSource Sentinel : Object Reference : Sentinel RootReference : Reference Atom : Sentinel JSONEnvelope : Object JSONGraph : Object JSONGraphEnvelope : Object Key : String | null KeySet : Key | Range | Array.<(Key|Range)> Path : Array.<Key> PathSet : Array.<KeySet> PathValue : Object Range : Object ## Protean

Kind: static property of Protean

Kind: static property of Rx

Param Type
filepath String
data Buffer | String
[opts] Object | String

Rx.mvObservable.<String>

File: rx/fs/mv.js

Kind: static property of Rx

Param Type Default
from String
to String
opts Object
[opts.mkdirp] Boolean false
[opts.clobber] Boolean false

Kind: static property of Rx

Param Type
method String

Kind: static property of Rx

Param Type
filepath String
data Buffer | String
[opts] Object | String

Rx.from(arg) ⇒ Observable

File: rx/from.js

Kind: static method of Rx

Param Type
arg Observable | Promise | Array | Object

File: rx/fs/cp.js

Kind: static method of Rx

Param Type Default
from String | Array.<String> | Observable.<String> | Promise.<String>
to String
[opts] Object
[opts.recursive] Boolean true
[opts.force] Boolean false

File: rx/glob.js

Kind: static method of Rx
Returns: Observable.<String> - An Observable emiting the paths found

Param Type Description
pattern String The glob pattern
[opts] Object https://github.com/isaacs/node-glob#options

File: rx/is-directory.js

Kind: static method of Rx
Returns: Observable.<Boolean> - An Observable emiting the paths found

Param Type
paths String | Array.<String> | Observable.<String>

File: rx/is-file.js

Kind: static method of Rx

Param Type
paths String | Array.<String> | Observable.<String>

Create the given paths in the file system.

File: rx/mkdir.js

Kind: static method of Rx

Param Type Default
paths String | Array.<String> | Observable.<String>
[opts] Object
[opts.mode] String '0777'

File: rx/read.js

Kind: static method of Rx

Param Type
patterns String | Array.<String> | Observable.<String> | Promise.<String>
[enc] String

File: rx/rm.js

Kind: static method of Rx

Param Type Default
patterns String | Array.<String> | Observable.<String> | Promise.<String>
[recursive] Boolean true

File: rx/stat.js

Kind: static method of Rx
Returns: Observable.<external:fs.Stats> - An Observable emiting the paths found

Param Type
patterns String | Array.<String> | Observable.<String> | Promise.<String>

Kind: static method of stat

Param Type
patterns String | Array.<String> | Observable.<String> | Promise.<String>

Kind: static method of stat

Param Type
fds Integer | Array.<Integer> | Observable.<Integer> | Promise.<Integer>

Kind: static property of Protean
Returns: Object - The object now with a immutable 'name' property of the given name value

Param Type
obj Object
name String

Kind: static property of Protean

Param Type
property String
subject Object

File: object/pluck.js

Kind: static property of Protean

Param Type
key String
[obj] Object

Utility function to get a className string.

Supply a list of strings, or objects with class names -> boolean indicating whether that class should be used. The returned string will contain all the class names indicated without duplicates, and separated by spaces.

File: dom/classnames.js

Kind: static method of Protean

Param Type
arg String | Object.<String, Boolean>

Protean.classify([subclass], props, [properties]) ⇒ ProteanClass

Create a constructor function passing in it's prototype methods.

File: function/classify

Kind: static method of Protean

Param Type Description
[subclass] function The subclass constructor function.
props Object Bare properties for the constructor's prototype.
[properties] Object Object.defineProperty property definitions.

Protean.inherit(superclass, [subclass], [props], [properties]) ⇒ ProteanClass

Create a constructor function that inherits properties and methods from the given super constructor.

File: function/inherit.js

Kind: static method of Protean
Returns: ProteanClass - The constructor function.

Param Type Default Description
superclass function The function to inherit from.
[subclass] function Function The Subclass constructor function. If omitted, and a constructor property is not defined in props, defaults to a function that calls the superclass' constructor function.
[props] Object Bare properties to initialize the prototype with.
[properties] Object {} Object.defineProperty property definitions.

Create a new object and then apply the constructor function with the arguments.

File: function/instantiate.js

Kind: static method of Protean
Returns: Object - The new instance

Param Type Description
fn function The constructor function
[args] Array.<Mixed> Arguments to pass to the constructor function

Like 'extend', but it preserves getters and setters, and will not overwrite existing properties defined directly on the source object.

File: object/augment.js

Kind: static method of Protean

Param Type
...obj Object

Takes a list of alternating key/values and returns an object.

File: object/enmap.js

Kind: static method of Protean

Param Type
...args Mixed

Takes an argument list of strings and returns an object with those keys, and their values being the index of that key plus one.

File: object/enumerate.js

Kind: static method of Protean

Type
String

Protean.traverse(obj, visitor, [post])

Kind: static method of Protean

Param Type Default Description
obj Object
visitor visitorFn
[post] Boolean false Do a post traversal

Kind: static constant of traverse

Kind: static constant of traverse

Kind: static constant of traverse

File: object/traverse.js

Kind: inner method of traverse
Returns: undefined | String - One of the constants of 'skip', 'continue', or 'break'. Returning undefined is the same as returing 'continue'.

Param Type Description
path Array.<String> The path to the value
value Mixed The value
context Object The original object

Fast GUID generator, RFC4122 version 4 compliant.

File: utility/guid.js

Kind: static method of Protean
See: http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
Author: Jeff Ward (jcward.com).
License: MIT license

File: utility/merge-exports.js

Kind: static method of Protean

Param Type
receiver Object
supplier function | Object

File: falcor/graph.js

Kind: static property of Falcor
See: https://github.com/Netflix/falcor-json-graph

File: falcor/graph/set.js

Kind: static property of Graph

Param Type
source Object
path String | Array.<String>
value *

File: falcor/graph/atoms.js

Kind: static method of Graph

Param Type
graph JSONGraph
fn Graph.atoms~visitorFn

Kind: inner method of atoms

Param Type
path Path
atom Atom
graph JSONGraph

Graph.fromObject(obj, [opts]) ⇒ JSONGraph

Takes a normal javascript object and returns a JSONGraph.

File: falcor/graph/from-object.js

Kind: static method of Graph

Param Type Default
obj Object
[opts] Object
[opts.arrayIsRef] Boolean true
[opts.root] Path []

File: falcor/graph/is-atom.js

Kind: static method of Graph

Param Type
sentinel *

File: falcor/graph/is-error.js

Kind: static method of Graph

Param Type
sentinel *

File: falcor/graph/is-ref.js

Kind: static method of Graph

Param Type
sentinel *

File: falcor/graph/is-root-ref.js

Kind: static method of Graph

Param Type
sentinel *

File: falcor/graph/is-sentinel.js

Kind: static method of Graph

Param Type
sentinel *

File: falcor/graph/refs.js

Kind: static method of Graph

Param Type
graph JSONGraph
fn Graph.atoms~visitorFn

Kind: inner method of refs

Param Type
path Path
ref Reference
graph JSONGraph

Graph.relative(root, graph) ⇒ JSONGraph

File: falcor/graph/relative.js

Kind: static method of Graph

Param Type
root Path
graph JSONGraph

Graph.resolve(root, graph) ⇒ JSONGraph

File: falcor/graph/resolve.js

Kind: static method of Graph

Param Type
root Path
graph JSONGraph

Graph.rootRef(path, value, props) ⇒ Reference

File: falcor/graph/root-ref.js

Kind: static method of Graph

Param Type
path Path
value Path
props Object

File: falcor/graph/sentinels.js

Kind: static method of Graph

Param Type
graph JSONGraph
fn Graph.sentinels~visitorFn

Kind: inner method of sentinels

Param Type
path Path
sentinel Sentinel
graph JSONGraph

Graph.toObject(graph, [opts]) ⇒ JSONGraph

Takes a JSONGraph and returns a Javascript Object.

File: falcor/graph/to-object.js

Kind: static method of Graph

Param Type
graph JSONGraph
[opts] Object

Kind: static property of Falcor
See: https://github.com/Netflix/falcor-path-utils

Path.relative(root, paths) ⇒ Array.<PathSet>

File: falcor/path/relative.js

Kind: static method of Path

Param Type
root Path
paths Array.<PathSet>

Path.resolve(root, paths) ⇒ Array.<PathSet>

File: falcor/path/resolve.js

Kind: static method of Path

Param Type
root Path
paths Array.<PathSet>

CollectionSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource

file: falcor/data-source/collection.js

Param Type Default
[collection] Collection
[opts] Object
[opts.indexedPath] Path ['byIndex']
[opts.keyedPath] Path ['byId']

Default options

Kind: instance property of CollectionSource
Properties

Type
Object

Kind: static property of options
Properties

Type
Path

Kind: static property of options
Properties

Type
Path

Kind: static property of options
Properties

Type
Path

Kind: static property of options
Properties

Type
Path

Kind: static property of options
Properties

Type
Path

Kind: instance property of CollectionSource
See: http://netflix.github.io/falcor/documentation/router.html
Properties

Type
external:FalcorRouter

Kind: instance property of CollectionSource
Properties

Type
Array.<Object>

collectionSource.get(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource
Implements: get

Param Type
paths Array.<PathSet>

collectionSource.set(envelope) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource
Implements: set

Param Type
envelope JSONGraphEnvelope

collectionSource.call(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource
Implements: call

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

collectionSource.getLength() ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

collectionSource.getRecordByIndex(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

Param Type
paths Array.<PathSets>

collectionSource.getRecordProps(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

Param Type
paths Array.<PathSets>

collectionSource.setRecordProps(graph) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

Param Type
graph JSONGraph

collectionSource.addRecord(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

collectionSource.removeRecord(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CollectionSource

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

CompositeSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource

A DataSource that allows for composing several different DataSources together through different Paths.

This allows individual DataSources to be constructed, used, and tested in their own domain. Then later you can compose them into a larger Graph.

The CompositeSource manages the re-writing of Paths and the resulting Graph so it appears that everything comes from a larger Graph.

Basically, all returned Paths/Graphs are updated to have any references relative to their Paths in the CompositeSource.

As a result, there was a need to create a new Falcor data type to express when a sub DataSource wanted to reference another part of the larger Graph. RootReference represents a Reference in the Graph that should not be kept local to the underlying DataSource, but should be interpreted from the root of the CompositeSource.

File: falcor/data-source/composite.js

Param Type
...args Array.<Path, DataSource>

Kind: instance property of CompositeSource
Properties

Type
Object.<Path, ProxiedSource>

compositeSource.get(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CompositeSource
Implements: get

Param Type
paths Array.<PathSets>

compositeSource.set(envelope) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CompositeSource
Implements: set

Param Type
envelope JSONGraphEnvelope

compositeSource.call(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of CompositeSource
Implements: call

Param Type
path Path
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

compositeSource.add(path, source) ⇒ CompositeSource

Kind: instance method of CompositeSource
Returns: CompositeSource - the CompositeSource instance

Param Type
path Path
source DataSource

JSONGraphEnvelopeProxy ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: JSONGraphEnevelope

Param Type Description
[opts] Object
[opts.expect] Array.<PathSet> Paths to expect
[opts.paths] Array.<PathSet> A starting set of paths
[opts.jsonGraph] JSONGraph A starting JSONGraph
[opts.invalidated] Array.<PathSet> A starting set of paths to invalidate

Kind: instance property of JSONGraphEnvelopeProxy
Properties

Type
Array.<PathSet>

Kind: instance property of JSONGraphEnvelopeProxy
Properties

Type
JSONGraph

Kind: instance property of JSONGraphEnvelopeProxy
Properties

Type
Array.<PathSet>

Kind: instance property of JSONGraphEnvelopeProxy
Properties

Type
Object

Get a list of paths this envelope is still expecting to fulfill

Kind: instance property of JSONGraphEnvelopeProxy
Read only: true
Properties

Type
Array.<Path>

Kind: instance method of JSONGraphEnvelopeProxy

Param Type
pathOrGraph Path | JSONGraph
[atom] Atom

Kind: instance method of JSONGraphEnvelopeProxy

Param Type
...path Path

Mark a path as fulfilled and set the given value on our jsonGraph

Kind: instance method of JSONGraphEnvelopeProxy

Param Type
path Path

Prepare this envelope to expect to fulfill a certain set of paths.

Kind: instance method of JSONGraphEnvelopeProxy

Param Type
paths Array.<PathSet>

jsonGraphEnvelopeProxy.relativeFrom(from) ⇒ JSONGraphEnvelopeProxy

Kind: instance method of JSONGraphEnvelopeProxy
Returns: JSONGraphEnvelopeProxy - A copy

Param Type
from Path

jsonGraphEnvelopeProxy.resolvedFrom(from) ⇒ JSONGraphEnvelopeProxy

Kind: instance method of JSONGraphEnvelopeProxy
Returns: JSONGraphEnvelopeProxy - A copy

Param Type
from Path

Merge another JSONGraphEnvelope into this one

Kind: instance method of JSONGraphEnvelopeProxy

Param Type
other JSONGraphEnvelopeProxy | JSONGraphEnvelope

Clear out our data so we do not have any dangling memory.

Kind: instance method of JSONGraphEnvelopeProxy

jsonGraphEnvelopeProxy.clone() ⇒ JSONGraphEnvelopeProxy

Get a copy of this proxy

Kind: instance method of JSONGraphEnvelopeProxy

jsonGraphEnvelopeProxy.valueOf() ⇒ JSONGraphEnvelope

Kind: instance method of JSONGraphEnvelopeProxy

jsonGraphEnvelopeProxy.finalize() ⇒ JSONGraphEnvelope

Kind: instance method of JSONGraphEnvelopeProxy

NoCacheSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource

A Falcor DataSource that proxies another data source and sets all returned atoms to expire immediately.

file: falcor/data-source/no-cache.js

Param Type
opts Object
opts.source DataSource

noCacheSource.get(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of NoCacheSource
Implements: get

Param Type
paths Array.<PathSets>

noCacheSource.set(envelope) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of NoCacheSource
Implements: set

Param Type
envelope JSONGraphEnvelope

noCacheSource.call(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of NoCacheSource
Implements: call

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

PartitionedSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource

A falcor DataSource that optionally reads from and writes to a variety of 'partitions' of other DataSources.

When reading (get) it will try the partitions in the order set by the 'reads' option. Any paths gone unfilled by the first, will be requested by the second, and so on. The final graph is a merge of all returned values from those partitions.

When writing (set/call) it will send the request to all given partitions in the 'writes' option. Again, returning a merged graph of all values writen.

Param Type Default
[opts] Object
[opts.reads] Array.<String> []
[opts.writes] Array.<String> []
[opts.partitions] Object.<String, DataSource> {}

Default options

Kind: instance property of PartitionedSource
Properties

Type
Object

Kind: static property of options
Properties

Type
Array.<String>

Kind: static property of options
Properties

Type
Array.<String>

Kind: static property of options
Properties

Type
Object.<String, DataSource>

partitionedSource.get(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of PartitionedSource
Implements: get

Param Type
paths Array.<PathSet>

partitionedSource.set(envelope) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of PartitionedSource
Implements: set

Param Type
envelope JSONGraphEnvelope

partitionedSource.call(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of PartitionedSource
Implements: call

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

ProxiedSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource

A Falcor DataSource that proxies to another source, re-writing the returned paths, and the paths to the values within the JSONGraph.

File: falcor/data-source/proxied.js

Param Type
[opts] Object
[opts.source] DataSource
[opts.root] Path

Kind: instance property of ProxiedSource
Properties

Type
DataSource

Kind: instance property of ProxiedSource
Properties

Type
Path

proxiedSource.get(paths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of ProxiedSource
Implements: get

Param Type
paths Array.<PathSets>

proxiedSource.set(envelope) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of ProxiedSource
Implements: set

Param Type
envelope JSONGraphEnvelope

proxiedSource.call(path, args, refSuffixes, thisPaths) ⇒ Observable.<JSONGraphEnvelope>

Kind: instance method of ProxiedSource
Implements: call

Param Type
path PathSet
args Array.<Mixed>
refSuffixes Array.<PathSet>
thisPaths Array.<PathSet>

Will the given paths be consumed by a get request against this datasource?

Kind: instance method of ProxiedSource

Param Type
paths Array.<PathSet>

Will the given JSONGraphEnvelope be consumed by a set request against this datasource?

Kind: instance method of ProxiedSource

Param Type
envelope JSONGraphEnvelope

Will the given path be consumed by a call request against this datasource?

Kind: instance method of ProxiedSource

Param Type
path Path

proxiedSource.getRelativeEnvelope(envelope) ⇒ JSONGraphEnvelope

Strip our leading path from the envelope's path(s) and jsonGraph object.

Kind: instance method of ProxiedSource

Param Type
envelope JSONGraphEnvelope

proxiedSource.getResolvedEnvelope(envelope) ⇒ JSONGraphEnvelope

Adjust the JSONGraphEnvelope to reflect our leading path information.

Kind: instance method of ProxiedSource

Param Type
envelope JSONGraphEnvelope

StorageSource ⇐ ProteanClass

Kind: global class
Extends: ProteanClass
Implements: DataSource