npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webantic/util

v9.0.4

Published

A library of utility functions

Downloads

59

Readme

Modules

util/array

util/array~move(array, fromIndex, toIndex) ⇒ Array.<any>

Kind: inner method of util/array
Summary: moves an element at a given index to another index
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | an array containing the element to move | | fromIndex | number | the location of the element to move | | toIndex | number | the destination index |

util/array~addToSet(array, item) ⇒ Array.<any>

Kind: inner method of util/array
Summary: Returns an array containing item, adding it if it is missing. Note: this only uses indexOf for comparison, so it will not work for objects
Returns: Array.<any> - the new array
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | an array to potentially add item to | | item | any | an item to ensure is within array |

util/array~addToSetInPlace(set, item) ⇒ boolean

Kind: inner method of util/array
Summary: Adds item to set if it is missing, returns true if set was modified
Returns: boolean - true if set was modified
Export:

| Param | Type | Description | | --- | --- | --- | | set | Array.<any> | a set to potentially add item to | | item | any | an item to ensure is within set |

util/array~first(array) ⇒ any

Kind: inner method of util/array
Summary: returns the first element in an array
Returns: any - the first element of the array
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | the array to search in |

util/array~last(array) ⇒ any

Kind: inner method of util/array
Summary: returns the last element in an array
Returns: any - the last element of the array
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | the array to search in |

util/array~eachUntil(array, callback)

Kind: inner method of util/array
Summary: calls callback for each item in an array, provided that the previous iteration didn't return false
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | of items to iterate | | callback | ForEachCallback | the function to invoke for each element in the supplied array |

util/array~remove(array, item) ⇒ Array.<any>

Kind: inner method of util/array
Summary: Remove an item from an array
Returns: Array.<any> - The new array
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array to remove item from | | item | any | The item to remove. Cannot be an object |

Example

var array = ['a', 'b', 'c']
remove(array, 'b') // returns ['a', 'c']

util/array~removeAll(array, item) ⇒ Array.<any>

Kind: inner method of util/array
Summary: Removes all occurrences of item from array
Returns: Array.<any> - The new array
Export:

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array to remove all occurrences of item from | | item | any | The item to remove |

Example

var array = ['a', 'b', 'b', 'c']
removeAll(array, 'b') // returns ['a', 'c']

util/array~forceArray(input) ⇒ Array.<any>

Kind: inner method of util/array
Summary: wraps the input in an array if it isn't already one
Returns: Array.<any> - always an array

| Param | Type | | --- | --- | | input | any |

util/array~mapAsync(array, callback, onComplete)

Map an array's values, iterating asynchronously

Kind: inner method of util/array

| Param | Description | | --- | --- | | array | The array to map | | callback | A callback to receive the current element & index. Should return the new value | | onComplete | A callback which will be called when all elements have been processed |

util/array~forEachAsync(array, cb, onComplete)

Iterate the elements in an array, calling the user-supplied callback on each element asynchronously

Kind: inner method of util/array

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array to iterate | | cb | ArrayTypes.MapCallbackFunction | the callback to receive the element(s) | | onComplete | ArrayTypes.CallbackFunction | A callback to be called when all elements have been iterated |

util/blaze

util/blaze~attachAPI(blaze, API)

Attach a DDP connection to Blaze so that it is available in templates' this.subscribe

Kind: inner method of util/blaze

| Param | Type | Description | | --- | --- | --- | | blaze | Object | a reference to Blaze | | API | Object | The DDP connection to attachs |

util/blaze~onCountChanged(callback)

Add a function to get called when the count changes

Kind: inner method of util/blaze

| Param | Type | | --- | --- | | callback | function |

util/collection

util/collection~insert(collection, items) ⇒ ICollectionReturn

Kind: inner method of util/collection
Summary: Inserts a number of items into the given collection
Export:

| Param | Type | Description | | --- | --- | --- | | collection | Mongo.Collection | A Mongo.Collection | | items | Array.<object> | the items to insert. |

util/collection~update(collection, items) ⇒ ICollectionReturn

Kind: inner method of util/collection
Summary: Updates a number of items into the given collection
Export:

| Param | Type | Description | | --- | --- | --- | | collection | Mongo.Collection | A Mongo.Collection | | items | Array.<object> | the items to update. The _id field is used as a selector, the rest of the object as the modifier |

util/collection~remove(collection, _ids) ⇒ ICollectionReturn

