@webantic/util
TypeScript icon, indicating that this package has built-in type declarations

9.0.4 • Public • Published

Modules

util/array
util/blaze
util/collection
util/config
util/data
util/date
util/emitter
util/http
util/image
util/location
util/meteor
util/model
util/number
util/object
util/popover
util/reactivity
util/schema
util/config
util/string

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

Param Description
source which element should the dropdown be attached to?
dropDownItems the items that should be shown in the dropdown @see DropDownItem
options

util/popover~ifLet(toCheck, ifCallback, elseCallback)

Internal function used to run a specific callback with a value if it exists

Kind: inner method of util/popover

Param Description
toCheck the value, or values to check
ifCallback the callback to run with the value if it exists
elseCallback the callback to run if the value does not exist

util/popover~viewportPosition(element)

Internal function used to get the viewport position of an element

Kind: inner method of util/popover

Param
element

util/popover~addTriangleToFixedElement(element, positionedWhere, pointingAt, container) ⇒

Adds a triangle to point at the edge of one element (element) to a target (pointingAt)

Kind: inner method of util/popover
Returns: the triangle element

Param Description
element the element doing the pointing
positionedWhere where is the popup in relation to the target
pointingAt what should it point at
container where do we add the triangle

util/popover~positionFixed(element, relativeTo)

Position an element relative to another

Kind: inner method of util/popover

Param Description
element the element to position
relativeTo the element to use as an anchor

util/reactivity

util/reactivity~reactivelyStore(getter, autorunnerOrTemplate) ⇒ any

Store some data that depends on reactive data sources in a reactive var so as not to recalculate it every time

Kind: inner method of util/reactivity
Returns: any - a function that when called returns the latest value of the data

Param Description
getter callback to get the value
autorunnerOrTemplate

util/schema

util/schema~optional(primitive) ⇒ Object

Kind: inner method of util/schema
Summary: returns an optional primitive definition
Returns: Object - the schema value definition
Export:

Param Type
primitive Schema.PrimitiveConstructor | string

util/schema~blackbox(primitive) ⇒ IBlackbox

Kind: inner method of util/schema
Summary: returns an blackbox primitive definition
Returns: IBlackbox - the schema value definition
Export:

Param Type Description
primitive Schema.PrimitiveConstructor | string (technically this will always be Object but it is configurable for consistency)

util/schema~optionalBlackbox(primitive) ⇒ IOptionalBlackbox

Kind: inner method of util/schema
Summary: returns an optional, blackboxed primitive definition
Returns: IOptionalBlackbox - the schema value definition
Export:

Param Type Description
primitive Schema.PrimitiveConstructor | string (technically this will always be Object but it is configurable for consistency)

util/schema~createdDate() ⇒ Schema.ICreatedDate

Kind: inner method of util/schema
Summary: returns a typedef with a type of Date and an autoValue function which returns a new date on insert
Returns: Schema.ICreatedDate - the schema value definition
Export:

util/schema~updatedDate() ⇒ Schema.IUpdatedDate

Kind: inner method of util/schema
Summary: returns a typedef with a type of Date and an autoValue function which returns a new date
Returns: Schema.IUpdatedDate - the schema value definition
Export:

util/schema~geoJSON(SimpleSchema) ⇒ Schema.IGeoJSON

Kind: inner method of util/schema
Summary: returns a typedef for a geoJSON object
Returns: Schema.IGeoJSON - the schema value definition
Export:

Param Type Description
SimpleSchema * A reference to SimpleSchema

util/schema~defaultValue(type, value)

Kind: inner method of util/schema
Summary: returns a typedef for a field with a defined default
Export:

Param Type Description
type Schema.PrimitiveConstructor | string The type constructor (e.g. Number)
value any The default value

util/schema~optionalDefaultValue(type, value)

Kind: inner method of util/schema
Summary: returns a typedef for an optional field with a defined default
Export:

Param Type Description
type Schema.PrimitiveConstructor | string The type constructor (e.g. Number)
value any The default value

util/schema~minZeroNumber() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for a field for a number with a minimum permitted value of zero
Returns: Object - typedef for number field with min value of 0
Export:

