repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Rekord/rekord | build/rekord.js | function(properties)
{
if ( !isValue( properties ) )
{
return this.length;
}
var resolver = createPropertyResolver( properties );
var result = 0;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( isValue( resolved ) )
{
re... | javascript | function(properties)
{
if ( !isValue( properties ) )
{
return this.length;
}
var resolver = createPropertyResolver( properties );
var result = 0;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( isValue( resolved ) )
{
re... | [
"function",
"(",
"properties",
")",
"{",
"if",
"(",
"!",
"isValue",
"(",
"properties",
")",
")",
"{",
"return",
"this",
".",
"length",
";",
"}",
"var",
"resolver",
"=",
"createPropertyResolver",
"(",
"properties",
")",
";",
"var",
"result",
"=",
"0",
"... | Counts the number of elements in this collection that has a value for the
given property expression.
```javascript
var c = Rekord.collect([{age: 2}, {age: 3}, {taco: 4}]);
c.count('age'); // 2
c.count('taco'); // 1
c.count(); // 3
```
@method
@memberof Rekord.Collection#
@param {propertyResolverInput} [properties] -
... | [
"Counts",
"the",
"number",
"of",
"elements",
"in",
"this",
"collection",
"that",
"has",
"a",
"value",
"for",
"the",
"given",
"property",
"expression",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9012-L9033 | train | |
Rekord/rekord | build/rekord.js | function(values, keys)
{
var valuesResolver = createPropertyResolver( values );
if ( keys )
{
var keysResolver = createPropertyResolver( keys );
var result = {};
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
var value = valuesResolver( model );
... | javascript | function(values, keys)
{
var valuesResolver = createPropertyResolver( values );
if ( keys )
{
var keysResolver = createPropertyResolver( keys );
var result = {};
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
var value = valuesResolver( model );
... | [
"function",
"(",
"values",
",",
"keys",
")",
"{",
"var",
"valuesResolver",
"=",
"createPropertyResolver",
"(",
"values",
")",
";",
"if",
"(",
"keys",
")",
"{",
"var",
"keysResolver",
"=",
"createPropertyResolver",
"(",
"keys",
")",
";",
"var",
"result",
"=... | Plucks values from elements in the collection. If only a `values` property
expression is given the result will be an array of resolved values. If the
`keys` property expression is given, the result will be an object where the
property of the object is determined by the key expression.
```javascript
var c = Rekord.coll... | [
"Plucks",
"values",
"from",
"elements",
"in",
"the",
"collection",
".",
"If",
"only",
"a",
"values",
"property",
"expression",
"is",
"given",
"the",
"result",
"will",
"be",
"an",
"array",
"of",
"resolved",
"values",
".",
"If",
"the",
"keys",
"property",
"e... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9060-L9094 | train | |
Rekord/rekord | build/rekord.js | function(callback, context)
{
var callbackContext = context || this;
for (var i = 0; i < this.length; i++)
{
var item = this[ i ];
callback.call( callbackContext, item, i );
if ( this[ i ] !== item )
{
i--;
}
}
return this;
} | javascript | function(callback, context)
{
var callbackContext = context || this;
for (var i = 0; i < this.length; i++)
{
var item = this[ i ];
callback.call( callbackContext, item, i );
if ( this[ i ] !== item )
{
i--;
}
}
return this;
} | [
"function",
"(",
"callback",
",",
"context",
")",
"{",
"var",
"callbackContext",
"=",
"context",
"||",
"this",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
"[",... | Iterates over each element in this collection and passes the element and
it's index to the given function. An optional function context can be given.
@method
@memberof Rekord.Collection#
@param {Function} callback -
The function to invoke for each element of this collection passing the
element and the index where it e... | [
"Iterates",
"over",
"each",
"element",
"in",
"this",
"collection",
"and",
"passes",
"the",
"element",
"and",
"it",
"s",
"index",
"to",
"the",
"given",
"function",
".",
"An",
"optional",
"function",
"context",
"can",
"be",
"given",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9110-L9127 | train | |
Rekord/rekord | build/rekord.js | function(callback, properties, values, equals)
{
var where = createWhere( properties, values, equals );
for (var i = 0; i < this.length; i++)
{
var item = this[ i ];
if ( where( item ) )
{
callback.call( this, item, i );
if ( this[ i ] !== item )
{
i-... | javascript | function(callback, properties, values, equals)
{
var where = createWhere( properties, values, equals );
for (var i = 0; i < this.length; i++)
{
var item = this[ i ];
if ( where( item ) )
{
callback.call( this, item, i );
if ( this[ i ] !== item )
{
i-... | [
"function",
"(",
"callback",
",",
"properties",
",",
"values",
",",
"equals",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"properties",
",",
"values",
",",
"equals",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"le... | Iterates over each element in this collection that matches the where
expression and passes the element and it's index to the given function.
@method
@memberof Rekord.Collection#
@param {Function} callback -
The function to invoke for each element of this collection passing the
element and the index where it exists.
@p... | [
"Iterates",
"over",
"each",
"element",
"in",
"this",
"collection",
"that",
"matches",
"the",
"where",
"expression",
"and",
"passes",
"the",
"element",
"and",
"it",
"s",
"index",
"to",
"the",
"given",
"function",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9148-L9168 | train | |
Rekord/rekord | build/rekord.js | function(reducer, initialValue)
{
for (var i = 0; i < this.length; i++)
{
initialValue = reducer( initialValue, this[ i ] );
}
return initialValue;
} | javascript | function(reducer, initialValue)
{
for (var i = 0; i < this.length; i++)
{
initialValue = reducer( initialValue, this[ i ] );
}
return initialValue;
} | [
"function",
"(",
"reducer",
",",
"initialValue",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"initialValue",
"=",
"reducer",
"(",
"initialValue",
",",
"this",
"[",
"i",
"]",
")",
";"... | Reduces all the elements of this collection to a single value. All elements
are passed to a function which accepts the currently reduced value and the
current element and returns the new reduced value.
```javascript
var reduceIt = function(curr, elem) {
return curr + ( elem[0] * elem[1] );
};
var c = Rekord.collect([[... | [
"Reduces",
"all",
"the",
"elements",
"of",
"this",
"collection",
"to",
"a",
"single",
"value",
".",
"All",
"elements",
"are",
"passed",
"to",
"a",
"function",
"which",
"accepts",
"the",
"currently",
"reduced",
"value",
"and",
"the",
"current",
"element",
"an... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9193-L9201 | train | |
Rekord/rekord | build/rekord.js | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
if ( where( model ) )
{
return true;
}
}
return false;
} | javascript | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
if ( where( model ) )
{
return true;
}
}
return false;
} | [
"function",
"(",
"properties",
",",
"value",
",",
"equals",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"properties",
",",
"value",
",",
"equals",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
... | Determines whether at least one element in this collection matches the
given criteria.
```javascript
var c = Rekord.collect([{age: 2}, {age: 6}]);
c.contains('age', 2); // true
c.contains('age', 3); // false
c.contains('age'); // true
c.contains('name'); // false
```
@method
@memberof Rekord.Collection#
@param {where... | [
"Determines",
"whether",
"at",
"least",
"one",
"element",
"in",
"this",
"collection",
"matches",
"the",
"given",
"criteria",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9294-L9309 | train | |
Rekord/rekord | build/rekord.js | function(grouping)
{
var by = createPropertyResolver( grouping.by );
var having = createWhere( grouping.having, grouping.havingValue, grouping.havingEquals );
var select = grouping.select || {};
var map = {};
if ( isString( grouping.by ) )
{
if ( !(grouping.by in select) )
{
... | javascript | function(grouping)
{
var by = createPropertyResolver( grouping.by );
var having = createWhere( grouping.having, grouping.havingValue, grouping.havingEquals );
var select = grouping.select || {};
var map = {};
if ( isString( grouping.by ) )
{
if ( !(grouping.by in select) )
{
... | [
"function",
"(",
"grouping",
")",
"{",
"var",
"by",
"=",
"createPropertyResolver",
"(",
"grouping",
".",
"by",
")",
";",
"var",
"having",
"=",
"createWhere",
"(",
"grouping",
".",
"having",
",",
"grouping",
".",
"havingValue",
",",
"grouping",
".",
"having... | Groups the elements into sub collections given some property expression to
use as the value to group by.
```javascript
var c = Rekord.collect([
{ name: 'Tom', age: 6, group: 'X' },
{ name: 'Jon', age: 7, group: 'X' },
{ name: 'Rob', age: 8, group: 'X' },
{ name: 'Bon', age: 9, group: 'Y' },
{ name: 'Ran', age: 10, gro... | [
"Groups",
"the",
"elements",
"into",
"sub",
"collections",
"given",
"some",
"property",
"expression",
"to",
"use",
"as",
"the",
"value",
"to",
"group",
"by",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L9363-L9444 | train | |
Rekord/rekord | build/rekord.js | function(database, models, remoteData)
{
Class.props(this, {
database: database,
map: new Map()
});
this.map.values = this;
this.reset( models, remoteData );
return this;
} | javascript | function(database, models, remoteData)
{
Class.props(this, {
database: database,
map: new Map()
});
this.map.values = this;
this.reset( models, remoteData );
return this;
} | [
"function",
"(",
"database",
",",
"models",
",",
"remoteData",
")",
"{",
"Class",
".",
"props",
"(",
"this",
",",
"{",
"database",
":",
"database",
",",
"map",
":",
"new",
"Map",
"(",
")",
"}",
")",
";",
"this",
".",
"map",
".",
"values",
"=",
"t... | Initializes the model collection by setting the database, the initial set
of models, and whether the initial set of models is from a remote source.
@method
@memberof Rekord.ModelCollection#
@param {Rekord.Database} database -
The database for the models in this collection.
@param {modelInput[]} [models] -
The initial ... | [
"Initializes",
"the",
"model",
"collection",
"by",
"setting",
"the",
"database",
"the",
"initial",
"set",
"of",
"models",
"and",
"whether",
"the",
"initial",
"set",
"of",
"models",
"is",
"from",
"a",
"remote",
"source",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10088-L10099 | train | |
Rekord/rekord | build/rekord.js | function(models, remoteData)
{
var map = this.map;
map.reset();
if ( isArray( models ) )
{
for (var i = 0; i < models.length; i++)
{
var model = models[ i ];
var parsed = this.parseModel( model, remoteData );
if ( parsed )
{
map.put( parsed.$key... | javascript | function(models, remoteData)
{
var map = this.map;
map.reset();
if ( isArray( models ) )
{
for (var i = 0; i < models.length; i++)
{
var model = models[ i ];
var parsed = this.parseModel( model, remoteData );
if ( parsed )
{
map.put( parsed.$key... | [
"function",
"(",
"models",
",",
"remoteData",
")",
"{",
"var",
"map",
"=",
"this",
".",
"map",
";",
"map",
".",
"reset",
"(",
")",
";",
"if",
"(",
"isArray",
"(",
"models",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"mode... | Resets the models in this collection with a new collection of models.
@method
@memberof Rekord.ModelCollection#
@param {modelInput[]} [models] -
The initial array of models in this collection.
@param {Boolean} [remoteData=false] -
If the models array is from a remote source. Remote sources place the
model directly int... | [
"Resets",
"the",
"models",
"in",
"this",
"collection",
"with",
"a",
"new",
"collection",
"of",
"models",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10290-L10323 | train | |
Rekord/rekord | build/rekord.js | function(key, model, delaySort)
{
this.map.put( key, model );
this.trigger( Collection.Events.Add, [this, model, this.map.indices[ key ]] );
if ( !delaySort )
{
this.sort();
}
} | javascript | function(key, model, delaySort)
{
this.map.put( key, model );
this.trigger( Collection.Events.Add, [this, model, this.map.indices[ key ]] );
if ( !delaySort )
{
this.sort();
}
} | [
"function",
"(",
"key",
",",
"model",
",",
"delaySort",
")",
"{",
"this",
".",
"map",
".",
"put",
"(",
"key",
",",
"model",
")",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Add",
",",
"[",
"this",
",",
"model",
",",
"this... | Places a model in this collection providing a key to use.
@method
@memberof Rekord.ModelCollection#
@param {modelKey} key -
The key of the model.
@param {Rekord.Model} model -
The model instance to place in the collection.
@param {Boolean} [delaySort=false] -
Whether automatic sorting should be delayed until the user ... | [
"Places",
"a",
"model",
"in",
"this",
"collection",
"providing",
"a",
"key",
"to",
"use",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10374-L10383 | train | |
Rekord/rekord | build/rekord.js | function(input, delaySort, remoteData)
{
var model = this.parseModel( input, remoteData );
var key = model.$key();
this.map.put( key, model );
this.trigger( Collection.Events.Add, [this, model, this.map.indices[ key ]] );
if ( !delaySort )
{
this.sort();
}
return this;
} | javascript | function(input, delaySort, remoteData)
{
var model = this.parseModel( input, remoteData );
var key = model.$key();
this.map.put( key, model );
this.trigger( Collection.Events.Add, [this, model, this.map.indices[ key ]] );
if ( !delaySort )
{
this.sort();
}
return this;
} | [
"function",
"(",
"input",
",",
"delaySort",
",",
"remoteData",
")",
"{",
"var",
"model",
"=",
"this",
".",
"parseModel",
"(",
"input",
",",
"remoteData",
")",
";",
"var",
"key",
"=",
"model",
".",
"$key",
"(",
")",
";",
"this",
".",
"map",
".",
"pu... | Adds a model to this collection - sorting the collection if a comparator
is set on this collection and `delaySort` is not a specified or a true
value.
@method
@memberof Rekord.ModelCollection#
@param {modelInput} input -
The model to add to this collection.
@param {Boolean} [delaySort=false] -
Whether automatic sortin... | [
"Adds",
"a",
"model",
"to",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"a",
"specified",
"or",
"a",
"true",
"value",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10406-L10420 | train | |
Rekord/rekord | build/rekord.js | function()
{
var values = AP.slice.apply( arguments );
var indices = [];
for (var i = 0; i < values.length; i++)
{
var model = this.parseModel( values[ i ] );
var key = model.$key();
this.map.put( key, model );
indices.push( this.map.indices[ key ] );
}
this.trigger(... | javascript | function()
{
var values = AP.slice.apply( arguments );
var indices = [];
for (var i = 0; i < values.length; i++)
{
var model = this.parseModel( values[ i ] );
var key = model.$key();
this.map.put( key, model );
indices.push( this.map.indices[ key ] );
}
this.trigger(... | [
"function",
"(",
")",
"{",
"var",
"values",
"=",
"AP",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
";",
"var",
"indices",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")"... | Adds one or more models to the end of this collection - sorting the
collection if a comparator is set on this collection.
@method
@memberof Rekord.ModelCollection#
@param {...modelInput} value -
The models to add to this collection.
@return {Number} -
The new length of this collection.
@emits Rekord.ModelCollection#ad... | [
"Adds",
"one",
"or",
"more",
"models",
"to",
"the",
"end",
"of",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10435-L10453 | train | |
Rekord/rekord | build/rekord.js | function(models, delaySort, remoteData)
{
if ( isArray( models ) )
{
var indices = [];
for (var i = 0; i < models.length; i++)
{
var model = this.parseModel( models[ i ], remoteData );
var key = model.$key();
this.map.put( key, model );
indices.push( this.ma... | javascript | function(models, delaySort, remoteData)
{
if ( isArray( models ) )
{
var indices = [];
for (var i = 0; i < models.length; i++)
{
var model = this.parseModel( models[ i ], remoteData );
var key = model.$key();
this.map.put( key, model );
indices.push( this.ma... | [
"function",
"(",
"models",
",",
"delaySort",
",",
"remoteData",
")",
"{",
"if",
"(",
"isArray",
"(",
"models",
")",
")",
"{",
"var",
"indices",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"models",
".",
"length",
";",
"... | Adds all models in the given array to this collection - sorting the
collection if a comparator is set on this collection and `delaySort` is
not specified or a true value.
@method
@memberof Rekord.ModelCollection#
@param {modelInput[]} models -
The models to add to this collection.
@param {Boolean} [delaySort=false] -
... | [
"Adds",
"all",
"models",
"in",
"the",
"given",
"array",
"to",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
"val... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10492-L10514 | train | |
Rekord/rekord | build/rekord.js | function(delaySort)
{
var removed = this[ 0 ];
this.map.removeAt( 0 );
this.trigger( Collection.Events.Remove, [this, removed, 0] );
if ( !delaySort )
{
this.sort();
}
return removed;
} | javascript | function(delaySort)
{
var removed = this[ 0 ];
this.map.removeAt( 0 );
this.trigger( Collection.Events.Remove, [this, removed, 0] );
if ( !delaySort )
{
this.sort();
}
return removed;
} | [
"function",
"(",
"delaySort",
")",
"{",
"var",
"removed",
"=",
"this",
"[",
"0",
"]",
";",
"this",
".",
"map",
".",
"removeAt",
"(",
"0",
")",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Remove",
",",
"[",
"this",
",",
"r... | Removes the first model in this collection and returns it - sorting the
collection if a comparator is set on this collection and `delaySort` is
no specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.shift(); // 1
```
@method
@memberof Rekord.ModelCollection#
@param {Boolean} [delaySort=fals... | [
"Removes",
"the",
"first",
"model",
"in",
"this",
"collection",
"and",
"returns",
"it",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"no",
"specified",
"or",
"a",
"true",
"... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10581-L10594 | train | |
Rekord/rekord | build/rekord.js | function(i, delaySort)
{
var removing;
if (i >= 0 && i < this.length)
{
removing = this[ i ];
this.map.removeAt( i );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
this.sort();
}
}
return removing;
} | javascript | function(i, delaySort)
{
var removing;
if (i >= 0 && i < this.length)
{
removing = this[ i ];
this.map.removeAt( i );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
this.sort();
}
}
return removing;
} | [
"function",
"(",
"i",
",",
"delaySort",
")",
"{",
"var",
"removing",
";",
"if",
"(",
"i",
">=",
"0",
"&&",
"i",
"<",
"this",
".",
"length",
")",
"{",
"removing",
"=",
"this",
"[",
"i",
"]",
";",
"this",
".",
"map",
".",
"removeAt",
"(",
"i",
... | Removes the model in this collection at the given index `i` - sorting
the collection if a comparator is set on this collection and `delaySort` is
not specified or a true value.
@method
@memberof Rekord.ModelCollection#
@param {Number} i -
The index of the model to remove.
@param {Boolean} [delaySort=false] -
Whether a... | [
"Removes",
"the",
"model",
"in",
"this",
"collection",
"at",
"the",
"given",
"index",
"i",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10613-L10631 | train | |
Rekord/rekord | build/rekord.js | function(input, delaySort)
{
var key = this.buildKeyFromInput( input );
var removing = this.map.get( key );
if ( removing )
{
var i = this.map.indices[ key ];
this.map.remove( key );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
... | javascript | function(input, delaySort)
{
var key = this.buildKeyFromInput( input );
var removing = this.map.get( key );
if ( removing )
{
var i = this.map.indices[ key ];
this.map.remove( key );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
... | [
"function",
"(",
"input",
",",
"delaySort",
")",
"{",
"var",
"key",
"=",
"this",
".",
"buildKeyFromInput",
"(",
"input",
")",
";",
"var",
"removing",
"=",
"this",
".",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"removing",
")",
"{",
"var",... | Removes the given model from this collection if it exists - sorting the
collection if a comparator is set on this collection and `delaySort` is not
specified or a true value.
@method
@memberof Rekord.ModelCollection#
@param {modelInput} input -
The model to remove from this collection if it exists.
@param {Boolean} [d... | [
"Removes",
"the",
"given",
"model",
"from",
"this",
"collection",
"if",
"it",
"exists",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10653-L10672 | train | |
Rekord/rekord | build/rekord.js | function(inputs, delaySort)
{
var map = this.map;
var removed = [];
var removedIndices = [];
for (var i = 0; i < inputs.length; i++)
{
var key = this.buildKeyFromInput( inputs[ i ] );
var removing = map.get( key );
if ( removing )
{
removedIndices.push( map.indice... | javascript | function(inputs, delaySort)
{
var map = this.map;
var removed = [];
var removedIndices = [];
for (var i = 0; i < inputs.length; i++)
{
var key = this.buildKeyFromInput( inputs[ i ] );
var removing = map.get( key );
if ( removing )
{
removedIndices.push( map.indice... | [
"function",
"(",
"inputs",
",",
"delaySort",
")",
"{",
"var",
"map",
"=",
"this",
".",
"map",
";",
"var",
"removed",
"=",
"[",
"]",
";",
"var",
"removedIndices",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inputs",
"."... | Removes the given models from this collection - sorting the collection if
a comparator is set on this collection and `delaySort` is not specified or
a true value.
@method
@memberof Rekord.ModelCollection#
@param {modelInput[]} inputs -
The models to remove from this collection if they exist.
@param {Boolean} [delaySor... | [
"Removes",
"the",
"given",
"models",
"from",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
"value",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10691-L10724 | train | |
Rekord/rekord | build/rekord.js | function(input)
{
var key = this.buildKeyFromInput( input );
var index = this.map.indices[ key ];
return index === undefined ? -1 : index;
} | javascript | function(input)
{
var key = this.buildKeyFromInput( input );
var index = this.map.indices[ key ];
return index === undefined ? -1 : index;
} | [
"function",
"(",
"input",
")",
"{",
"var",
"key",
"=",
"this",
".",
"buildKeyFromInput",
"(",
"input",
")",
";",
"var",
"index",
"=",
"this",
".",
"map",
".",
"indices",
"[",
"key",
"]",
";",
"return",
"index",
"===",
"undefined",
"?",
"-",
"1",
":... | Returns the index of the given model in this collection or returns -1
if the model doesn't exist in this collection.
@method
@memberof Rekord.ModelCollection#
@param {modelInput} input -
The model to search for.
@return {Number} -
The index of the model in this collection or -1 if it was not found. | [
"Returns",
"the",
"index",
"of",
"the",
"given",
"model",
"in",
"this",
"collection",
"or",
"returns",
"-",
"1",
"if",
"the",
"model",
"doesn",
"t",
"exist",
"in",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L10737-L10743 | train | |
Rekord/rekord | build/rekord.js | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
var hasChanges = function( model )
{
return where( model ) && model.$hasChanges();
};
return this.contains( hasChanges );
} | javascript | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
var hasChanges = function( model )
{
return where( model ) && model.$hasChanges();
};
return this.contains( hasChanges );
} | [
"function",
"(",
"properties",
",",
"value",
",",
"equals",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"properties",
",",
"value",
",",
"equals",
")",
";",
"var",
"hasChanges",
"=",
"function",
"(",
"model",
")",
"{",
"return",
"where",
"(",
"m... | Returns whether this collection has at least one model with changes. An
additional where expression can be given to only check certain models.
@method
@memberof Rekord.ModelCollection#
@param {whereInput} [properties] -
See {@link Rekord.createWhere}
@param {Any} [value] -
See {@link Rekord.createWhere}
@param {equali... | [
"Returns",
"whether",
"this",
"collection",
"has",
"at",
"least",
"one",
"model",
"with",
"changes",
".",
"An",
"additional",
"where",
"expression",
"can",
"be",
"given",
"to",
"only",
"check",
"certain",
"models",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11241-L11251 | train | |
Rekord/rekord | build/rekord.js | function(properties, value, equals, out)
{
var where = createWhere( properties, value, equals );
var changes = out && out instanceof ModelCollection ? out : this.cloneEmpty();
this.each(function(model)
{
if ( where( model ) && model.$hasChanges() )
{
changes.put( model.$key(), mod... | javascript | function(properties, value, equals, out)
{
var where = createWhere( properties, value, equals );
var changes = out && out instanceof ModelCollection ? out : this.cloneEmpty();
this.each(function(model)
{
if ( where( model ) && model.$hasChanges() )
{
changes.put( model.$key(), mod... | [
"function",
"(",
"properties",
",",
"value",
",",
"equals",
",",
"out",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"properties",
",",
"value",
",",
"equals",
")",
";",
"var",
"changes",
"=",
"out",
"&&",
"out",
"instanceof",
"ModelCollection",
"?... | Returns a collection of all changes for each model. The changes are keyed
into the collection by the models key. An additional where expression can
be given to only check certain models.
@method
@memberof Rekord.ModelCollection#
@param {whereInput} [properties] -
See {@link Rekord.createWhere}
@param {Any} [value] -
S... | [
"Returns",
"a",
"collection",
"of",
"all",
"changes",
"for",
"each",
"model",
".",
"The",
"changes",
"are",
"keyed",
"into",
"the",
"collection",
"by",
"the",
"models",
"key",
".",
"An",
"additional",
"where",
"expression",
"can",
"be",
"given",
"to",
"onl... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11274-L11288 | train | |
Rekord/rekord | build/rekord.js | function(cloneModels, cloneProperties)
{
var source = this;
if ( cloneModels )
{
source = [];
for (var i = 0; i < this.length; i++)
{
source[ i ] = this[ i ].$clone( cloneProperties );
}
}
return ModelCollection.create( this.database, source, true );
} | javascript | function(cloneModels, cloneProperties)
{
var source = this;
if ( cloneModels )
{
source = [];
for (var i = 0; i < this.length; i++)
{
source[ i ] = this[ i ].$clone( cloneProperties );
}
}
return ModelCollection.create( this.database, source, true );
} | [
"function",
"(",
"cloneModels",
",",
"cloneProperties",
")",
"{",
"var",
"source",
"=",
"this",
";",
"if",
"(",
"cloneModels",
")",
"{",
"source",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i... | Returns a clone of this collection. Optionally the models in this
collection can also be cloned.
@method
@memberof Rekord.ModelCollection#
@param {Boolean} [cloneModels=false] -
Whether or not the models should be cloned as well.
@param {Boolean} [cloneProperties] -
The properties object which defines what fields shou... | [
"Returns",
"a",
"clone",
"of",
"this",
"collection",
".",
"Optionally",
"the",
"models",
"in",
"this",
"collection",
"can",
"also",
"be",
"cloned",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11335-L11350 | train | |
Rekord/rekord | build/rekord.js | function(base, filter)
{
if ( this.base )
{
this.base.database.off( Database.Events.ModelUpdated, this.onModelUpdated );
}
ModelCollection.prototype.init.call( this, base.database );
Filtering.init.call( this, base, filter );
base.database.on( Database.Events.ModelUpdated, this.onMode... | javascript | function(base, filter)
{
if ( this.base )
{
this.base.database.off( Database.Events.ModelUpdated, this.onModelUpdated );
}
ModelCollection.prototype.init.call( this, base.database );
Filtering.init.call( this, base, filter );
base.database.on( Database.Events.ModelUpdated, this.onMode... | [
"function",
"(",
"base",
",",
"filter",
")",
"{",
"if",
"(",
"this",
".",
"base",
")",
"{",
"this",
".",
"base",
".",
"database",
".",
"off",
"(",
"Database",
".",
"Events",
".",
"ModelUpdated",
",",
"this",
".",
"onModelUpdated",
")",
";",
"}",
"M... | Initializes the filtered collection by setting the base collection and the
filtering function.
@method
@memberof Rekord.FilteredModelCollection#
@param {Rekord.ModelCollection} base -
The model collection to listen to for changes to update this collection.
@param {whereCallback} filter -
The function which determines ... | [
"Initializes",
"the",
"filtered",
"collection",
"by",
"setting",
"the",
"base",
"collection",
"and",
"the",
"filtering",
"function",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11448-L11462 | train | |
Rekord/rekord | build/rekord.js | function(model)
{
var exists = this.has( model.$key() );
var matches = this.filter( model );
if ( exists && !matches )
{
this.remove( model );
}
if ( !exists && matches )
{
this.add( model );
}
} | javascript | function(model)
{
var exists = this.has( model.$key() );
var matches = this.filter( model );
if ( exists && !matches )
{
this.remove( model );
}
if ( !exists && matches )
{
this.add( model );
}
} | [
"function",
"(",
"model",
")",
"{",
"var",
"exists",
"=",
"this",
".",
"has",
"(",
"model",
".",
"$key",
"(",
")",
")",
";",
"var",
"matches",
"=",
"this",
".",
"filter",
"(",
"model",
")",
";",
"if",
"(",
"exists",
"&&",
"!",
"matches",
")",
"... | Handles the ModelUpdated event from the database. | [
"Handles",
"the",
"ModelUpdated",
"event",
"from",
"the",
"database",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11520-L11533 | train | |
Rekord/rekord | build/rekord.js | DiscriminateCollection | function DiscriminateCollection(collection, discriminator, discriminatorsToModel)
{
Class.props( collection,
{
discriminator: discriminator,
discriminatorsToModel: discriminatorsToModel
});
// Original Functions
var buildKeyFromInput = collection.buildKeyFromInput;
var parseModel = collection.parse... | javascript | function DiscriminateCollection(collection, discriminator, discriminatorsToModel)
{
Class.props( collection,
{
discriminator: discriminator,
discriminatorsToModel: discriminatorsToModel
});
// Original Functions
var buildKeyFromInput = collection.buildKeyFromInput;
var parseModel = collection.parse... | [
"function",
"DiscriminateCollection",
"(",
"collection",
",",
"discriminator",
",",
"discriminatorsToModel",
")",
"{",
"Class",
".",
"props",
"(",
"collection",
",",
"{",
"discriminator",
":",
"discriminator",
",",
"discriminatorsToModel",
":",
"discriminatorsToModel",
... | Overrides functions in the given model collection to turn it into a collection
which contains models with a discriminator field.
@param {Rekord.ModelCollection} collection -
The collection instance with discriminated models.
@param {String} discriminator -
The name of the field which contains the discriminator.
@param... | [
"Overrides",
"functions",
"in",
"the",
"given",
"model",
"collection",
"to",
"turn",
"it",
"into",
"a",
"collection",
"which",
"contains",
"models",
"with",
"a",
"discriminator",
"field",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11770-L11867 | train |
Rekord/rekord | build/rekord.js | function(input)
{
if ( isObject( input ) )
{
var discriminatedValue = input[ this.discriminator ];
var model = this.discriminatorsToModel[ discriminatedValue ];
if ( model )
{
return model.Database.keyHandler.buildKeyFromInput( input );
}
}
... | javascript | function(input)
{
if ( isObject( input ) )
{
var discriminatedValue = input[ this.discriminator ];
var model = this.discriminatorsToModel[ discriminatedValue ];
if ( model )
{
return model.Database.keyHandler.buildKeyFromInput( input );
}
}
... | [
"function",
"(",
"input",
")",
"{",
"if",
"(",
"isObject",
"(",
"input",
")",
")",
"{",
"var",
"discriminatedValue",
"=",
"input",
"[",
"this",
".",
"discriminator",
"]",
";",
"var",
"model",
"=",
"this",
".",
"discriminatorsToModel",
"[",
"discriminatedVa... | Builds a key from input. Discriminated collections only accept objects as
input - otherwise there's no way to determine the discriminator. If the
discriminator on the input doesn't map to a Rekord instance OR the input
is not an object the input will be returned instead of a model instance.
@param {modelInput} input -... | [
"Builds",
"a",
"key",
"from",
"input",
".",
"Discriminated",
"collections",
"only",
"accept",
"objects",
"as",
"input",
"-",
"otherwise",
"there",
"s",
"no",
"way",
"to",
"determine",
"the",
"discriminator",
".",
"If",
"the",
"discriminator",
"on",
"the",
"i... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11798-L11812 | train | |
Rekord/rekord | build/rekord.js | function(input, remoteData)
{
if ( input instanceof Model )
{
return input;
}
var discriminatedValue = isValue( input ) ? input[ this.discriminator ] : null;
var model = this.discriminatorsToModel[ discriminatedValue ];
return model ? model.Database.parseModel( input, r... | javascript | function(input, remoteData)
{
if ( input instanceof Model )
{
return input;
}
var discriminatedValue = isValue( input ) ? input[ this.discriminator ] : null;
var model = this.discriminatorsToModel[ discriminatedValue ];
return model ? model.Database.parseModel( input, r... | [
"function",
"(",
"input",
",",
"remoteData",
")",
"{",
"if",
"(",
"input",
"instanceof",
"Model",
")",
"{",
"return",
"input",
";",
"}",
"var",
"discriminatedValue",
"=",
"isValue",
"(",
"input",
")",
"?",
"input",
"[",
"this",
".",
"discriminator",
"]",... | Takes input and returns a model instance. The input is expected to be an
object, any other type will return null.
@param {modelInput} input -
The input to parse to a model instance.
@param {Boolean} [remoteData=false] -
Whether or not the input is coming from a remote source.
@return {Rekord.Model} -
The model instanc... | [
"Takes",
"input",
"and",
"returns",
"a",
"model",
"instance",
".",
"The",
"input",
"is",
"expected",
"to",
"be",
"an",
"object",
"any",
"other",
"type",
"will",
"return",
"null",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L11825-L11836 | train | |
Rekord/rekord | build/rekord.js | function(database, field, options)
{
applyOptions( this, options, this.getDefaults( database, field, options ) );
this.database = database;
this.name = field;
this.options = options;
this.initialized = false;
this.property = this.property || (indexOf( database.fields, this.name ) !== false);
... | javascript | function(database, field, options)
{
applyOptions( this, options, this.getDefaults( database, field, options ) );
this.database = database;
this.name = field;
this.options = options;
this.initialized = false;
this.property = this.property || (indexOf( database.fields, this.name ) !== false);
... | [
"function",
"(",
"database",
",",
"field",
",",
"options",
")",
"{",
"applyOptions",
"(",
"this",
",",
"options",
",",
"this",
".",
"getDefaults",
"(",
"database",
",",
"field",
",",
"options",
")",
")",
";",
"this",
".",
"database",
"=",
"database",
"... | Initializes this relation with the given database, field, and options.
@param {Rekord.Database} database [description]
@param {String} field [description]
@param {Object} options [description] | [
"Initializes",
"this",
"relation",
"with",
"the",
"given",
"database",
"field",
"and",
"options",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L13758-L13780 | train | |
rossj/rackit | lib/rackit.js | function (cb) {
o1._client.auth(function (err) {
if (err && !(err instanceof Error)) {
err = new Error(err.message || err);
}
if (!err) {
o1.config = {
storage : o1._client._serviceUrl
};
}
cb(err);
});
} | javascript | function (cb) {
o1._client.auth(function (err) {
if (err && !(err instanceof Error)) {
err = new Error(err.message || err);
}
if (!err) {
o1.config = {
storage : o1._client._serviceUrl
};
}
cb(err);
});
} | [
"function",
"(",
"cb",
")",
"{",
"o1",
".",
"_client",
".",
"auth",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"&&",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"{",
"err",
"=",
"new",
"Error",
"(",
"err",
".",
"message",
"|... | First authenticate with Cloud Files | [
"First",
"authenticate",
"with",
"Cloud",
"Files"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L75-L88 | train | |
rossj/rackit | lib/rackit.js | function (cb) {
if (o1.options.tempURLKey) {
o1._log('Setting temporary URL key for account...');
o1._client.setTemporaryUrlKey(o1.options.tempURLKey, cb);
} else {
cb();
}
} | javascript | function (cb) {
if (o1.options.tempURLKey) {
o1._log('Setting temporary URL key for account...');
o1._client.setTemporaryUrlKey(o1.options.tempURLKey, cb);
} else {
cb();
}
} | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"o1",
".",
"options",
".",
"tempURLKey",
")",
"{",
"o1",
".",
"_log",
"(",
"'Setting temporary URL key for account...'",
")",
";",
"o1",
".",
"_client",
".",
"setTemporaryUrlKey",
"(",
"o1",
".",
"options",
".",
... | Set Account Metadata Key for public access | [
"Set",
"Account",
"Metadata",
"Key",
"for",
"public",
"access"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L96-L103 | train | |
rossj/rackit | lib/rackit.js | function (cb) {
o1._client.createContainer(sName, function (err, _container) {
if (err)
return cb(err);
// check that a parallel operation didn't just add the same container
container = _.find(o1.aContainers, { name : sName });
if (!container) {
o1.aContainers.push(_container);
conta... | javascript | function (cb) {
o1._client.createContainer(sName, function (err, _container) {
if (err)
return cb(err);
// check that a parallel operation didn't just add the same container
container = _.find(o1.aContainers, { name : sName });
if (!container) {
o1.aContainers.push(_container);
conta... | [
"function",
"(",
"cb",
")",
"{",
"o1",
".",
"_client",
".",
"createContainer",
"(",
"sName",
",",
"function",
"(",
"err",
",",
"_container",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"// check that a parallel operation didn't j... | Create the container | [
"Create",
"the",
"container"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L179-L194 | train | |
rossj/rackit | lib/rackit.js | function (cb) {
if (!o1.options.useCDN)
return cb();
o1._log('CDN enabling the container');
container.enableCdn(function (err, _container) {
if (err)
return cb(err);
// check that a parallel operation didn't just CDN enable the same container
var index = _.findIndex(o1.aContainers, { na... | javascript | function (cb) {
if (!o1.options.useCDN)
return cb();
o1._log('CDN enabling the container');
container.enableCdn(function (err, _container) {
if (err)
return cb(err);
// check that a parallel operation didn't just CDN enable the same container
var index = _.findIndex(o1.aContainers, { na... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"o1",
".",
"options",
".",
"useCDN",
")",
"return",
"cb",
"(",
")",
";",
"o1",
".",
"_log",
"(",
"'CDN enabling the container'",
")",
";",
"container",
".",
"enableCdn",
"(",
"function",
"(",
"err",
",... | CDN enable the container, if necessary | [
"CDN",
"enable",
"the",
"container",
"if",
"necessary"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L196-L213 | train | |
rossj/rackit | lib/rackit.js | function (err, results) {
if (err) {
return cb(err);
}
// Generate file id
var id = options.filename || utils.uid(24);
//
// Generate the headers to be send to Rackspace
//
var headers = {};
// set the content-length of transfer-encoding as appropriate
if (fromFile) {
headers['c... | javascript | function (err, results) {
if (err) {
return cb(err);
}
// Generate file id
var id = options.filename || utils.uid(24);
//
// Generate the headers to be send to Rackspace
//
var headers = {};
// set the content-length of transfer-encoding as appropriate
if (fromFile) {
headers['c... | [
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"// Generate file id",
"var",
"id",
"=",
"options",
".",
"filename",
"||",
"utils",
".",
"uid",
"(",
"24",
")",
";",
"//",
"/... | Final function of parallel.. create the request to add the file | [
"Final",
"function",
"of",
"parallel",
"..",
"create",
"the",
"request",
"to",
"add",
"the",
"file"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L328-L391 | train | |
rossj/rackit | lib/rackit.js | function (err) {
var i;
// If the extended option is off, just return cloudpaths
if (!options.extended) {
i = aObjects.length;
while (i--) {
aObjects[i] = aObjects[i].cloudpath;
}
}
cb(err, err ? undefined : aObjects);
} | javascript | function (err) {
var i;
// If the extended option is off, just return cloudpaths
if (!options.extended) {
i = aObjects.length;
while (i--) {
aObjects[i] = aObjects[i].cloudpath;
}
}
cb(err, err ? undefined : aObjects);
} | [
"function",
"(",
"err",
")",
"{",
"var",
"i",
";",
"// If the extended option is off, just return cloudpaths",
"if",
"(",
"!",
"options",
".",
"extended",
")",
"{",
"i",
"=",
"aObjects",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"aObjects",
"[... | Final function of forEach | [
"Final",
"function",
"of",
"forEach"
] | d5e5184980b00b993ef3eb448c2a5a763b9daf56 | https://github.com/rossj/rackit/blob/d5e5184980b00b993ef3eb448c2a5a763b9daf56/lib/rackit.js#L429-L441 | train | |
gerardobort/node-corenlp | examples/browser/tree/tree.js | collapse | function collapse(d) {
if (d.children) {
d._children = d.children;
d._children.forEach(collapse);
d.children = null;
}
} | javascript | function collapse(d) {
if (d.children) {
d._children = d.children;
d._children.forEach(collapse);
d.children = null;
}
} | [
"function",
"collapse",
"(",
"d",
")",
"{",
"if",
"(",
"d",
".",
"children",
")",
"{",
"d",
".",
"_children",
"=",
"d",
".",
"children",
";",
"d",
".",
"_children",
".",
"forEach",
"(",
"collapse",
")",
";",
"d",
".",
"children",
"=",
"null",
";"... | Collapse the node and all it's children | [
"Collapse",
"the",
"node",
"and",
"all",
"it",
"s",
"children"
] | c4461168a58950130c904785e6e7386bcebdad09 | https://github.com/gerardobort/node-corenlp/blob/c4461168a58950130c904785e6e7386bcebdad09/examples/browser/tree/tree.js#L89-L95 | train |
gerardobort/node-corenlp | examples/browser/tree/tree.js | click | function click(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
} | javascript | function click(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
} | [
"function",
"click",
"(",
"d",
")",
"{",
"if",
"(",
"d",
".",
"children",
")",
"{",
"d",
".",
"_children",
"=",
"d",
".",
"children",
";",
"d",
".",
"children",
"=",
"null",
";",
"}",
"else",
"{",
"d",
".",
"children",
"=",
"d",
".",
"_children... | Toggle children on click. | [
"Toggle",
"children",
"on",
"click",
"."
] | c4461168a58950130c904785e6e7386bcebdad09 | https://github.com/gerardobort/node-corenlp/blob/c4461168a58950130c904785e6e7386bcebdad09/examples/browser/tree/tree.js#L225-L234 | train |
relution-io/relution-sdk | lib/core/cipher.js | encryptJson | function encryptJson(password, json) {
return Q.all([
randomBytes(pbkdf2SaltLen),
randomBytes(cipherIvLen)
]).spread(function (salt, iv) {
return pbkdf2(password, salt, pbkdf2Iterations, pbkdf2KeyLen, pbkdf2Digest).then(function (key) {
var cipher = crypto.createCipheriv(ciph... | javascript | function encryptJson(password, json) {
return Q.all([
randomBytes(pbkdf2SaltLen),
randomBytes(cipherIvLen)
]).spread(function (salt, iv) {
return pbkdf2(password, salt, pbkdf2Iterations, pbkdf2KeyLen, pbkdf2Digest).then(function (key) {
var cipher = crypto.createCipheriv(ciph... | [
"function",
"encryptJson",
"(",
"password",
",",
"json",
")",
"{",
"return",
"Q",
".",
"all",
"(",
"[",
"randomBytes",
"(",
"pbkdf2SaltLen",
")",
",",
"randomBytes",
"(",
"cipherIvLen",
")",
"]",
")",
".",
"spread",
"(",
"function",
"(",
"salt",
",",
"... | encrypts a JSON object using a user-provided password.
This method is suitable for human-entered passwords and not appropriate for machine generated
passwords. Make sure to read regarding pbkdf2.
@param password of a human.
@param json to encode.
@return encoded json data.
@internal Not part of public API, exported ... | [
"encrypts",
"a",
"JSON",
"object",
"using",
"a",
"user",
"-",
"provided",
"password",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/core/cipher.js#L52-L73 | train |
relution-io/relution-sdk | lib/core/cipher.js | decryptJson | function decryptJson(password, data) {
var salt = new Buffer(data.salt, 'base64');
return pbkdf2(password, salt, pbkdf2Iterations, pbkdf2KeyLen, pbkdf2Digest).then(function (key) {
var iv = new Buffer(data.iv, 'base64');
var decipher = crypto.createDecipheriv(cipherAlgorithm, key, iv);
v... | javascript | function decryptJson(password, data) {
var salt = new Buffer(data.salt, 'base64');
return pbkdf2(password, salt, pbkdf2Iterations, pbkdf2KeyLen, pbkdf2Digest).then(function (key) {
var iv = new Buffer(data.iv, 'base64');
var decipher = crypto.createDecipheriv(cipherAlgorithm, key, iv);
v... | [
"function",
"decryptJson",
"(",
"password",
",",
"data",
")",
"{",
"var",
"salt",
"=",
"new",
"Buffer",
"(",
"data",
".",
"salt",
",",
"'base64'",
")",
";",
"return",
"pbkdf2",
"(",
"password",
",",
"salt",
",",
"pbkdf2Iterations",
",",
"pbkdf2KeyLen",
"... | decrypts some encoded json data.
@param password of a human.
@param data encoded json data.
@return json to decoded.
@internal Not part of public API, exported for library use only. | [
"decrypts",
"some",
"encoded",
"json",
"data",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/core/cipher.js#L84-L97 | train |
banphlet/HubtelMobilePayment | lib/onlinecheckout.js | OnlineCheckout | function OnlineCheckout(body) {
if (!body) throw new Error('No data provided')
const config = this.config
const hubtelurl =
'https://api.hubtel.com/v1/merchantaccount/onlinecheckout/invoice/create'
const auth =
'Basic ' +
Buffer.from(config.clientid + ':' + config.secretid).toString('base64')
r... | javascript | function OnlineCheckout(body) {
if (!body) throw new Error('No data provided')
const config = this.config
const hubtelurl =
'https://api.hubtel.com/v1/merchantaccount/onlinecheckout/invoice/create'
const auth =
'Basic ' +
Buffer.from(config.clientid + ':' + config.secretid).toString('base64')
r... | [
"function",
"OnlineCheckout",
"(",
"body",
")",
"{",
"if",
"(",
"!",
"body",
")",
"throw",
"new",
"Error",
"(",
"'No data provided'",
")",
"const",
"config",
"=",
"this",
".",
"config",
"const",
"hubtelurl",
"=",
"'https://api.hubtel.com/v1/merchantaccount/onlinec... | Use Hubtel Online Checkout Service
@param {object} body | [
"Use",
"Hubtel",
"Online",
"Checkout",
"Service"
] | 6308e35e0d0c3a1567f94bfee3039f74eee8e480 | https://github.com/banphlet/HubtelMobilePayment/blob/6308e35e0d0c3a1567f94bfee3039f74eee8e480/lib/onlinecheckout.js#L7-L25 | train |
canjs/can-query-logic | compat/compat.js | function(raw){
var clone = canReflect.serialize(raw);
if(clone.page) {
clone[offset] = clone.page.start;
clone[limit] = (clone.page.end - clone.page.start) + 1;
delete clone.page;
}
... | javascript | function(raw){
var clone = canReflect.serialize(raw);
if(clone.page) {
clone[offset] = clone.page.start;
clone[limit] = (clone.page.end - clone.page.start) + 1;
delete clone.page;
}
... | [
"function",
"(",
"raw",
")",
"{",
"var",
"clone",
"=",
"canReflect",
".",
"serialize",
"(",
"raw",
")",
";",
"if",
"(",
"clone",
".",
"page",
")",
"{",
"clone",
"[",
"offset",
"]",
"=",
"clone",
".",
"page",
".",
"start",
";",
"clone",
"[",
"limi... | taking the normal format and putting it back page.start -> start page.end -> end | [
"taking",
"the",
"normal",
"format",
"and",
"putting",
"it",
"back",
"page",
".",
"start",
"-",
">",
"start",
"page",
".",
"end",
"-",
">",
"end"
] | fe32908e7aa36853362fbc1a4df276193247f38d | https://github.com/canjs/can-query-logic/blob/fe32908e7aa36853362fbc1a4df276193247f38d/compat/compat.js#L228-L236 | train | |
saneki-discontinued/node-toxcore | lib/toxerror.js | ToxError | function ToxError(type, code, message) {
this.name = "ToxError";
this.type = ( type || "ToxError" );
this.code = ( code || 0 ); // 0 = unsuccessful
this.message = ( message || (this.type + ": " + this.code) );
Error.captureStackTrace(this, ToxError);
} | javascript | function ToxError(type, code, message) {
this.name = "ToxError";
this.type = ( type || "ToxError" );
this.code = ( code || 0 ); // 0 = unsuccessful
this.message = ( message || (this.type + ": " + this.code) );
Error.captureStackTrace(this, ToxError);
} | [
"function",
"ToxError",
"(",
"type",
",",
"code",
",",
"message",
")",
"{",
"this",
".",
"name",
"=",
"\"ToxError\"",
";",
"this",
".",
"type",
"=",
"(",
"type",
"||",
"\"ToxError\"",
")",
";",
"this",
".",
"code",
"=",
"(",
"code",
"||",
"0",
")",... | Creates a ToxError instance
@class
@param {String} type of error
@param {Number} code of type
@param {String} message of error | [
"Creates",
"a",
"ToxError",
"instance"
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/lib/toxerror.js#L30-L36 | train |
banphlet/HubtelMobilePayment | lib/checkstatus.js | CheckStatus | function CheckStatus(token) {
if (!token) throw 'Invoice Token must be provided'
const config = this.config
const hubtelurl = `https://api.hubtel.com/v1/merchantaccount/onlinecheckout/invoice/status/${token}`
const auth =
'Basic ' +
Buffer.from(config.clientid + ':' + config.secretid).toString('base64'... | javascript | function CheckStatus(token) {
if (!token) throw 'Invoice Token must be provided'
const config = this.config
const hubtelurl = `https://api.hubtel.com/v1/merchantaccount/onlinecheckout/invoice/status/${token}`
const auth =
'Basic ' +
Buffer.from(config.clientid + ':' + config.secretid).toString('base64'... | [
"function",
"CheckStatus",
"(",
"token",
")",
"{",
"if",
"(",
"!",
"token",
")",
"throw",
"'Invoice Token must be provided'",
"const",
"config",
"=",
"this",
".",
"config",
"const",
"hubtelurl",
"=",
"`",
"${",
"token",
"}",
"`",
"const",
"auth",
"=",
"'Ba... | Check the Status of Hubtel online-checkout Transaction
@param {String} token | [
"Check",
"the",
"Status",
"of",
"Hubtel",
"online",
"-",
"checkout",
"Transaction"
] | 6308e35e0d0c3a1567f94bfee3039f74eee8e480 | https://github.com/banphlet/HubtelMobilePayment/blob/6308e35e0d0c3a1567f94bfee3039f74eee8e480/lib/checkstatus.js#L7-L22 | train |
canjs/can-query-logic | src/serializers/basic-query.js | hydrateAndValue | function hydrateAndValue(value, prop, SchemaType, hydrateChild) {
// The `SchemaType` is the type of value on `instances` of
// the schema. `Instances` values are different from `Set` values.
if (SchemaType) {
// If there's a `SetType`, we will use that
var SetType = SchemaType[setTypeSymbol];
if (SetType) {
... | javascript | function hydrateAndValue(value, prop, SchemaType, hydrateChild) {
// The `SchemaType` is the type of value on `instances` of
// the schema. `Instances` values are different from `Set` values.
if (SchemaType) {
// If there's a `SetType`, we will use that
var SetType = SchemaType[setTypeSymbol];
if (SetType) {
... | [
"function",
"hydrateAndValue",
"(",
"value",
",",
"prop",
",",
"SchemaType",
",",
"hydrateChild",
")",
"{",
"// The `SchemaType` is the type of value on `instances` of",
"// the schema. `Instances` values are different from `Set` values.",
"if",
"(",
"SchemaType",
")",
"{",
"//... | This is used to hydrate a value directly within a `filter`'s And. | [
"This",
"is",
"used",
"to",
"hydrate",
"a",
"value",
"directly",
"within",
"a",
"filter",
"s",
"And",
"."
] | fe32908e7aa36853362fbc1a4df276193247f38d | https://github.com/canjs/can-query-logic/blob/fe32908e7aa36853362fbc1a4df276193247f38d/src/serializers/basic-query.js#L40-L98 | train |
relution-io/relution-sdk | lib/livedata/SyncContext.spec.js | loadCollection | function loadCollection(collection, data) {
return Q(collection.fetch()).then(function () {
// delete all before running tests
return Q.all(collection.models.slice().map(function (model) {
return model.destroy();
})).then(function () {
chai_1.a... | javascript | function loadCollection(collection, data) {
return Q(collection.fetch()).then(function () {
// delete all before running tests
return Q.all(collection.models.slice().map(function (model) {
return model.destroy();
})).then(function () {
chai_1.a... | [
"function",
"loadCollection",
"(",
"collection",
",",
"data",
")",
"{",
"return",
"Q",
"(",
"collection",
".",
"fetch",
"(",
")",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// delete all before running tests",
"return",
"Q",
".",
"all",
"(",
"colle... | loads data using collection, returns promise on collection, collection is empty afterwards | [
"loads",
"data",
"using",
"collection",
"returns",
"promise",
"on",
"collection",
"collection",
"is",
"empty",
"afterwards"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/livedata/SyncContext.spec.js#L71-L92 | train |
hhff/ember-chimp | addon/components/ember-chimp.js | endsWith | function endsWith(string, suffix) {
return string.indexOf(suffix, string.length - suffix.length) !== -1;
} | javascript | function endsWith(string, suffix) {
return string.indexOf(suffix, string.length - suffix.length) !== -1;
} | [
"function",
"endsWith",
"(",
"string",
",",
"suffix",
")",
"{",
"return",
"string",
".",
"indexOf",
"(",
"suffix",
",",
"string",
".",
"length",
"-",
"suffix",
".",
"length",
")",
"!==",
"-",
"1",
";",
"}"
] | A utility method for checking the end of a string
for a certain value.
@method endsWith
@param {String} string The string to check.
@param {String} suffix The suffix to check the string for.
@private
@return {Boolean} A boolean that indicates whether the suffix is present. | [
"A",
"utility",
"method",
"for",
"checking",
"the",
"end",
"of",
"a",
"string",
"for",
"a",
"certain",
"value",
"."
] | 796a737f58965f16ad574df19c44f77eca528df1 | https://github.com/hhff/ember-chimp/blob/796a737f58965f16ad574df19c44f77eca528df1/addon/components/ember-chimp.js#L22-L24 | train |
peerigon/erroz | lib/defaultRenderer.js | defaultRenderer | function defaultRenderer(template, data) {
return template.replace(/%\w+/g, function (match) {
return data[match.slice(1)];
});
} | javascript | function defaultRenderer(template, data) {
return template.replace(/%\w+/g, function (match) {
return data[match.slice(1)];
});
} | [
"function",
"defaultRenderer",
"(",
"template",
",",
"data",
")",
"{",
"return",
"template",
".",
"replace",
"(",
"/",
"%\\w+",
"/",
"g",
",",
"function",
"(",
"match",
")",
"{",
"return",
"data",
"[",
"match",
".",
"slice",
"(",
"1",
")",
"]",
";",
... | replaces all %placeHolder with data.placeHolder
@param {String} template
@param {Object} data
@returns {String} | [
"replaces",
"all",
"%placeHolder",
"with",
"data",
".",
"placeHolder"
] | 57adf5fa7a86680da2c6460b81aaaceaa57db6bd | https://github.com/peerigon/erroz/blob/57adf5fa7a86680da2c6460b81aaaceaa57db6bd/lib/defaultRenderer.js#L10-L14 | train |
relution-io/relution-sdk | lib/core/objectid.js | makeObjectID | function makeObjectID() {
return hexString(8, Date.now() / 1000) +
hexString(6, machineId) +
hexString(4, processId) +
hexString(6, counter++); // a 3-byte counter, starting with a random value.
} | javascript | function makeObjectID() {
return hexString(8, Date.now() / 1000) +
hexString(6, machineId) +
hexString(4, processId) +
hexString(6, counter++); // a 3-byte counter, starting with a random value.
} | [
"function",
"makeObjectID",
"(",
")",
"{",
"return",
"hexString",
"(",
"8",
",",
"Date",
".",
"now",
"(",
")",
"/",
"1000",
")",
"+",
"hexString",
"(",
"6",
",",
"machineId",
")",
"+",
"hexString",
"(",
"4",
",",
"processId",
")",
"+",
"hexString",
... | random-based impl of Mongo ObjectID | [
"random",
"-",
"based",
"impl",
"of",
"Mongo",
"ObjectID"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/core/objectid.js#L36-L41 | train |
fergiemcdowall/search-index-adder | lib/delete.js | function (key) {
if (key === undefined) {
that.push({
key: 'DOCUMENT' + sep + docId + sep,
lastPass: true
})
return end()
}
that.options.indexes.get(key, function (err, val) {
if (!err) {
that.push({
key: key,
value:... | javascript | function (key) {
if (key === undefined) {
that.push({
key: 'DOCUMENT' + sep + docId + sep,
lastPass: true
})
return end()
}
that.options.indexes.get(key, function (err, val) {
if (!err) {
that.push({
key: key,
value:... | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"key",
"===",
"undefined",
")",
"{",
"that",
".",
"push",
"(",
"{",
"key",
":",
"'DOCUMENT'",
"+",
"sep",
"+",
"docId",
"+",
"sep",
",",
"lastPass",
":",
"true",
"}",
")",
"return",
"end",
"(",
")",
... | get value from db and push it to the stream | [
"get",
"value",
"from",
"db",
"and",
"push",
"it",
"to",
"the",
"stream"
] | 5c0fc40fbff4bb4912a5e8ba542cb88a650efd11 | https://github.com/fergiemcdowall/search-index-adder/blob/5c0fc40fbff4bb4912a5e8ba542cb88a650efd11/lib/delete.js#L43-L60 | train | |
relution-io/relution-sdk | server/mongodb_rest.js | function(req, res, fromMessage) {
var name = req.params.name;
var doc = req.body;
var id = this.toId(req.params.id || doc._id);
if (typeof id === 'undefined' || id === '') {
return res.send(400, "invalid id.");
}
doc._id = id;
... | javascript | function(req, res, fromMessage) {
var name = req.params.name;
var doc = req.body;
var id = this.toId(req.params.id || doc._id);
if (typeof id === 'undefined' || id === '') {
return res.send(400, "invalid id.");
}
doc._id = id;
... | [
"function",
"(",
"req",
",",
"res",
",",
"fromMessage",
")",
"{",
"var",
"name",
"=",
"req",
".",
"params",
".",
"name",
";",
"var",
"doc",
"=",
"req",
".",
"body",
";",
"var",
"id",
"=",
"this",
".",
"toId",
"(",
"req",
".",
"params",
".",
"id... | Update a document | [
"Update",
"a",
"document"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/mongodb_rest.js#L185-L218 | train | |
relution-io/relution-sdk | server/mongodb_rest.js | function(req, res, fromMessage) {
var name = req.params.name;
var id = this.toId(req.params.id);
if (typeof id === 'undefined' || id === '') {
return res.send(400, "invalid id.");
}
var doc = {};
doc._id = id;
doc.... | javascript | function(req, res, fromMessage) {
var name = req.params.name;
var id = this.toId(req.params.id);
if (typeof id === 'undefined' || id === '') {
return res.send(400, "invalid id.");
}
var doc = {};
doc._id = id;
doc.... | [
"function",
"(",
"req",
",",
"res",
",",
"fromMessage",
")",
"{",
"var",
"name",
"=",
"req",
".",
"params",
".",
"name",
";",
"var",
"id",
"=",
"this",
".",
"toId",
"(",
"req",
".",
"params",
".",
"id",
")",
";",
"if",
"(",
"typeof",
"id",
"===... | Delete a contact | [
"Delete",
"a",
"contact"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/mongodb_rest.js#L221-L267 | train | |
relution-io/relution-sdk | server/mongodb_rest.js | function(entity, msg) {
if (!msg._id) {
msg._id = new ObjectID();
}
var collection = new mongodb.Collection(this.db, "__msg__" + entity);
if (msg.method === 'delete' && (msg.id === 'all' || msg.id === 'clean')) {
collection.remove(function ... | javascript | function(entity, msg) {
if (!msg._id) {
msg._id = new ObjectID();
}
var collection = new mongodb.Collection(this.db, "__msg__" + entity);
if (msg.method === 'delete' && (msg.id === 'all' || msg.id === 'clean')) {
collection.remove(function ... | [
"function",
"(",
"entity",
",",
"msg",
")",
"{",
"if",
"(",
"!",
"msg",
".",
"_id",
")",
"{",
"msg",
".",
"_id",
"=",
"new",
"ObjectID",
"(",
")",
";",
"}",
"var",
"collection",
"=",
"new",
"mongodb",
".",
"Collection",
"(",
"this",
".",
"db",
... | save a new change message | [
"save",
"a",
"new",
"change",
"message"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/mongodb_rest.js#L270-L284 | train | |
relution-io/relution-sdk | server/mongodb_rest.js | function(entity, time, callback) {
var collection = new mongodb.Collection(this.db, "__msg__" + entity);
time = parseInt(time);
if (time || time === 0) {
collection.ensureIndex(
{ time: 1, id: 1 },
{ unique:true, background:true... | javascript | function(entity, time, callback) {
var collection = new mongodb.Collection(this.db, "__msg__" + entity);
time = parseInt(time);
if (time || time === 0) {
collection.ensureIndex(
{ time: 1, id: 1 },
{ unique:true, background:true... | [
"function",
"(",
"entity",
",",
"time",
",",
"callback",
")",
"{",
"var",
"collection",
"=",
"new",
"mongodb",
".",
"Collection",
"(",
"this",
".",
"db",
",",
"\"__msg__\"",
"+",
"entity",
")",
";",
"time",
"=",
"parseInt",
"(",
"time",
")",
";",
"if... | read the change message, since time | [
"read",
"the",
"change",
"message",
"since",
"time"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/mongodb_rest.js#L287-L322 | train | |
relution-io/relution-sdk | lib/livedata/SyncEndpoint.js | hashCode | function hashCode() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var hash = 0;
for (var i = 0; i < args.length; ++i) {
var str = args[i] || '';
for (var j = 0, l = str.length; j < l; ++j) {
var char = str.charCod... | javascript | function hashCode() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var hash = 0;
for (var i = 0; i < args.length; ++i) {
var str = args[i] || '';
for (var j = 0, l = str.length; j < l; ++j) {
var char = str.charCod... | [
"function",
"hashCode",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"_i",
"=",
"0",
";",
"_i",
"<",
"arguments",
".",
"length",
";",
"_i",
"++",
")",
"{",
"args",
"[",
"_i",
"-",
"0",
"]",
"=",
"arguments",
"[",
"_i",... | very simple hash coding implementation.
@internal For library use only. | [
"very",
"simple",
"hash",
"coding",
"implementation",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/livedata/SyncEndpoint.js#L31-L46 | train |
flumedb/aligned-block-file | blocks.js | readInteger | function readInteger(width, reader) {
return function (start, cb) {
var i = Math.floor(start/block_size)
var _i = start%block_size
//if the UInt32BE aligns with in a block
//read directly and it's 3x faster.
if(_i < block_size - width)
get(i, function (err, block) {
... | javascript | function readInteger(width, reader) {
return function (start, cb) {
var i = Math.floor(start/block_size)
var _i = start%block_size
//if the UInt32BE aligns with in a block
//read directly and it's 3x faster.
if(_i < block_size - width)
get(i, function (err, block) {
... | [
"function",
"readInteger",
"(",
"width",
",",
"reader",
")",
"{",
"return",
"function",
"(",
"start",
",",
"cb",
")",
"{",
"var",
"i",
"=",
"Math",
".",
"floor",
"(",
"start",
"/",
"block_size",
")",
"var",
"_i",
"=",
"start",
"%",
"block_size",
"//i... | start by reading the end of the last block. this must always be kept in memory. | [
"start",
"by",
"reading",
"the",
"end",
"of",
"the",
"last",
"block",
".",
"this",
"must",
"always",
"be",
"kept",
"in",
"memory",
"."
] | 5361e46459f0836e2c8ec597d795c42a1a783d91 | https://github.com/flumedb/aligned-block-file/blob/5361e46459f0836e2c8ec597d795c42a1a783d91/blocks.js#L85-L107 | train |
relution-io/relution-sdk | server/backend/routes/push.js | init | function init(app) {
app.post('/api/v1/push/registration',
/**
* register the device on the push Service
*
* @param req containing body JSON to pass as input.
* @param res result of call is provided as JSON body data.
* @param next function to invoke error handling.
*/
function serv... | javascript | function init(app) {
app.post('/api/v1/push/registration',
/**
* register the device on the push Service
*
* @param req containing body JSON to pass as input.
* @param res result of call is provided as JSON body data.
* @param next function to invoke error handling.
*/
function serv... | [
"function",
"init",
"(",
"app",
")",
"{",
"app",
".",
"post",
"(",
"'/api/v1/push/registration'",
",",
"/**\n * register the device on the push Service\n *\n * @param req containing body JSON to pass as input.\n * @param res result of call is provided as JSON body data.\n * @p... | module providing direct access to push.
registers a push target device.
<p>
The method attempts fetching an existing device using the metadata
information given. This either works by providing a UUID or using
heuristics based on information typically extracted using Cordova device
plugin. The latter approach solves t... | [
"module",
"providing",
"direct",
"access",
"to",
"push",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/backend/routes/push.js#L24-L58 | train |
relution-io/relution-sdk | server/backend/routes/push.js | serviceCall | function serviceCall(req, res, next) {
Q(pushService.registerPushDevice(req.body)).then(res.json.bind(res), next).done();
} | javascript | function serviceCall(req, res, next) {
Q(pushService.registerPushDevice(req.body)).then(res.json.bind(res), next).done();
} | [
"function",
"serviceCall",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"Q",
"(",
"pushService",
".",
"registerPushDevice",
"(",
"req",
".",
"body",
")",
")",
".",
"then",
"(",
"res",
".",
"json",
".",
"bind",
"(",
"res",
")",
",",
"next",
")",
... | register the device on the push Service
@param req containing body JSON to pass as input.
@param res result of call is provided as JSON body data.
@param next function to invoke error handling. | [
"register",
"the",
"device",
"on",
"the",
"push",
"Service"
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/backend/routes/push.js#L33-L35 | train |
syntax-tree/hast-util-to-parse5 | index.js | patch | function patch(node, p5, parentSchema) {
var schema = parentSchema
var position = node.position
var children = node.children
var childNodes = []
var length = children ? children.length : 0
var index = -1
var child
if (node.type === 'element') {
if (schema.space === 'html' && node.tagName === 'svg')... | javascript | function patch(node, p5, parentSchema) {
var schema = parentSchema
var position = node.position
var children = node.children
var childNodes = []
var length = children ? children.length : 0
var index = -1
var child
if (node.type === 'element') {
if (schema.space === 'html' && node.tagName === 'svg')... | [
"function",
"patch",
"(",
"node",
",",
"p5",
",",
"parentSchema",
")",
"{",
"var",
"schema",
"=",
"parentSchema",
"var",
"position",
"=",
"node",
".",
"position",
"var",
"children",
"=",
"node",
".",
"children",
"var",
"childNodes",
"=",
"[",
"]",
"var",... | Patch specific properties. | [
"Patch",
"specific",
"properties",
"."
] | d1a90057eca4a38986e94c2220b692531d678335 | https://github.com/syntax-tree/hast-util-to-parse5/blob/d1a90057eca4a38986e94c2220b692531d678335/index.js#L112-L151 | train |
relution-io/relution-sdk | lib/web/urls.js | resolveServer | function resolveServer(path, options) {
if (options === void 0) { options = {}; }
var serverUrl = options.serverUrl || init.initOptions.serverUrl;
if (path) {
if (serverUrl) {
path = url.resolve(serverUrl, path);
}
}
else {
path = serverUrl;
}
return url.r... | javascript | function resolveServer(path, options) {
if (options === void 0) { options = {}; }
var serverUrl = options.serverUrl || init.initOptions.serverUrl;
if (path) {
if (serverUrl) {
path = url.resolve(serverUrl, path);
}
}
else {
path = serverUrl;
}
return url.r... | [
"function",
"resolveServer",
"(",
"path",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"serverUrl",
"=",
"options",
".",
"serverUrl",
"||",
"init",
".",
"initOptions",
".",
"... | computes a server url from a given path.
@param path path to resolve, relative or absolute.
@param options of server in effect.
@return {string} absolute URL of server. | [
"computes",
"a",
"server",
"url",
"from",
"a",
"given",
"path",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/web/urls.js#L36-L48 | train |
relution-io/relution-sdk | lib/web/urls.js | resolveUrl | function resolveUrl(path, options) {
if (options === void 0) { options = {}; }
var serverUrl = resolveServer(path, options);
if (!serverUrl) {
return path;
}
if (path.charAt(0) !== '/') {
// construct full application url
var tenantOrga = options.tenantOrga;
if (!tena... | javascript | function resolveUrl(path, options) {
if (options === void 0) { options = {}; }
var serverUrl = resolveServer(path, options);
if (!serverUrl) {
return path;
}
if (path.charAt(0) !== '/') {
// construct full application url
var tenantOrga = options.tenantOrga;
if (!tena... | [
"function",
"resolveUrl",
"(",
"path",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"serverUrl",
"=",
"resolveServer",
"(",
"path",
",",
"options",
")",
";",
"if",
"(",
"!"... | computes a url from a given path.
- absolute URLs are used as is, e.g.
``http://192.168.0.10:8080/mway/myapp/api/v1/some_endpoint`` stays as is,
- machine-relative URLs beginning with ``/`` are resolved against the Relution server logged
into, so that ``/gofer/.../rest/...``-style URLs work as expected, for example
``... | [
"computes",
"a",
"url",
"from",
"a",
"given",
"path",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/web/urls.js#L69-L98 | train |
relution-io/relution-sdk | lib/web/urls.js | resolveApp | function resolveApp(baseAliasOrNameOrApp, options) {
if (options === void 0) { options = {}; }
// defaults on arguments given
var url;
if (!baseAliasOrNameOrApp) {
url = options.application || init.initOptions.application;
}
else if (_.isString(baseAliasOrNameOrApp)) {
url = base... | javascript | function resolveApp(baseAliasOrNameOrApp, options) {
if (options === void 0) { options = {}; }
// defaults on arguments given
var url;
if (!baseAliasOrNameOrApp) {
url = options.application || init.initOptions.application;
}
else if (_.isString(baseAliasOrNameOrApp)) {
url = base... | [
"function",
"resolveApp",
"(",
"baseAliasOrNameOrApp",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"// defaults on arguments given",
"var",
"url",
";",
"if",
"(",
"!",
"baseAliasOrNameOrAp... | computes the basepath of a BaaS application.
@param baseAliasOrNameOrApp baseAlias of application, may be name when baseAlias is not changed
by developer or application metadata object of Relution server.
@param options of server in effect.
@return {string} absolute URL of application alias on current server. | [
"computes",
"the",
"basepath",
"of",
"a",
"BaaS",
"application",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/web/urls.js#L108-L127 | train |
relution-io/relution-sdk | lib/livedata/Store.js | isStore | function isStore(object) {
if (!object || typeof object !== 'object') {
return false;
}
else if ('isStore' in object) {
diag.debug.assert(function () { return object.isStore === Store.prototype.isPrototypeOf(object); });
return object.isStore;
}
else {
return Store.pr... | javascript | function isStore(object) {
if (!object || typeof object !== 'object') {
return false;
}
else if ('isStore' in object) {
diag.debug.assert(function () { return object.isStore === Store.prototype.isPrototypeOf(object); });
return object.isStore;
}
else {
return Store.pr... | [
"function",
"isStore",
"(",
"object",
")",
"{",
"if",
"(",
"!",
"object",
"||",
"typeof",
"object",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"'isStore'",
"in",
"object",
")",
"{",
"diag",
".",
"debug",
".",
"assert... | tests whether a given object is a Store.
@param {object} object to check.
@return {boolean} whether object is a Store. | [
"tests",
"whether",
"a",
"given",
"object",
"is",
"a",
"Store",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/livedata/Store.js#L37-L48 | train |
swagen/swagen | lib/utils.js | loadConfig | function loadConfig(justJson) {
if (!justJson) {
const configScript = path.resolve(currentDir, configScriptFileName);
if (fs.existsSync(configScript)) {
return require(configScript);
}
}
const configJson = path.resolve(currentDir, configJsonFileName);
if (fs.existsSy... | javascript | function loadConfig(justJson) {
if (!justJson) {
const configScript = path.resolve(currentDir, configScriptFileName);
if (fs.existsSync(configScript)) {
return require(configScript);
}
}
const configJson = path.resolve(currentDir, configJsonFileName);
if (fs.existsSy... | [
"function",
"loadConfig",
"(",
"justJson",
")",
"{",
"if",
"(",
"!",
"justJson",
")",
"{",
"const",
"configScript",
"=",
"path",
".",
"resolve",
"(",
"currentDir",
",",
"configScriptFileName",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"configScrip... | Loads the correct configuration from the current directory.
@returns {Object} Configuration object | [
"Loads",
"the",
"correct",
"configuration",
"from",
"the",
"current",
"directory",
"."
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/lib/utils.js#L39-L62 | train |
relution-io/relution-sdk | server/backend/routes/connectors.js | init | function init(app) {
app.post('/api/v1/connectors/:connection',
/**
* installs session data such as credentials.
*
* @param req containing body JSON to pass as input.
* @param res result of call is provided as JSON body data.
* @param next function to invoke error handling.
*/
... | javascript | function init(app) {
app.post('/api/v1/connectors/:connection',
/**
* installs session data such as credentials.
*
* @param req containing body JSON to pass as input.
* @param res result of call is provided as JSON body data.
* @param next function to invoke error handling.
*/
... | [
"function",
"init",
"(",
"app",
")",
"{",
"app",
".",
"post",
"(",
"'/api/v1/connectors/:connection'",
",",
"/**\n * installs session data such as credentials.\n *\n * @param req containing body JSON to pass as input.\n * @param res result of call is provided as JSON body dat... | module providing direct access to connectors.
Used by Relution SDK connectors module for direct access to backend servers. If you do not want
or need this functionality, the routes defined herein can be removed.
@param app express.js application to hook into. | [
"module",
"providing",
"direct",
"access",
"to",
"connectors",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/backend/routes/connectors.js#L16-L40 | train |
relution-io/relution-sdk | server/backend/routes/connectors.js | serviceCall | function serviceCall(req, res, next) {
connector.configureSession(req.params.connection, req.body);
res.send(204); // success --> 204 no content
} | javascript | function serviceCall(req, res, next) {
connector.configureSession(req.params.connection, req.body);
res.send(204); // success --> 204 no content
} | [
"function",
"serviceCall",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"connector",
".",
"configureSession",
"(",
"req",
".",
"params",
".",
"connection",
",",
"req",
".",
"body",
")",
";",
"res",
".",
"send",
"(",
"204",
")",
";",
"// success --> 2... | installs session data such as credentials.
@param req containing body JSON to pass as input.
@param res result of call is provided as JSON body data.
@param next function to invoke error handling. | [
"installs",
"session",
"data",
"such",
"as",
"credentials",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/backend/routes/connectors.js#L25-L28 | train |
relution-io/relution-sdk | server/backend/routes/connectors.js | serviceCall | function serviceCall(req, res, next) {
connector.runCall(req.params.connection, req.params.call, req.body).then(res.json.bind(res), next).done();
} | javascript | function serviceCall(req, res, next) {
connector.runCall(req.params.connection, req.params.call, req.body).then(res.json.bind(res), next).done();
} | [
"function",
"serviceCall",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"connector",
".",
"runCall",
"(",
"req",
".",
"params",
".",
"connection",
",",
"req",
".",
"params",
".",
"call",
",",
"req",
".",
"body",
")",
".",
"then",
"(",
"res",
".",... | calls directly into a service connection.
@param req containing body JSON to pass as input.
@param res result of call is provided as JSON body data.
@param next function to invoke error handling. | [
"calls",
"directly",
"into",
"a",
"service",
"connection",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/server/backend/routes/connectors.js#L37-L39 | train |
saneki-discontinued/node-toxcore | examples/bin/old/promises-example.js | function(callback) {
// Asynchronously set our name and status message using promises
Promise.join(
tox.setNameAsync('Bluebird'),
tox.setStatusMessageAsync('Some status message')
).then(function() {
console.log('Successfully set name and status message!');
callback();
}).catch(function(err) {
... | javascript | function(callback) {
// Asynchronously set our name and status message using promises
Promise.join(
tox.setNameAsync('Bluebird'),
tox.setStatusMessageAsync('Some status message')
).then(function() {
console.log('Successfully set name and status message!');
callback();
}).catch(function(err) {
... | [
"function",
"(",
"callback",
")",
"{",
"// Asynchronously set our name and status message using promises",
"Promise",
".",
"join",
"(",
"tox",
".",
"setNameAsync",
"(",
"'Bluebird'",
")",
",",
"tox",
".",
"setStatusMessageAsync",
"(",
"'Some status message'",
")",
")",
... | Initialize ourself. Sets name and status message.
@private | [
"Initialize",
"ourself",
".",
"Sets",
"name",
"and",
"status",
"message",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/examples/bin/old/promises-example.js#L72-L84 | train | |
saneki-discontinued/node-toxcore | examples/bin/old/promises-example.js | function(callback) {
tox.on('friendRequest', function(evt) {
console.log('Accepting friend request from ' + evt.publicKeyHex());
// Automatically accept the request
tox.addFriendNoRequestAsync(evt.publicKey()).then(function() {
console.log('Successfully accepted the friend request!');
}).catch(f... | javascript | function(callback) {
tox.on('friendRequest', function(evt) {
console.log('Accepting friend request from ' + evt.publicKeyHex());
// Automatically accept the request
tox.addFriendNoRequestAsync(evt.publicKey()).then(function() {
console.log('Successfully accepted the friend request!');
}).catch(f... | [
"function",
"(",
"callback",
")",
"{",
"tox",
".",
"on",
"(",
"'friendRequest'",
",",
"function",
"(",
"evt",
")",
"{",
"console",
".",
"log",
"(",
"'Accepting friend request from '",
"+",
"evt",
".",
"publicKeyHex",
"(",
")",
")",
";",
"// Automatically acc... | Initialize our callbacks, listening for friend requests and messages. | [
"Initialize",
"our",
"callbacks",
"listening",
"for",
"friend",
"requests",
"and",
"messages",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/examples/bin/old/promises-example.js#L89-L124 | train | |
saneki-discontinued/node-toxcore | examples/bin/old/promises-example.js | function(callback) {
async.parallelAsync([
tox.addGroupchat.bind(tox),
tox.getAV().addGroupchat.bind(tox.getAV())
]).then(function(results) {
groupchats['text'] = results[0];
groupchats['av'] = results[1];
}).finally(callback);
} | javascript | function(callback) {
async.parallelAsync([
tox.addGroupchat.bind(tox),
tox.getAV().addGroupchat.bind(tox.getAV())
]).then(function(results) {
groupchats['text'] = results[0];
groupchats['av'] = results[1];
}).finally(callback);
} | [
"function",
"(",
"callback",
")",
"{",
"async",
".",
"parallelAsync",
"(",
"[",
"tox",
".",
"addGroupchat",
".",
"bind",
"(",
"tox",
")",
",",
"tox",
".",
"getAV",
"(",
")",
".",
"addGroupchat",
".",
"bind",
"(",
"tox",
".",
"getAV",
"(",
")",
")",... | Initialize the groupchats, and call the callback when finished. | [
"Initialize",
"the",
"groupchats",
"and",
"call",
"the",
"callback",
"when",
"finished",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/examples/bin/old/promises-example.js#L129-L137 | train | |
swagen/swagen | cli.js | handleCommandError | function handleCommandError(ex) {
// If the command throws an exception, display the error message and command help.
if (ex instanceof Error) {
console.log(chalk.red(ex.message));
} else {
console.log(chalk.red(ex));
}
console.log();
const helpArgs = {
_: [command]
};... | javascript | function handleCommandError(ex) {
// If the command throws an exception, display the error message and command help.
if (ex instanceof Error) {
console.log(chalk.red(ex.message));
} else {
console.log(chalk.red(ex));
}
console.log();
const helpArgs = {
_: [command]
};... | [
"function",
"handleCommandError",
"(",
"ex",
")",
"{",
"// If the command throws an exception, display the error message and command help.",
"if",
"(",
"ex",
"instanceof",
"Error",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"red",
"(",
"ex",
".",
"message",
... | If the command throws an exception, display the error message and command help
@param {*} ex The thrown exception | [
"If",
"the",
"command",
"throws",
"an",
"exception",
"display",
"the",
"error",
"message",
"and",
"command",
"help"
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/cli.js#L57-L69 | train |
saneki-discontinued/node-toxcore | lib/old/toxencryptsave.js | function(tox, opts) {
// If one argument and not tox, assume opts
if(arguments.length === 1 && !(tox instanceof Tox)) {
opts = tox;
tox = undefined;
}
if(!(tox instanceof Tox)) {
tox = undefined;
//var err = new Error('Tox instance required for ToxEncryptSave');
//throw err;
}
if(!opts... | javascript | function(tox, opts) {
// If one argument and not tox, assume opts
if(arguments.length === 1 && !(tox instanceof Tox)) {
opts = tox;
tox = undefined;
}
if(!(tox instanceof Tox)) {
tox = undefined;
//var err = new Error('Tox instance required for ToxEncryptSave');
//throw err;
}
if(!opts... | [
"function",
"(",
"tox",
",",
"opts",
")",
"{",
"// If one argument and not tox, assume opts",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
"&&",
"!",
"(",
"tox",
"instanceof",
"Tox",
")",
")",
"{",
"opts",
"=",
"tox",
";",
"tox",
"=",
"undefined",
... | Construct a new ToxEncryptSave.
@class
@param {Tox} [tox] Tox instance
@param {Object} [opts] Options
@param {String} [opts.path] toxencryptsave library path, will
use the default if not specified
@param {Boolean} [opts.sync=true] If true, will have async methods behave
like sync methods if no callback given | [
"Construct",
"a",
"new",
"ToxEncryptSave",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/lib/old/toxencryptsave.js#L47-L74 | train | |
banphlet/HubtelMobilePayment | index.js | HubtelMobilePayment | function HubtelMobilePayment({
secretid = required('secretid'),
clientid = required('clientid'),
merchantaccnumber = required('merchantaccnumber'),
}) {
this.config = {}
this.config['clientid'] = clientid
this.config['secretid'] = secretid
this.config['merchantaccnumber'] = merchantaccnumber
this.hubtel... | javascript | function HubtelMobilePayment({
secretid = required('secretid'),
clientid = required('clientid'),
merchantaccnumber = required('merchantaccnumber'),
}) {
this.config = {}
this.config['clientid'] = clientid
this.config['secretid'] = secretid
this.config['merchantaccnumber'] = merchantaccnumber
this.hubtel... | [
"function",
"HubtelMobilePayment",
"(",
"{",
"secretid",
"=",
"required",
"(",
"'secretid'",
")",
",",
"clientid",
"=",
"required",
"(",
"'clientid'",
")",
",",
"merchantaccnumber",
"=",
"required",
"(",
"'merchantaccnumber'",
")",
",",
"}",
")",
"{",
"this",
... | Set up Hubtel authentication
@param {object} data | [
"Set",
"up",
"Hubtel",
"authentication"
] | 6308e35e0d0c3a1567f94bfee3039f74eee8e480 | https://github.com/banphlet/HubtelMobilePayment/blob/6308e35e0d0c3a1567f94bfee3039f74eee8e480/index.js#L13-L23 | train |
silvermine/eslint-plugin-silvermine | lib/rules/brace-style.js | validateCurlyPair | function validateCurlyPair(openingCurly, closingCurly) {
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly),
tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly),
tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly),
sing... | javascript | function validateCurlyPair(openingCurly, closingCurly) {
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly),
tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly),
tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly),
sing... | [
"function",
"validateCurlyPair",
"(",
"openingCurly",
",",
"closingCurly",
")",
"{",
"const",
"tokenBeforeOpeningCurly",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"openingCurly",
")",
",",
"tokenAfterOpeningCurly",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"o... | Validates a pair of curly brackets based on the user's config
@param {Token} openingCurly The opening curly bracket
@param {Token} closingCurly The closing curly bracket
@returns {void} | [
"Validates",
"a",
"pair",
"of",
"curly",
"brackets",
"based",
"on",
"the",
"user",
"s",
"config"
] | 2eac37fcaa4cfa86ad7a36793e4a8908e90bfbb6 | https://github.com/silvermine/eslint-plugin-silvermine/blob/2eac37fcaa4cfa86ad7a36793e4a8908e90bfbb6/lib/rules/brace-style.js#L97-L137 | train |
relution-io/relution-sdk | lib/livedata/Model.js | isModel | function isModel(object) {
if (!object || typeof object !== 'object') {
return false;
}
else if ('isModel' in object) {
diag.debug.assert(function () { return object.isModel === Model.prototype.isPrototypeOf(object); });
return object.isModel;
}
else {
return Model.pr... | javascript | function isModel(object) {
if (!object || typeof object !== 'object') {
return false;
}
else if ('isModel' in object) {
diag.debug.assert(function () { return object.isModel === Model.prototype.isPrototypeOf(object); });
return object.isModel;
}
else {
return Model.pr... | [
"function",
"isModel",
"(",
"object",
")",
"{",
"if",
"(",
"!",
"object",
"||",
"typeof",
"object",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"'isModel'",
"in",
"object",
")",
"{",
"diag",
".",
"debug",
".",
"assert... | tests whether a given object is a Model.
@param {object} object to check.
@return {boolean} whether object is a Model. | [
"tests",
"whether",
"a",
"given",
"object",
"is",
"a",
"Model",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/livedata/Model.js#L40-L51 | train |
saneki-discontinued/node-toxcore | examples/bin/dns-example.js | function(dnsaddr) {
var domain = getAddressDomain(dnsaddr);
if(domain !== undefined && clients[domain] !== undefined)
return clients[domain];
} | javascript | function(dnsaddr) {
var domain = getAddressDomain(dnsaddr);
if(domain !== undefined && clients[domain] !== undefined)
return clients[domain];
} | [
"function",
"(",
"dnsaddr",
")",
"{",
"var",
"domain",
"=",
"getAddressDomain",
"(",
"dnsaddr",
")",
";",
"if",
"(",
"domain",
"!==",
"undefined",
"&&",
"clients",
"[",
"domain",
"]",
"!==",
"undefined",
")",
"return",
"clients",
"[",
"domain",
"]",
";",... | Get the ToxDns client for a specific address.
@param {String} dnsaddr - Address (ex. 'user@toxme.io')
@return {ToxDns} client to use for the given address, or undefined if none
for the address domain | [
"Get",
"the",
"ToxDns",
"client",
"for",
"a",
"specific",
"address",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/examples/bin/dns-example.js#L47-L51 | train | |
saneki-discontinued/node-toxcore | lib/toxdns.js | function(opts) {
if(!opts) opts = {};
var libpath = opts['path'];
var key = opts['key'];
this._library = this._createLibrary(libpath);
this._initKey(key);
this._initHandle(this._key);
} | javascript | function(opts) {
if(!opts) opts = {};
var libpath = opts['path'];
var key = opts['key'];
this._library = this._createLibrary(libpath);
this._initKey(key);
this._initHandle(this._key);
} | [
"function",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
")",
"opts",
"=",
"{",
"}",
";",
"var",
"libpath",
"=",
"opts",
"[",
"'path'",
"]",
";",
"var",
"key",
"=",
"opts",
"[",
"'key'",
"]",
";",
"this",
".",
"_library",
"=",
"this",
".",
... | Creates a ToxDns instance.
@class
@param {Object} [opts] Options
@param {String} [opts.path] Path to libtoxdns.so
@param {(Buffer|String)} [opts.key] Public key of ToxDns3 service | [
"Creates",
"a",
"ToxDns",
"instance",
"."
] | 45dfb339f4e8a58888fca175528dee13f075824a | https://github.com/saneki-discontinued/node-toxcore/blob/45dfb339f4e8a58888fca175528dee13f075824a/lib/toxdns.js#L50-L58 | train | |
canjs/can-query-logic | src/types/values-not.js | function(not, primitive){
// NOT(5) U 5
if( set.isEqual( not.value, primitive) ) {
return set.UNIVERSAL;
}
// NOT(4) U 6
else {
throw new Error("Not,Identity Union is not filled out");
}
} | javascript | function(not, primitive){
// NOT(5) U 5
if( set.isEqual( not.value, primitive) ) {
return set.UNIVERSAL;
}
// NOT(4) U 6
else {
throw new Error("Not,Identity Union is not filled out");
}
} | [
"function",
"(",
"not",
",",
"primitive",
")",
"{",
"// NOT(5) U 5",
"if",
"(",
"set",
".",
"isEqual",
"(",
"not",
".",
"value",
",",
"primitive",
")",
")",
"{",
"return",
"set",
".",
"UNIVERSAL",
";",
"}",
"// NOT(4) U 6",
"else",
"{",
"throw",
"new",... | not 5 and not 6 | [
"not",
"5",
"and",
"not",
"6"
] | fe32908e7aa36853362fbc1a4df276193247f38d | https://github.com/canjs/can-query-logic/blob/fe32908e7aa36853362fbc1a4df276193247f38d/src/types/values-not.js#L49-L58 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (url, options) {
return Object.keys(options).reduce(this._replacePlaceholderInUrl.bind(this, options), url);
} | javascript | function (url, options) {
return Object.keys(options).reduce(this._replacePlaceholderInUrl.bind(this, options), url);
} | [
"function",
"(",
"url",
",",
"options",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"reduce",
"(",
"this",
".",
"_replacePlaceholderInUrl",
".",
"bind",
"(",
"this",
",",
"options",
")",
",",
"url",
")",
";",
"}"
] | Parses an JSON Wire protocol dummy url
@method parseUrl
@param {string} url URL with placeholders
@param {object} options List of url options
@return {string} url Parsed URL | [
"Parses",
"an",
"JSON",
"Wire",
"protocol",
"dummy",
"url"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L53-L55 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (options, cb, wd, params) {
// if no cb is given, generate a body with the `desiredCapabilities` object
if (!cb) {
// check if we have parameters set up
if (Object.keys(params).length > 0) {
return JSON.stringify(params);
}
return '';
}
// invo... | javascript | function (options, cb, wd, params) {
// if no cb is given, generate a body with the `desiredCapabilities` object
if (!cb) {
// check if we have parameters set up
if (Object.keys(params).length > 0) {
return JSON.stringify(params);
}
return '';
}
// invo... | [
"function",
"(",
"options",
",",
"cb",
",",
"wd",
",",
"params",
")",
"{",
"// if no cb is given, generate a body with the `desiredCapabilities` object",
"if",
"(",
"!",
"cb",
")",
"{",
"// check if we have parameters set up",
"if",
"(",
"Object",
".",
"keys",
"(",
... | Generates the message body for webdriver client requests of type POST
@method generateBody
@param {object} options Browser options (name, bin path, etc.)
@param {function|undefined} cb Callback function that should be invoked to generate the message body
@param {Dalek.Internal.Webdriver} wd Webdriver base object
@para... | [
"Generates",
"the",
"message",
"body",
"for",
"webdriver",
"client",
"requests",
"of",
"type",
"POST"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L113-L126 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (hostname, port, prefix, url, method, body, auth) {
var options = {
hostname: hostname,
port: port,
path: prefix + url,
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Content-Length': Buffer.byteLength(body, 'utf8'... | javascript | function (hostname, port, prefix, url, method, body, auth) {
var options = {
hostname: hostname,
port: port,
path: prefix + url,
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Content-Length': Buffer.byteLength(body, 'utf8'... | [
"function",
"(",
"hostname",
",",
"port",
",",
"prefix",
",",
"url",
",",
"method",
",",
"body",
",",
"auth",
")",
"{",
"var",
"options",
"=",
"{",
"hostname",
":",
"hostname",
",",
"port",
":",
"port",
",",
"path",
":",
"prefix",
"+",
"url",
",",
... | Generates the request options for a webdriver client request
@method generateRequestOptions
@param {string} hostname Hostname of the webdriver server
@param {integer} port Port of the webdriver server
@param {string} prefix Url address prefix of the webdriver endpoint
@param {string} url Url of the webdriver method
@p... | [
"Generates",
"the",
"request",
"options",
"for",
"a",
"webdriver",
"client",
"request"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L141-L159 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (remote, driver) {
return function webdriverCommand() {
var deferred = Q.defer();
// the request meta data
var params = Driver.generateParamset(remote.params, arguments);
var body = Driver.generateBody({}, remote.onRequest, this, params);
var options = Driver.gener... | javascript | function (remote, driver) {
return function webdriverCommand() {
var deferred = Q.defer();
// the request meta data
var params = Driver.generateParamset(remote.params, arguments);
var body = Driver.generateBody({}, remote.onRequest, this, params);
var options = Driver.gener... | [
"function",
"(",
"remote",
",",
"driver",
")",
"{",
"return",
"function",
"webdriverCommand",
"(",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"// the request meta data",
"var",
"params",
"=",
"Driver",
".",
"generateParamset",
"(",
... | Generates the webdriver callback function
@method _generateWebdriverCommand
@param {object} remote Dummy request body (function name, url, method)
@param {DalekJs.Internal.Driver} driver Driver instance
@return {function} webdriverCommand Generated webdriver command function
@private | [
"Generates",
"the",
"webdriver",
"callback",
"function"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L188-L203 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (driver, remote, options, deferred, response) {
this.data = '';
response.on('data', driver._concatDataChunks.bind(this));
response.on('end', driver._onResponseEnd.bind(this, driver, response, remote, options, deferred));
return this;
} | javascript | function (driver, remote, options, deferred, response) {
this.data = '';
response.on('data', driver._concatDataChunks.bind(this));
response.on('end', driver._onResponseEnd.bind(this, driver, response, remote, options, deferred));
return this;
} | [
"function",
"(",
"driver",
",",
"remote",
",",
"options",
",",
"deferred",
",",
"response",
")",
"{",
"this",
".",
"data",
"=",
"''",
";",
"response",
".",
"on",
"(",
"'data'",
",",
"driver",
".",
"_concatDataChunks",
".",
"bind",
"(",
"this",
")",
"... | Response callback function
@method _onResponse
@param {DalekJs.Internal.Driver} driver Driver instance
@param {object} remote Dummy request body (function name, url, method)
@param {object} options Request options (method, port, path, headers, etc.)
@param {object} deferred Webdriver command deferred
@param {object} r... | [
"Response",
"callback",
"function"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L218-L223 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (driver, response, remote, options, deferred) {
return driver[(response.statusCode === 500 ? '_onError' : '_onSuccess')].bind(this)(driver, response, remote, options, deferred);
} | javascript | function (driver, response, remote, options, deferred) {
return driver[(response.statusCode === 500 ? '_onError' : '_onSuccess')].bind(this)(driver, response, remote, options, deferred);
} | [
"function",
"(",
"driver",
",",
"response",
",",
"remote",
",",
"options",
",",
"deferred",
")",
"{",
"return",
"driver",
"[",
"(",
"response",
".",
"statusCode",
"===",
"500",
"?",
"'_onError'",
":",
"'_onSuccess'",
")",
"]",
".",
"bind",
"(",
"this",
... | Response end callback function
@method _onResponseEnd
@param {DalekJs.Internal.Driver} driver Driver instance
@param {object} response Response from the webdriver server
@param {object} remote Dummy request body (function name, url, method)
@param {object} options Request options (method, port, path, headers, etc.)
@p... | [
"Response",
"end",
"callback",
"function"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L251-L253 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (driver, response, remote, options, deferred) {
// Provide a default error handler to prevent hangs.
if (!remote.onError) {
remote.onError = function (request, remote, options, deferred, data) {
data = JSON.parse(data);
var value = -1;
if (typeof data.value.mes... | javascript | function (driver, response, remote, options, deferred) {
// Provide a default error handler to prevent hangs.
if (!remote.onError) {
remote.onError = function (request, remote, options, deferred, data) {
data = JSON.parse(data);
var value = -1;
if (typeof data.value.mes... | [
"function",
"(",
"driver",
",",
"response",
",",
"remote",
",",
"options",
",",
"deferred",
")",
"{",
"// Provide a default error handler to prevent hangs.",
"if",
"(",
"!",
"remote",
".",
"onError",
")",
"{",
"remote",
".",
"onError",
"=",
"function",
"(",
"r... | On error callback function
@method _onError
@param {DalekJs.Internal.Driver} driver Driver instance
@param {object} response Response from the webdriver server
@param {object} remote Dummy request body (function name, url, method)
@param {object} options Request options (method, port, path, headers, etc.)
@param {obje... | [
"On",
"error",
"callback",
"function"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L268-L283 | train | |
dalekjs/dalek-internal-webdriver | lib/driver.js | function (driver, response, remote, options, deferred) {
// log response data
this.events.emit('driver:webdriver:response', {
statusCode: response.statusCode,
method: response.req.method,
path: response.req.path,
data: this.data
});
if (remote.onResponse) {... | javascript | function (driver, response, remote, options, deferred) {
// log response data
this.events.emit('driver:webdriver:response', {
statusCode: response.statusCode,
method: response.req.method,
path: response.req.path,
data: this.data
});
if (remote.onResponse) {... | [
"function",
"(",
"driver",
",",
"response",
",",
"remote",
",",
"options",
",",
"deferred",
")",
"{",
"// log response data",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:webdriver:response'",
",",
"{",
"statusCode",
":",
"response",
".",
"statusCode",
",... | On success callback function
@method _onSuccess
@param {DalekJs.Internal.Driver} driver Driver instance
@param {object} response Response from the webdriver server
@param {object} remote Dummy request body (function name, url, method)
@param {object} options Request options (method, port, path, headers, etc.)
@param {... | [
"On",
"success",
"callback",
"function"
] | 1b857e99f0ef5d045f355eabcf991378ed98279c | https://github.com/dalekjs/dalek-internal-webdriver/blob/1b857e99f0ef5d045f355eabcf991378ed98279c/lib/driver.js#L298-L313 | train | |
swagen/swagen | lib/generate/index.js | handleFileSwagger | function handleFileSwagger(profile, profileKey) {
const inputFilePath = path.resolve(currentDir, profile.file);
console.log(chalk`{green [${profileKey}]} Input swagger file : {cyan ${inputFilePath}}`);
fs.readFile(inputFilePath, 'utf8', (error, swagger) => {
if (error) {
console.log(chal... | javascript | function handleFileSwagger(profile, profileKey) {
const inputFilePath = path.resolve(currentDir, profile.file);
console.log(chalk`{green [${profileKey}]} Input swagger file : {cyan ${inputFilePath}}`);
fs.readFile(inputFilePath, 'utf8', (error, swagger) => {
if (error) {
console.log(chal... | [
"function",
"handleFileSwagger",
"(",
"profile",
",",
"profileKey",
")",
"{",
"const",
"inputFilePath",
"=",
"path",
".",
"resolve",
"(",
"currentDir",
",",
"profile",
".",
"file",
")",
";",
"console",
".",
"log",
"(",
"chalk",
"`",
"${",
"profileKey",
"}"... | Reads the swagger json from a file specified in the profile.
@param {Profile} profile - The profile being handled.
@param {String} profileKey - The name of the profile. | [
"Reads",
"the",
"swagger",
"json",
"from",
"a",
"file",
"specified",
"in",
"the",
"profile",
"."
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/lib/generate/index.js#L73-L84 | train |
swagen/swagen | lib/generate/index.js | handleUrlSwagger | function handleUrlSwagger(profile, profileKey) {
console.log(chalk`{green [${profileKey}]} Input swagger URL : {cyan ${profile.url}}`);
const options = {
rejectUnauthorized: false
};
needle.get(profile.url, options, (err, resp, body) => {
if (err) {
console.log(chalk`{red Can... | javascript | function handleUrlSwagger(profile, profileKey) {
console.log(chalk`{green [${profileKey}]} Input swagger URL : {cyan ${profile.url}}`);
const options = {
rejectUnauthorized: false
};
needle.get(profile.url, options, (err, resp, body) => {
if (err) {
console.log(chalk`{red Can... | [
"function",
"handleUrlSwagger",
"(",
"profile",
",",
"profileKey",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
"`",
"${",
"profileKey",
"}",
"${",
"profile",
".",
"url",
"}",
"`",
")",
";",
"const",
"options",
"=",
"{",
"rejectUnauthorized",
":",
"fal... | Reads the swagger json from a URL specified in the profile.
@param {Profile} profile The profile being handled.
@param {String} profileKey The name of the profile. | [
"Reads",
"the",
"swagger",
"json",
"from",
"a",
"URL",
"specified",
"in",
"the",
"profile",
"."
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/lib/generate/index.js#L91-L104 | train |
swagen/swagen | lib/generate/index.js | verifyProfile | function verifyProfile(profile, profileKey) {
if (!profile.file && !profile.url) {
throw new Error(`[${profileKey}] Must specify a file or url in the configuration.`);
}
if (!profile.output) {
throw new Error(`[${profileKey}] Must specify an output file path in the configuration.`);
}
... | javascript | function verifyProfile(profile, profileKey) {
if (!profile.file && !profile.url) {
throw new Error(`[${profileKey}] Must specify a file or url in the configuration.`);
}
if (!profile.output) {
throw new Error(`[${profileKey}] Must specify an output file path in the configuration.`);
}
... | [
"function",
"verifyProfile",
"(",
"profile",
",",
"profileKey",
")",
"{",
"if",
"(",
"!",
"profile",
".",
"file",
"&&",
"!",
"profile",
".",
"url",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"profileKey",
"}",
"`",
")",
";",
"}",
"if",
"(",... | Ensure that the profile structure is valid. | [
"Ensure",
"that",
"the",
"profile",
"structure",
"is",
"valid",
"."
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/lib/generate/index.js#L109-L129 | train |
swagen/swagen | lib/generate/index.js | processInputs | function processInputs(config) {
for (const profileKey in config) {
const profile = config[profileKey];
if (profile.skip) {
continue;
}
verifyProfile(profile, profileKey);
if (profile.file) {
handleFileSwagger(profile, profileKey);
} else {
... | javascript | function processInputs(config) {
for (const profileKey in config) {
const profile = config[profileKey];
if (profile.skip) {
continue;
}
verifyProfile(profile, profileKey);
if (profile.file) {
handleFileSwagger(profile, profileKey);
} else {
... | [
"function",
"processInputs",
"(",
"config",
")",
"{",
"for",
"(",
"const",
"profileKey",
"in",
"config",
")",
"{",
"const",
"profile",
"=",
"config",
"[",
"profileKey",
"]",
";",
"if",
"(",
"profile",
".",
"skip",
")",
"{",
"continue",
";",
"}",
"verif... | Iterates through each profile in the config and handles the swagger.
@param {Object} config Configuration object | [
"Iterates",
"through",
"each",
"profile",
"in",
"the",
"config",
"and",
"handles",
"the",
"swagger",
"."
] | cd8b032942d9fa9184243012ceecfeb179948340 | https://github.com/swagen/swagen/blob/cd8b032942d9fa9184243012ceecfeb179948340/lib/generate/index.js#L135-L150 | train |
phase2/generator-gadget | generators/lib/drupalProjectVersion.js | toMinorRange | function toMinorRange(version) {
var regex = /^\d+\.\d+/;
var range = version.match(regex);
if (range) {
return '^' + range[0];
}
else {
var regex = /^\d+\.x/;
var range = version.match(regex);
if (range) {
return range[0];
}
}
return version;
} | javascript | function toMinorRange(version) {
var regex = /^\d+\.\d+/;
var range = version.match(regex);
if (range) {
return '^' + range[0];
}
else {
var regex = /^\d+\.x/;
var range = version.match(regex);
if (range) {
return range[0];
}
}
return version;
} | [
"function",
"toMinorRange",
"(",
"version",
")",
"{",
"var",
"regex",
"=",
"/",
"^\\d+\\.\\d+",
"/",
";",
"var",
"range",
"=",
"version",
".",
"match",
"(",
"regex",
")",
";",
"if",
"(",
"range",
")",
"{",
"return",
"'^'",
"+",
"range",
"[",
"0",
"... | Convert a semantic version to a minor range.
In composer.json entries for Drupal core or other major projects, we often
want to designate the version similar to '^8.2'. This code converts version
strings that may have a pre-release suffix to such a range.
Furthermore, there are some edge cases wherein we may want to ... | [
"Convert",
"a",
"semantic",
"version",
"to",
"a",
"minor",
"range",
"."
] | 8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d | https://github.com/phase2/generator-gadget/blob/8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d/generators/lib/drupalProjectVersion.js#L113-L128 | train |
phase2/generator-gadget | generators/lib/drupalProjectVersion.js | toDrupalMajorVersion | function toDrupalMajorVersion(version) {
var regex = /^(\d+)\.\d+\.[x\d+]/;
var match = version.match(regex)
if (match) {
return match[1] + '.x';
}
return version;
} | javascript | function toDrupalMajorVersion(version) {
var regex = /^(\d+)\.\d+\.[x\d+]/;
var match = version.match(regex)
if (match) {
return match[1] + '.x';
}
return version;
} | [
"function",
"toDrupalMajorVersion",
"(",
"version",
")",
"{",
"var",
"regex",
"=",
"/",
"^(\\d+)\\.\\d+\\.[x\\d+]",
"/",
";",
"var",
"match",
"=",
"version",
".",
"match",
"(",
"regex",
")",
"if",
"(",
"match",
")",
"{",
"return",
"match",
"[",
"1",
"]",... | The Drupal update system uses a pre-semver approach of version numbering.
Major versions must be in the form of "8.x", as opposed to other semver
ranges or version numbers. | [
"The",
"Drupal",
"update",
"system",
"uses",
"a",
"pre",
"-",
"semver",
"approach",
"of",
"version",
"numbering",
"."
] | 8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d | https://github.com/phase2/generator-gadget/blob/8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d/generators/lib/drupalProjectVersion.js#L136-L144 | train |
phase2/generator-gadget | generators/lib/drupalProjectVersion.js | isCached | function isCached(project, majorVersion) {
var cid = project+majorVersion;
return cache[cid] && cache[cid].short_name[0] == project && cache[cid].api_version[0] == majorVersion;
} | javascript | function isCached(project, majorVersion) {
var cid = project+majorVersion;
return cache[cid] && cache[cid].short_name[0] == project && cache[cid].api_version[0] == majorVersion;
} | [
"function",
"isCached",
"(",
"project",
",",
"majorVersion",
")",
"{",
"var",
"cid",
"=",
"project",
"+",
"majorVersion",
";",
"return",
"cache",
"[",
"cid",
"]",
"&&",
"cache",
"[",
"cid",
"]",
".",
"short_name",
"[",
"0",
"]",
"==",
"project",
"&&",
... | Determine if we have successfully cached the release data. | [
"Determine",
"if",
"we",
"have",
"successfully",
"cached",
"the",
"release",
"data",
"."
] | 8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d | https://github.com/phase2/generator-gadget/blob/8ebc9a6f7592ebc37844cd2aec346c2e00aaa91d/generators/lib/drupalProjectVersion.js#L149-L152 | train |
GenesysPureEngage/provisioning-client-js | src/internal/code-gen/provisioning-api/model/AddUserDataData.js | function(userName, firstName, lastName, password) {
var _this = this;
_this['userName'] = userName;
_this['firstName'] = firstName;
_this['lastName'] = lastName;
_this['password'] = password;
} | javascript | function(userName, firstName, lastName, password) {
var _this = this;
_this['userName'] = userName;
_this['firstName'] = firstName;
_this['lastName'] = lastName;
_this['password'] = password;
} | [
"function",
"(",
"userName",
",",
"firstName",
",",
"lastName",
",",
"password",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"_this",
"[",
"'userName'",
"]",
"=",
"userName",
";",
"_this",
"[",
"'firstName'",
"]",
"=",
"firstName",
";",
"_this",
"[",
"... | The AddUserDataData model module.
@module model/AddUserDataData
@version 9.0.000.46.3206
Constructs a new <code>AddUserDataData</code>.
@alias module:model/AddUserDataData
@class
@param userName {String} The user's unique login.
@param firstName {String} The user's first name.
@param lastName {String} The user's last... | [
"The",
"AddUserDataData",
"model",
"module",
"."
] | 8d5e1ed6bf75bedf1a580091b9f197670ea98041 | https://github.com/GenesysPureEngage/provisioning-client-js/blob/8d5e1ed6bf75bedf1a580091b9f197670ea98041/src/internal/code-gen/provisioning-api/model/AddUserDataData.js#L51-L79 | train | |
canjs/can-query-logic | src/types/basic-query.js | BasicQuery | function BasicQuery(query) {
assign(this, query);
if (!this.filter) {
this.filter = set.UNIVERSAL;
}
if (!this.page) {
this.page = new RecordRange();
}
if (!this.sort) {
this.sort = "id";
}
if (typeof this.sort === "string") {
this.sort = new DefaultSort(this.sort);
}
} | javascript | function BasicQuery(query) {
assign(this, query);
if (!this.filter) {
this.filter = set.UNIVERSAL;
}
if (!this.page) {
this.page = new RecordRange();
}
if (!this.sort) {
this.sort = "id";
}
if (typeof this.sort === "string") {
this.sort = new DefaultSort(this.sort);
}
} | [
"function",
"BasicQuery",
"(",
"query",
")",
"{",
"assign",
"(",
"this",
",",
"query",
")",
";",
"if",
"(",
"!",
"this",
".",
"filter",
")",
"{",
"this",
".",
"filter",
"=",
"set",
".",
"UNIVERSAL",
";",
"}",
"if",
"(",
"!",
"this",
".",
"page",
... | Define the BasicQuery type | [
"Define",
"the",
"BasicQuery",
"type"
] | fe32908e7aa36853362fbc1a4df276193247f38d | https://github.com/canjs/can-query-logic/blob/fe32908e7aa36853362fbc1a4df276193247f38d/src/types/basic-query.js#L136-L150 | train |
JS-DevTools/globify | lib/parsed-args.js | ParsedArgs | function ParsedArgs (args) {
/**
* The command to run ("browserify" or "watchify")
* @type {string}
*/
this.cmd = "browserify";
/**
* The base directory for the entry-file glob pattern.
* See {@link helpers#getBaseDir} for details.
* @type {string}
*/
this.baseDir = "";
/**
* Options... | javascript | function ParsedArgs (args) {
/**
* The command to run ("browserify" or "watchify")
* @type {string}
*/
this.cmd = "browserify";
/**
* The base directory for the entry-file glob pattern.
* See {@link helpers#getBaseDir} for details.
* @type {string}
*/
this.baseDir = "";
/**
* Options... | [
"function",
"ParsedArgs",
"(",
"args",
")",
"{",
"/**\n * The command to run (\"browserify\" or \"watchify\")\n * @type {string}\n */",
"this",
".",
"cmd",
"=",
"\"browserify\"",
";",
"/**\n * The base directory for the entry-file glob pattern.\n * See {@link helpers#getBaseDir} ... | Parses the command-line arguments and replaces glob patterns with functions to expand those patterns.
@param {string[]} args - All command-line arguments, most of which will simply be passed to Browserify
@constructor | [
"Parses",
"the",
"command",
"-",
"line",
"arguments",
"and",
"replaces",
"glob",
"patterns",
"with",
"functions",
"to",
"expand",
"those",
"patterns",
"."
] | 650a0a8727982427c5d1d66e1094b0e23a15a8b6 | https://github.com/JS-DevTools/globify/blob/650a0a8727982427c5d1d66e1094b0e23a15a8b6/lib/parsed-args.js#L16-L69 | train |
relution-io/relution-sdk | lib/livedata/WebSqlStore.js | openDatabase | function openDatabase(options) {
var db;
var sqlitePlugin = 'sqlitePlugin';
if (global[sqlitePlugin]) {
// device implementation
options = _.clone(options);
if (!options.key) {
if (options.security) {
options.key = options.security;
delete ... | javascript | function openDatabase(options) {
var db;
var sqlitePlugin = 'sqlitePlugin';
if (global[sqlitePlugin]) {
// device implementation
options = _.clone(options);
if (!options.key) {
if (options.security) {
options.key = options.security;
delete ... | [
"function",
"openDatabase",
"(",
"options",
")",
"{",
"var",
"db",
";",
"var",
"sqlitePlugin",
"=",
"'sqlitePlugin'",
";",
"if",
"(",
"global",
"[",
"sqlitePlugin",
"]",
")",
"{",
"// device implementation",
"options",
"=",
"_",
".",
"clone",
"(",
"options",... | openDatabase of browser or via require websql.
@internal Not public API, exported for testing purposes only! | [
"openDatabase",
"of",
"browser",
"or",
"via",
"require",
"websql",
"."
] | 776b8bd0c249428add03f97ba2d19092e709bc7b | https://github.com/relution-io/relution-sdk/blob/776b8bd0c249428add03f97ba2d19092e709bc7b/lib/livedata/WebSqlStore.js#L43-L86 | train |
peerigon/erroz | lib/index.js | erroz | function erroz(error) {
var errorFn = function (data) {
//apply all attributes on the instance
for (var errKey in errorFn.prototype) {
if (errorFn.prototype.hasOwnProperty(errKey)) {
this[errKey] = errorFn.prototype[errKey];
}
}
//overwrite ... | javascript | function erroz(error) {
var errorFn = function (data) {
//apply all attributes on the instance
for (var errKey in errorFn.prototype) {
if (errorFn.prototype.hasOwnProperty(errKey)) {
this[errKey] = errorFn.prototype[errKey];
}
}
//overwrite ... | [
"function",
"erroz",
"(",
"error",
")",
"{",
"var",
"errorFn",
"=",
"function",
"(",
"data",
")",
"{",
"//apply all attributes on the instance",
"for",
"(",
"var",
"errKey",
"in",
"errorFn",
".",
"prototype",
")",
"{",
"if",
"(",
"errorFn",
".",
"prototype",... | generate Error-classes based on ErrozError
@param error
@returns {Function} | [
"generate",
"Error",
"-",
"classes",
"based",
"on",
"ErrozError"
] | 57adf5fa7a86680da2c6460b81aaaceaa57db6bd | https://github.com/peerigon/erroz/blob/57adf5fa7a86680da2c6460b81aaaceaa57db6bd/lib/index.js#L14-L71 | train |
OpusCapita/npm-scripts | bin/update-changelog.js | metadata | function metadata(log, value) {
var lines = value.split('\n');
log.commit = lines[0].split(' ')[1];
log.author = lines[1].split(':')[1].trim();
log.date = lines[2].slice(8);
return log
} | javascript | function metadata(log, value) {
var lines = value.split('\n');
log.commit = lines[0].split(' ')[1];
log.author = lines[1].split(':')[1].trim();
log.date = lines[2].slice(8);
return log
} | [
"function",
"metadata",
"(",
"log",
",",
"value",
")",
"{",
"var",
"lines",
"=",
"value",
".",
"split",
"(",
"'\\n'",
")",
";",
"log",
".",
"commit",
"=",
"lines",
"[",
"0",
"]",
".",
"split",
"(",
"' '",
")",
"[",
"1",
"]",
";",
"log",
".",
... | parse git log | [
"parse",
"git",
"log"
] | d70c80f48ebbd862c84617de834d239cecd17023 | https://github.com/OpusCapita/npm-scripts/blob/d70c80f48ebbd862c84617de834d239cecd17023/bin/update-changelog.js#L36-L42 | train |
djgrant/heidelberg | js/lib/hammer.js | stopDefaultBrowserBehavior | function stopDefaultBrowserBehavior(element, css_props) {
if(!css_props || !element || !element.style) {
return;
}
// with css properties for modern browsers
Hammer.utils.each(['webkit', 'khtml', 'moz', 'Moz', 'ms', 'o', ''], function(vendor) {
Hammer.utils.each(css_props, function(value, p... | javascript | function stopDefaultBrowserBehavior(element, css_props) {
if(!css_props || !element || !element.style) {
return;
}
// with css properties for modern browsers
Hammer.utils.each(['webkit', 'khtml', 'moz', 'Moz', 'ms', 'o', ''], function(vendor) {
Hammer.utils.each(css_props, function(value, p... | [
"function",
"stopDefaultBrowserBehavior",
"(",
"element",
",",
"css_props",
")",
"{",
"if",
"(",
"!",
"css_props",
"||",
"!",
"element",
"||",
"!",
"element",
".",
"style",
")",
"{",
"return",
";",
"}",
"// with css properties for modern browsers",
"Hammer",
"."... | stop browser default behavior with css props
@param {HtmlElement} element
@param {Object} css_props | [
"stop",
"browser",
"default",
"behavior",
"with",
"css",
"props"
] | 151e254962055c1c4d7705a5eb277b96cb9a7849 | https://github.com/djgrant/heidelberg/blob/151e254962055c1c4d7705a5eb277b96cb9a7849/js/lib/hammer.js#L303-L335 | train |
djgrant/heidelberg | js/lib/hammer.js | detect | function detect(eventData) {
if(!this.current || this.stopped) {
return;
}
// extend event data with calculations about scale, distance etc
eventData = this.extendEventData(eventData);
// instance options
var inst_options = this.current.inst.options;
// call Hammer.gesture handlers
... | javascript | function detect(eventData) {
if(!this.current || this.stopped) {
return;
}
// extend event data with calculations about scale, distance etc
eventData = this.extendEventData(eventData);
// instance options
var inst_options = this.current.inst.options;
// call Hammer.gesture handlers
... | [
"function",
"detect",
"(",
"eventData",
")",
"{",
"if",
"(",
"!",
"this",
".",
"current",
"||",
"this",
".",
"stopped",
")",
"{",
"return",
";",
"}",
"// extend event data with calculations about scale, distance etc",
"eventData",
"=",
"this",
".",
"extendEventDat... | Hammer.gesture detection
@param {Object} eventData | [
"Hammer",
".",
"gesture",
"detection"
] | 151e254962055c1c4d7705a5eb277b96cb9a7849 | https://github.com/djgrant/heidelberg/blob/151e254962055c1c4d7705a5eb277b96cb9a7849/js/lib/hammer.js#L816-L850 | train |
djgrant/heidelberg | js/lib/hammer.js | stopDetect | function stopDetect() {
// clone current data to the store as the previous gesture
// used for the double tap gesture, since this is an other gesture detect session
this.previous = Hammer.utils.extend({}, this.current);
// reset the current
this.current = null;
// stopped!
this.stopped = t... | javascript | function stopDetect() {
// clone current data to the store as the previous gesture
// used for the double tap gesture, since this is an other gesture detect session
this.previous = Hammer.utils.extend({}, this.current);
// reset the current
this.current = null;
// stopped!
this.stopped = t... | [
"function",
"stopDetect",
"(",
")",
"{",
"// clone current data to the store as the previous gesture",
"// used for the double tap gesture, since this is an other gesture detect session",
"this",
".",
"previous",
"=",
"Hammer",
".",
"utils",
".",
"extend",
"(",
"{",
"}",
",",
... | clear the Hammer.gesture vars
this is called on endDetect, but can also be used when a final Hammer.gesture has been detected
to stop other Hammer.gestures from being fired | [
"clear",
"the",
"Hammer",
".",
"gesture",
"vars",
"this",
"is",
"called",
"on",
"endDetect",
"but",
"can",
"also",
"be",
"used",
"when",
"a",
"final",
"Hammer",
".",
"gesture",
"has",
"been",
"detected",
"to",
"stop",
"other",
"Hammer",
".",
"gestures",
... | 151e254962055c1c4d7705a5eb277b96cb9a7849 | https://github.com/djgrant/heidelberg/blob/151e254962055c1c4d7705a5eb277b96cb9a7849/js/lib/hammer.js#L858-L868 | train |
djgrant/heidelberg | js/lib/hammer.js | register | function register(gesture) {
// add an enable gesture options if there is no given
var options = gesture.defaults || {};
if(options[gesture.name] === undefined) {
options[gesture.name] = true;
}
// extend Hammer default options with the Hammer.gesture options
Hammer.utils.extend(Hammer.de... | javascript | function register(gesture) {
// add an enable gesture options if there is no given
var options = gesture.defaults || {};
if(options[gesture.name] === undefined) {
options[gesture.name] = true;
}
// extend Hammer default options with the Hammer.gesture options
Hammer.utils.extend(Hammer.de... | [
"function",
"register",
"(",
"gesture",
")",
"{",
"// add an enable gesture options if there is no given",
"var",
"options",
"=",
"gesture",
".",
"defaults",
"||",
"{",
"}",
";",
"if",
"(",
"options",
"[",
"gesture",
".",
"name",
"]",
"===",
"undefined",
")",
... | register new gesture
@param {Object} gesture object, see gestures.js for documentation
@returns {Array} gestures | [
"register",
"new",
"gesture"
] | 151e254962055c1c4d7705a5eb277b96cb9a7849 | https://github.com/djgrant/heidelberg/blob/151e254962055c1c4d7705a5eb277b96cb9a7849/js/lib/hammer.js#L943-L967 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.