Kind: inner method of util/collection
Summary: Remvoves a number of items by their _id from the given collection
Export:

| Param | Type | Description | | --- | --- | --- | | collection | Mongo.Collection | A Mongo.Collection | | _ids | Array.<string> | the _ids of the items to remove. |

util/collection~caseInsensitiveSelector(fieldName, str, [wordIsPrefix]) ⇒ Object

Kind: inner method of util/collection
Summary: Generates a selector for a field which will perform a case-insensitive lookup for the given value
Returns: Object - the Mongo selector object
Export:

| Param | Type | Default | Description | | --- | --- | --- | --- | | fieldName | string | | the name of the field to query | | str | string | | the value to query | | [wordIsPrefix] | boolean | false | whether the supplied value for str is a prefix or the whole query |

util/collection~selectorFromParams(selectorParams) ⇒ Object

Kind: inner method of util/collection
Summary: Parses "skip", "limit", "sort", "before" and "since" into a selector and options object
Returns: Object - The constructed selector & options objects
Export:

| Param | Type | Description | | --- | --- | --- | | selectorParams | ISelectorParams | An object containing any/all of the defined keys. "createdOrUpdated" can be either "createdAt" (default) or "updatedAt". It determines what "before" and "since" act upon |

util/collection~getObserverHandlers(context, collection) ⇒ IObserveHandlers

Kind: inner method of util/collection
Summary: Returns a map of default observe callback handlers
Returns: IObserveHandlers - The map of callback handlers
Export:

| Param | Type | Description | | --- | --- | --- | | context | any | The this context. It should contain added, changed and removed methods | | collection | string | The name of the collection to add/change/remove documents to/from |

util/collection~mapHelpersToThis(pureHelpers) ⇒ any

Takes an object of helpers and wraps them in functions that use the this context and pass it as the first arg. Allows thisless functions to be used as collection helpers

Kind: inner method of util/collection

| Param | Type | Description | | --- | --- | --- | | pureHelpers | any | helpers to map |

util/collection~IFailedOps : Object

Kind: inner typedef of util/collection
Properties

| Name | Type | Description | | --- | --- | --- | | code | number | the error code | | message | string | the error message | | additional | any | meta information about the error |

util/collection~ICollectionReturn : Object

Kind: inner typedef of util/collection
Properties

| Name | Type | Description | | --- | --- | --- | | success | boolean | Whether no operations failed | | failed | Array.<IFailedOps> | an array of objects detailling failed operations | | succeeded | Array.<(any|boolean)> | an array of objects detailling documents of successful operations |

util/collection~IObserveHandlers : Object

Kind: inner typedef of util/collection
Properties

| Name | Type | | --- | --- | | added | function | | changed | function | | removed | function |

util/collection~ISelectorParams : Object

Kind: inner typedef of util/collection
Properties

| Name | Type | Default | Description | | --- | --- | --- | --- | | [skip] | number | | A number indicating how many matching documents to skip | | [limit] | number | | A number indicating the maximum number of documents to return | | [sort] | Object.<number> | | An object whose keys equate to database column names and whose values are either 1 or -1 to indicate sort order | | [createdOrUpdated] | string | "&quot;createdAt&quot;" | | | [before] | Date | string | number | | A parsable representation of a date. Only documents whose createdAt or updatedAt (as defined by createdOrUpdated) are greater than the supplied value will be returned | | [since] | Date | string | number | | A parsable representation of a date. Only documents whose createdAt or updatedAt (as defined by createdOrUpdated) are less than the supplied value will be returned | | [fields] | Object.<number> | | An object whose keys equate to database column names and whose values are either 1 or 0 to indicate inclusion or exclusion |

util/config

util/config~Configuration

Kind: inner class of util/config

new Configuration(collection, Meteor, [Tracker], [connection])

A configuration class - provides a DB-backed, environment variable / meteor.settings populated set of config values

| Param | Type | Description | | --- | --- | --- | | collection | Mongo.Collection | the config collection | | Meteor | Object | a reference to the Meteor object | | [Tracker] | Object | an optional reference to Tracker - will be mocked in a non-reactive way if not supplied | | [connection] | Object | an optional override for the DDP connection to use to subscribe to the config pub |

util/config~StandaloneConfiguration

Kind: inner class of util/config

new StandaloneConfiguration()

A configuration class - provides an environment variable / codebase-populated set of config values

util/data

util/data~titles([flatten]) ⇒ Array.<object> | Array.<string>