util/schema~optionalMinZeroNumber() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for an optional field for a number with a minimum permitted value of zero
Returns: Object - typedef for optional number field with min value of 0
Export:

util/schema~minZeroNumberWithDefault() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for a field for a number with a minimum permitted and default value of zero
Returns: Object - typedef for number field with minimum and default value of 0
Export:

util/schema~integerBetweenValues(min, max)

Kind: inner method of util/schema
Summary: returns a typedef for a field for an integer between two values
Export:

Param Type Description
min number the minimum permitted value
max number the maximum permitted value

util/schema~optionalIntegerBetweenValues(min, max)

Kind: inner method of util/schema
Summary: returns a typedef for an optional field for an integer between two values
Export:

Param Type Description
min number the minimum permitted value
max number the maximum permitted value

util/schema~idParams(name) ⇒ any

Kind: inner method of util/schema
Summary: returns an array with a single object in which defines an _id path param
Returns: any - the params array
Export:

Param Type Description
name string the name of the field

util/schema~checkParameters(context, params, schema) ⇒ boolean

Kind: inner method of util/schema
Summary: Check incoming parameters against a schema
Returns: boolean - true
Throws:

  • 400 on validation error

Export:

Param Type Description
context any The this context
params any The incoming parameters
schema any A SimpleSchema schema

util/schema~positiveNumber() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for a field for a number with a minimum permitted value greater than zero
Returns: Object - typedef for number field with positive min value (> 0)
Export:

util/schema~optionalPositiveNumber() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for an optional field for a number with a minimum permitted value of zero
Returns: Object - typedef for optional number field with positive min value (> 0)
Export:

util/schema~positiveInteger() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for a field for an integer with a minimum permitted value of zero
Returns: Object - typedef for integer field with positive min value (> 0)
Export:

util/schema~optionalPositiveInteger() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for an optional field for an integer with a minimum permitted value of zero
Returns: Object - typedef for optional integer field with positive min value (> 0)
Export:

util/schema~immutable() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for a field that should not be updated once set
Returns: Object - typedef for field with immutable value
Export:

util/schema~optionalImmutable() ⇒ Object

Kind: inner method of util/schema
Summary: returns a typedef for an optional field that should not be updated once set
Returns: Object - typedef for optional field with immutable value
Export:

util/schema~alwaysArray()

Kind: inner method of util/schema
Summary: returns multiple typedefs for an array of elements of the given type where the default value is always an empty array
Export:

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/string

util/string~capitalize(str) ⇒ string

Kind: inner method of util/string
Summary: makes the first letter of a string uppercase and the rest lowercase
Returns: string - the capitalised string
Export:

Param Type Description
str string the string to capitalise

util/string~humanize(str) ⇒ string

Kind: inner method of util/string
Summary: Converts identifiers to more human-friendly versions. e.g. helloWorld -> Hello world
Returns: string - the human-friendly version of the string
Export:

Param Type Description
str string the string to humanise

util/string~titleize(str) ⇒ string

Kind: inner method of util/string
Summary: converts each words' first letter to uppercase.
Returns: string - the titleized string
Export:

Param Type Description
str string the string to titleize

util/string~camelize(str) ⇒ string

Kind: inner method of util/string
Summary: converts a string of words to a lowerCamelCase word
Returns: string - the camelized string
Export:

Param Type Description
str string the string to camelize

util/string~hyphenate(str) ⇒ string

Kind: inner method of util/string
Summary: converts spaces to hyphens
Returns: string - the processed string
Export:

Param Type Description
str string the string to perform the replacements on

util/string~truncate(str, [count]) ⇒ string

Kind: inner method of util/string
Summary: limits the length of a string to count (plus three for dots)
Returns: string - the possibly truncated string
Export:

Param Type Description
str string the string to truncate
[count] number the maximum length of the string

util/string~addThousandsSeparators(str) ⇒ string

Kind: inner method of util/string
Summary: Inserts a comma every three digits
Returns: string - the formatted number
Export:

Param Type Description
str string | number a number, represented as a string

util/string~extname(filename) ⇒ string

Kind: inner method of util/string
Summary: gets the file extension from a file name
Returns: string - the file extension
Export:

Param Type Description
filename string the full filename. e.g. "movie.avi"

util/string~underscore(str) ⇒ string

Kind: inner method of util/string
Summary: converts spaces to underscores in a string
Returns: string - the processed string
Export:

Param Type Description
str string the string to process

util/string~keyify(str, [replacer]) ⇒ string

Kind: inner method of util/string
Summary: converts spaces to dashes/underscores & lowercases the string for db values and filenames etc..
Returns: string - the keyified string
Export:

Param Type Description
str string the string to keyify
[replacer] string the character to use in place of spaces. Can be '-' or '_'

util/string~getDomain(str) ⇒ string | null

Kind: inner method of util/string
Summary: gets the domain from an email address
Returns: string | null - the domain, or null
Export:

Param Type Description
str string the email address to test

util/string~startsWith(haystack, needle) ⇒ boolean

Kind: inner method of util/string
Summary: Reports whether haystack starts with needle
Returns: boolean - whether haystack starts with needle
Export:

Param Type Description
haystack string the string to search
needle string the substring to search for

util/string~endsWith(haystack, needle) ⇒ boolean

Kind: inner method of util/string
Summary: Reports whether haystack ends with needle
Returns: boolean - whether haystack ends with needle
Export:

Param Type Description
haystack string the string to search
needle string the substring to search for

util/string~escapeRegExp(str) ⇒ string

Kind: inner method of util/string
Summary: Escapes special characters in a string, enabling the string's use as a regex
Returns: string - the escaped string
Export:

Param Type Description
str string the string to escape

util/string~isEmail(str) ⇒ boolean

Kind: inner method of util/string
Summary: determines whether a string looks like an email address
Returns: boolean - whether the string looks like an email
Export:

Param Type Description
str string the potential email address

util/string~isUrl(str) ⇒ boolean

Kind: inner method of util/string
Summary: determines whether a string looks like a url
Returns: boolean - whether the string looks like a url
Export:

Param Type Description
str string the potential url

util/string~isIP(str) ⇒ boolean

Kind: inner method of util/string
Summary: determins whether a string looks like an ip address (either IPv4 or IPv6)
Returns: boolean - whether the string looks like an ip
Export:

Param Type Description
str string the potential ip address

util/string~isIPv4(str) ⇒ boolean

Kind: inner method of util/string
Summary: determines whether a string looks like an ip address
Returns: boolean - whether the string looks like an ip
Export:

Param Type Description
str string the potential ip address

util/string~isIPv6(str) ⇒ boolean

Kind: inner method of util/string
Summary: determines whether a string looks like an ip address
Returns: boolean - whether the string looks like an ip
Export:

Param Type Description
str string the potential ip address

util/string~caseInsensitivePermutations(str) ⇒ Array.<string>

Kind: inner method of util/string
Summary: generates permutations of all case variations of a given string.
Returns: Array.<string> - an array of permutations
Export:

Param Type Description
str string The string to get permutations of

util/string~nonEmpty(str) ⇒ boolean

Kind: inner method of util/string
Summary: Check if something is a string and non-empty
Returns: boolean - whether the provided value is a string and has a length
Export:

Param Type Description
str any the string to check

util/string~dedent(strings, values) ⇒ string

Kind: inner method of util/string
Summary: Remove leading indents from a template string without removing all leading whitespace
Returns: string - the processed string
Export:

Param Type Description
strings TemplateStringsArray the string parts
values Array.<any> templating variables for interpolation

util/string~formatPennies(amount, symbol)

Formats an amount in pennies to £x.xx

Kind: inner method of util/string

Param Type Default Description
amount number
symbol string "£" override for custom prefixed symbol, defaults to '£'

Readme

Keywords

none

Package Sidebar

Install

npm i @webantic/util

Weekly Downloads

17

Version

9.0.4

License

SEE LICENSE IN ./LICENSE

Unpacked Size

349 kB

Total Files

71

Last publish

Collaborators

  • carlevans719
  • ngaskill
  • jm-ans