Kind: inner method of util/data
Summary: provides a list of name titles
Returns: Array.<object> | Array.<string> - If flatten is true, an array of string values otherwise an array of objects with name and camelized value
Export:

| Param | Type | Default | Description | | --- | --- | --- | --- | | [flatten] | boolean | false | whether to return an array of plain text values |

util/data~genders([flatten]) ⇒ Array.<object> | Array.<string>

Kind: inner method of util/data
Summary: provides a list of genders
Returns: Array.<object> | Array.<string> - If flatten is true, an array of string values otherwise an array of objects with name and camelized value
Export:

| Param | Type | Default | Description | | --- | --- | --- | --- | | [flatten] | boolean | false | whether to return an array of plain text values |

util/data~maritalStatuses([flatten]) ⇒ Array.<object> | Array.<string>

Kind: inner method of util/data
Summary: provides a list of maritalStatuses
Returns: Array.<object> | Array.<string> - If flatten is true, an array of string values otherwise an array of objects with name and camelized value
Export:

| Param | Type | Default | Description | | --- | --- | --- | --- | | [flatten] | boolean | false | whether to return an array of plain text values |

util/data~nationalities([flatten]) ⇒ Array.<object> | Array.<string>

Kind: inner method of util/data
Summary: provides a list of nationalities
Returns: Array.<object> | Array.<string> - If flatten is true, an array of string values otherwise an array of objects with name and camelized value
Export:

| Param | Type | Default | Description | | --- | --- | --- | --- | | [flatten] | boolean | false | whether to return an array of plain text values |

util/date

util/date~randomBetween(from, to) ⇒ Date

Kind: inner method of util/date
Summary: gets a random date between two others
Returns: Date - the random date
Export:

| Param | Type | Description | | --- | --- | --- | | from | Date | random date must be greater than this | | to | Date | random date must be less than this |

util/date~getDate([startEnd], [prevNext], [interval]) ⇒ Date

Gets a Date object of a given offset from now

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Default | Description | | --- | --- | --- | --- | | [startEnd] | string | | Either 'start' or 'end' to round the date to the start or end of the day | | [prevNext] | string | "'prev'" | | | [interval] | string | "'day'" | |

util/date~yesterday([startEnd]) ⇒ Date

Return a Date object from 24 hours ago

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~tomorrow([startEnd]) ⇒ Date

Return a Date object for 24 hours in the future

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~lastWeek([startEnd]) ⇒ Date

Return a Date object from 7 days ago

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~nextWeek([startEnd]) ⇒ Date

Return a Date object for 7 days in the future

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~lastMonth([startEnd]) ⇒ Date

Return a Date object from 30 days ago

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~nextMonth([startEnd]) ⇒ Date

Return a Date object for 30 days in the future

Kind: inner method of util/date
Returns: Date - the date object

| Param | Type | Description | | --- | --- | --- | | [startEnd] | string | either 'start' or 'end' - determines whether to round the date to the start or end of the day |

util/date~getPreviousDay(day) ⇒ string

Can be passed either a full or three-letter day name and will return the previous day's name

Kind: inner method of util/date
Returns: string - the name of the previous day

| Param | Type | Description | | --- | --- | --- | | day | string | a full or three-letter day name |

util/date~getNextDay(day) ⇒ string

Can be passed either a full or three-letter day name and will return the next day's name

Kind: inner method of util/date
Returns: string - the name of the next day

| Param | Type | Description | | --- | --- | --- | | day | string | a full or three-letter day name |

util/emitter

util/emitter.MultiEmitter

Kind: static class of util/emitter
Export:

new MultiEmitter()

Slightly more advanced event emitter style class that allows listening to different events via string arguments

util/emitter.Emitter

Kind: static class of util/emitter
Export:

new Emitter()

Basic class that represents an event that can be listened to and broadcasted

util/emitter.MultiEmitter#listen(event, callback)

Add a callback to be ran whenver this event is broadcasted

Kind: static method of util/emitter

| Param | Description | | --- | --- | | event | the event as a string to be listened to | | callback | the callback to run whenever said event is triggered |

util/emitter.MultiEmitter#broadcast(event, value)

Broadcast an event of the given type

Kind: static method of util/emitter

| Param | Description | | --- | --- | | event | even type to broadcast | | value | value to be passed to each callback |

util/emitter.MultiEmitter#removeListeners(event)

Remove all attached listeners for a specific event type

Kind: static method of util/emitter

| Param | | --- | | event |

util/emitter.Emitter#listen()

Add a callback to be ran whenver this event is broadcasted

Kind: static method of util/emitter

util/emitter.Emitter#broadcast(value)

Calls all callbacks that have been registered with the given value

Kind: static method of util/emitter

| Param | Description | | --- | --- | | value | value to broadcast, if any |

util/emitter.Emitter#removeListeners()

Remove all attached listeners

Kind: static method of util/emitter

util/http

util/http~getBaseParameter([{ location, type, required }]) ⇒ Object

Kind: inner method of util/http
Summary: returns a basic Swagger parameter field
Export:

| Param | Type | Default | | --- | --- | --- | | [{ location, type, required }] | * | {} |

util/http~requiredBodyString(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a required body string parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~requiredBodyNumber(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a required body number parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~requiredBodyDate(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a required body string parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~requiredBodyBoolean(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a required body boolean parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~requiredBodyObject(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a required body object parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~optionalBodyString(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a optional body string parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~optionalBodyNumber(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a optional body number parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~optionalBodyDate(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a optional body string parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~optionalBodyBoolean(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a optional body boolean parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/http~optionalBodyObject(extendedDef) ⇒ Object

Kind: inner method of util/http
Summary: scaffolds a optional body object parameter
Export:

| Param | Type | Description | | --- | --- | --- | | extendedDef | Object | the rest of the definition |

util/image

util/image~dataURIToBlob(dataURI) ⇒ blob

Kind: inner method of util/image
Summary: converts a data uri to a blob://
Returns: blob - the uri as a blob
Export:

| Param | Type | Description | | --- | --- | --- | | dataURI | string | the data uri to convert into a blob |

util/image~toDataURI(file, callback)

Kind: inner method of util/image
Summary: converts an image file to a data uri
Export:

| Param | Type | Description | | --- | --- | --- | | file | File | the image file to convert | | callback | function | a function to receive the result of the conversion |

util/location

util/location~calculateDistance(lat1, lon1, lat2, lon2) ⇒ number

Kind: inner method of util/location
Summary: Get the distance in KM between two latitude/longitude pairs
Returns: number - The distance between the two points, in KM
Export:

| Param | Type | Description | | --- | --- | --- | | lat1 | number | The first latitude | | lon1 | number | The first longitude | | lat2 | number | The second latitude | | lon2 | number | The second longitude |

util/meteor

util/meteor~assert(assertion, errorCode, [meta])

Kind: inner method of util/meteor
Summary: if the assertion is falsey, throws an error
Export:

| Param | Type | Description | | --- | --- | --- | | assertion | any | anything that should be truthy to not throw an error | | errorCode | number | the error code | | [meta] | any | additional info to include with the error |

util/meteor~assertString(value, name)

Assert that the typeof ${value} is 'string'

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked |

util/meteor~assertBoolean(value, name)

Assert that the typeof ${value} is 'boolean'

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked |

util/meteor~assertNumber(value, name)

Assert that the typeof ${value} is 'number'

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked |

util/meteor~assertInt(value, name)

Assert that the ${value} is an integer

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked |

util/meteor~assertObject(value, name)

Assert that the typeof ${value} is 'object'

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked |

util/meteor~assertArray(value, name, type)

Assert that the ${value} is an array

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | name | the name of the value being checked | | type | the expected datatype of every item within the supposed array |

util/meteor~assertDate(value, options)

Assert that the typeof ${value} is 'Date'

Kind: inner method of util/meteor

| Param | Description | | --- | --- | | value | any value to check the type of | | options | whether to parse the date |

util/model

util/model~ModelDefinition

Kind: inner class of util/model
Export:

new ModelDefinition(t)

Class to generate model definitions

| Param | Type | Description | | --- | --- | --- | | t | string | The type for this definition |

ModelDefinition.ModelDefinition#auto(func) ⇒ this

Define an autoValue

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | func | function | The autovalue function |

ModelDefinition.ModelDefinition#maybe() ⇒ this

Set this field as optional

Kind: static method of ModelDefinition

ModelDefinition.ModelDefinition#max(val, [exclusive]) ⇒ this

Set this field's maximum allowed value / length

Kind: static method of ModelDefinition

| Param | Type | Default | Description | | --- | --- | --- | --- | | val | number | | The max value / length | | [exclusive] | boolean | false | Whether this value is an exclusive max |

ModelDefinition.ModelDefinition#min(val, [exclusive]) ⇒ this

Set this field's minimum allowed value / length

Kind: static method of ModelDefinition

| Param | Type | Default | Description | | --- | --- | --- | --- | | val | number | | The min value / length | | [exclusive] | boolean | false | Whether this value is an exclusive min |

ModelDefinition.ModelDefinition#maxCount(val) ⇒ this

Set the maximum number of allowed elements in an array field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | val | number | The max number of elements |

ModelDefinition.ModelDefinition#minCount(val) ⇒ this

Set the minimum number of allowed elements in an array field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | val | number | The min number of elements |

ModelDefinition.ModelDefinition#subtype(format) ⇒ this

Set the subtype / format of this field. E.g. "float" for a number type

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | format | string | The format / subtype |

ModelDefinition.ModelDefinition#prop(name, value) ⇒ this

Define a single property of an object-type field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | name | string | The property name | | value | ModelDefinition | The property value |

ModelDefinition.ModelDefinition#props(properties) ⇒ this

Define all properties of an object-type field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | properties | * | The property definitions |

ModelDefinition.ModelDefinition#elems(definition) ⇒ this

Define the elements of an array-type field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | definition | ModelDefinition | The definition which applies to all elements |

ModelDefinition.ModelDefinition#regex(pattern) ⇒ this

Define a RegEx pattern which applies to a string-type field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | pattern | RegEx | The pattern |

ModelDefinition.ModelDefinition#in(values) ⇒ this

Define a list of permitted values for this field

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | values | Array | ILink | The array of allowed values |

ModelDefinition.ModelDefinition#join(model, [field], where) ⇒ this

Define a link to another Model

Kind: static method of ModelDefinition

| Param | Type | Default | Description | | --- | --- | --- | --- | | model | string | | The name of the model | | [field] | string | "'_id'" | The field on the other model to join on | | where | * | | An optional selector for items in the foreign model |

ModelDefinition.ModelDefinition#other(key, value) ⇒ this

Set a custom definition key

Kind: static method of ModelDefinition

| Param | Type | Description | | --- | --- | --- | | key | string | The key name | | value | * | The value |

util/model~def ⇒ this

Shorthand to get an instance of ModelDefinition

Kind: inner constant of util/model

| Param | Type | Description | | --- | --- | --- | | type | string | The type of the field (e.g. 'string' / 'boolean') |

util/model~ILinkWhere : Object

Kind: inner typedef of util/model
Properties

| Name | Type | | --- | --- | | * | * |

util/model~ILink : Object

Kind: inner typedef of util/model
Properties

| Name | Type | | --- | --- | | model | string | | [field] | string | | [where] | ILinkWhere |

util/number

util/number~clamp(val, min, max) ⇒ number

Kind: inner method of util/number
Summary: ensures that a number falls between two others, constraining it if necessary
Returns: number - the clamped number
Export:

| Param | Type | Description | | --- | --- | --- | | val | number | the number to clamp | | min | number | the minimum that the number should be | | max | number | the maximum that the number should be |

util/number~random([min], [max])

Kind: inner method of util/number
Summary: Returns a random integer, optionally between an min and max
Export:

| Param | Type | Description | | --- | --- | --- | | [min] | number | The minimum acceptable value | | [max] | number | The maximum acceptable value |

util/number~pad(num, width, char) ⇒ string

Kind: inner method of util/number
Summary: pads out a number to specified width with specified char or 0
Returns: string - the padded number
Export:

| Param | | --- | | num | | width | | char |

util/object

util/object~map(object, callback) ⇒ any

Kind: inner method of util/object
Summary: passes each key=>value pair to callback, setting the result to a new object under a key of the same name
Returns: any - a new object with the same key names but mapped values
Export:

| Param | Type | Description | | --- | --- | --- | | object | any | the object whose values to map | | callback | function | a function to pass each key=>value pair to |

util/object~transform(object, callback)

Kind: inner method of util/object
Summary: Like map, but able to transform the key too. Map the object into a completely different

| Param | Description | | --- | --- | | object | the object to transform | | callback | callback to perform the transformation, return an array like [key, value] |

util/object~forEach()

Kind: inner method of util/object
Summary: Like array.forEach, but for an object, gets keys and values

util/object~filter(object, callback) ⇒ any

Kind: inner method of util/object
Summary: passes each key=>value pair of an object to callback, copying them over if the result is truthy
Returns: any - a filtered copy of the input object
Export:

| Param | Type | Description | | --- | --- | --- | | object | any | the object whose keys to filter | | callback | function | the function to pass each key=>value pair to |

util/object~resolve() ⇒ any | undefined

Kind: inner method of util/object
Summary: get a nested property of an object by string e.g. resolve(myObj, 'nested.property')
Returns: any | undefined - resolved value or undefined if intermediate values are undefined
Export:

util/object~didResolve() ⇒ boolean

Kind: inner method of util/object
Summary: report whether an attempt to resolve a nested property of an object was successful or not.
Returns: boolean - whether the nested property exists
Export:

util/object~resolveIf() ⇒ any | null

Kind: inner method of util/object
Summary: same as resolve but sets the property to val
Returns: any | null - The resolved value or null
Export:

util/object~resolveSet() ⇒ boolean

Kind: inner method of util/object
Summary: same as resolve but sets the property to val
Returns: boolean - whether setting was successful
Export:

util/object~transformPathsToObjects(obj) ⇒

Transform an entire object by converting all of its keys into object paths using resolveSet

Kind: inner method of util/object
Returns: obj for convenience, although transformed in place

| Param | Description | | --- | --- | | obj | the object to transform (transformed in place) |

util/object~flatten(input, _output, _prefix)

Convert a deep object into one which is flat (has a max depth of 1 level). The output object's keys will use dot notation to symbolise depth. If a property contains a dot, this will be converted to "[dot]"

Kind: inner method of util/object

| Param | Type | Description | | --- | --- | --- | | input | object | An input object. Required | | _output | object | Private param used in recursion | | _prefix | string | Private param used in recursion |

Example

var deepObj = {person: {profile: {name: 'Carl', age: 26}, password: 'foobar', '.withDot': true}}
    var res = flatten(deepObj)
    // res === {
    //   'person.profile.name': 'Carl',
    //   'person.profile.age': 26,
    //   'person.password': 'foobar',
    //   'person.[dot]withDot': true
    // }

util/object~flattenAll(input, _output, _prefix)

Convert a deep object into one which is flat (has a max depth of 1 level). The output object's keys will use dot notation to symbolise depth. Also processes arrays

Kind: inner method of util/object

| Param | Type | Description | | --- | --- | --- | | input | object | An input object. Required | | _output | object | Private param used in recursion | | _prefix | string | Private param used in recursion |

Example

var deepObj = {person: {profile: {name: 'Carl', age: 26}, things: ['foo', 'bar'], '.withdot': true}}
    flattenAll(deepObj)
    // returns {
    //   'person.profile.name': 'Carl',
    //   'person.profile.age': 26,
    //   'person.things.0': 'foo',
    //   'person.things.1': 'bar'
    //   'person.[dot]withDot: true
    // }

util/object~resolveSetP(outerObj, outerPath, outerVal) ⇒ boolean

Kind: inner method of util/object
Summary: same as resolveSet, but will create paths down into objects where they don't exist
Returns: boolean - whether the op was successful
Export:

| Param | Type | Description | | --- | --- | --- | | outerObj | object | the object to create the value in | | outerPath | string | the path (dot notation) into the object | | outerVal | any | the new value |

util/object~mapAsync

Kind: inner typedef of util/object
Summary: passes each key=>value pair to callback asynchronously, setting the result to a new object under a key of the same name. Calls onComplete when all keys have been mapped
Export:

| Param | Type | Description | | --- | --- | --- | | object | any | the object whose values to map | | callback | function | a function to pass each key=>value pair to | | onComplete | function | a callback which will receive two arguments, error and res |

util/object~transformAsync

Kind: inner typedef of util/object
Summary: Like map, but able to transform the key too. Map the object into a completely different shape. Iterates asynchronously
Export:

| Param | Type | Description | | --- | --- | --- | | object | any | the object to transform | | cb | function | callback to perform the transformation, return an array like [key, value] | | onComplete | function | a callback which will received two arguments, error and res |

util/popover

util/popover~open(source, content, options)

Opens a popover with the specified content located on the edge of the source object

Kind: inner method of util/popover

| Param | Description | | --- | --- | | source | the target element this popover should be attached to | | content | the content to show in the popover | | options | |

util/popover~openDropdown(source, dropDownItems, options)

Opens a dropdown, which internally is still a popover with some special additions

Kind: inner method of [util/popover](#mod