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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MobilityData/gtfs-realtime-bindings | nodejs/gtfs-realtime.js | Translation | function Translation(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Translation(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Translation",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"i... | Properties of a Translation.
@memberof transit_realtime.TranslatedString
@interface ITranslation
@property {string} text Translation text
@property {string|null} [language] Translation language
Constructs a new Translation.
@memberof transit_realtime.TranslatedString
@classdesc Represents a Translation.
@implements I... | [
"Properties",
"of",
"a",
"Translation",
"."
] | 2ede9aeee2d9e8ec62ecc7684b8ee624fcfc5487 | https://github.com/MobilityData/gtfs-realtime-bindings/blob/2ede9aeee2d9e8ec62ecc7684b8ee624fcfc5487/nodejs/gtfs-realtime.js#L4534-L4539 | train |
Microsoft/vscode-css-languageservice | build/mdn/mdn-data-importer.js | extractMDNProperties | function extractMDNProperties(mdnEntry) {
if (mdnEntry.status === 'standard') {
return {
syntax: mdnEntry.syntax
}
}
return {
status: abbreviateStatus(mdnEntry.status),
syntax: mdnEntry.syntax
}
} | javascript | function extractMDNProperties(mdnEntry) {
if (mdnEntry.status === 'standard') {
return {
syntax: mdnEntry.syntax
}
}
return {
status: abbreviateStatus(mdnEntry.status),
syntax: mdnEntry.syntax
}
} | [
"function",
"extractMDNProperties",
"(",
"mdnEntry",
")",
"{",
"if",
"(",
"mdnEntry",
".",
"status",
"===",
"'standard'",
")",
"{",
"return",
"{",
"syntax",
":",
"mdnEntry",
".",
"syntax",
"}",
"}",
"return",
"{",
"status",
":",
"abbreviateStatus",
"(",
"m... | Extract only the MDN data that we use | [
"Extract",
"only",
"the",
"MDN",
"data",
"that",
"we",
"use"
] | 2d0a8b93fa1cf138ccb936ab144303aea3e36d05 | https://github.com/Microsoft/vscode-css-languageservice/blob/2d0a8b93fa1cf138ccb936ab144303aea3e36d05/build/mdn/mdn-data-importer.js#L76-L87 | train |
Microsoft/vscode-css-languageservice | build/generate_browserjs.js | convertEntry | function convertEntry(entry) {
entry.description = entry.desc
delete entry.desc
if (entry.values) {
entry.values.forEach(v => {
v.description = v.desc
delete v.desc
if (v.browsers) {
if (v.browsers === 'all') {
delete v.browsers
} else {
v.browsers = entry.browsers.split(',')
if (... | javascript | function convertEntry(entry) {
entry.description = entry.desc
delete entry.desc
if (entry.values) {
entry.values.forEach(v => {
v.description = v.desc
delete v.desc
if (v.browsers) {
if (v.browsers === 'all') {
delete v.browsers
} else {
v.browsers = entry.browsers.split(',')
if (... | [
"function",
"convertEntry",
"(",
"entry",
")",
"{",
"entry",
".",
"description",
"=",
"entry",
".",
"desc",
"delete",
"entry",
".",
"desc",
"if",
"(",
"entry",
".",
"values",
")",
"{",
"entry",
".",
"values",
".",
"forEach",
"(",
"v",
"=>",
"{",
"v",... | Temporarily convert old entry to new entry
Todo@Pine: Change MDN data generation so this yields new entry | [
"Temporarily",
"convert",
"old",
"entry",
"to",
"new",
"entry",
"Todo"
] | 2d0a8b93fa1cf138ccb936ab144303aea3e36d05 | https://github.com/Microsoft/vscode-css-languageservice/blob/2d0a8b93fa1cf138ccb936ab144303aea3e36d05/build/generate_browserjs.js#L422-L465 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | childByName | function childByName(node, name) {
var childNodes = node.childNodes;
for (var childKey in childNodes) {
var child = childNodes[childKey];
if (child.nodeName === name) {
return child;
}
}
} | javascript | function childByName(node, name) {
var childNodes = node.childNodes;
for (var childKey in childNodes) {
var child = childNodes[childKey];
if (child.nodeName === name) {
return child;
}
}
} | [
"function",
"childByName",
"(",
"node",
",",
"name",
")",
"{",
"var",
"childNodes",
"=",
"node",
".",
"childNodes",
";",
"for",
"(",
"var",
"childKey",
"in",
"childNodes",
")",
"{",
"var",
"child",
"=",
"childNodes",
"[",
"childKey",
"]",
";",
"if",
"(... | This module provides support methods to the parsing classes.
Returns the first element of the given node which nodeName matches the given name.
@param {Object} node - The node to use to find a match.
@param {String} name - The name to look for.
@return {Object} | [
"This",
"module",
"provides",
"support",
"methods",
"to",
"the",
"parsing",
"classes",
".",
"Returns",
"the",
"first",
"element",
"of",
"the",
"given",
"node",
"which",
"nodeName",
"matches",
"the",
"given",
"name",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L252-L262 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | resolveVastAdTagURI | function resolveVastAdTagURI(vastAdTagUrl, originalUrl) {
if (!originalUrl) {
return vastAdTagUrl;
}
if (vastAdTagUrl.indexOf('//') === 0) {
var _location = location,
protocol = _location.protocol;
return '' + protocol + vastAdTagUrl;
}
if (vastAdTagUrl.indexOf('://') === -1) {
// R... | javascript | function resolveVastAdTagURI(vastAdTagUrl, originalUrl) {
if (!originalUrl) {
return vastAdTagUrl;
}
if (vastAdTagUrl.indexOf('//') === 0) {
var _location = location,
protocol = _location.protocol;
return '' + protocol + vastAdTagUrl;
}
if (vastAdTagUrl.indexOf('://') === -1) {
// R... | [
"function",
"resolveVastAdTagURI",
"(",
"vastAdTagUrl",
",",
"originalUrl",
")",
"{",
"if",
"(",
"!",
"originalUrl",
")",
"{",
"return",
"vastAdTagUrl",
";",
"}",
"if",
"(",
"vastAdTagUrl",
".",
"indexOf",
"(",
"'//'",
")",
"===",
"0",
")",
"{",
"var",
"... | Converts relative vastAdTagUri.
@param {String} vastAdTagUrl - The url to resolve.
@param {String} originalUrl - The original url.
@return {String} | [
"Converts",
"relative",
"vastAdTagUri",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L290-L309 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | mergeWrapperAdData | function mergeWrapperAdData(unwrappedAd, wrapper) {
unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates);
unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates);
unwrappedAd.extensions = wrapper.extensions.concat(un... | javascript | function mergeWrapperAdData(unwrappedAd, wrapper) {
unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates);
unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates);
unwrappedAd.extensions = wrapper.extensions.concat(un... | [
"function",
"mergeWrapperAdData",
"(",
"unwrappedAd",
",",
"wrapper",
")",
"{",
"unwrappedAd",
".",
"errorURLTemplates",
"=",
"wrapper",
".",
"errorURLTemplates",
".",
"concat",
"(",
"unwrappedAd",
".",
"errorURLTemplates",
")",
";",
"unwrappedAd",
".",
"impressionU... | Merges the data between an unwrapped ad and his wrapper.
@param {Ad} unwrappedAd - The 'unwrapped' Ad.
@param {Ad} wrapper - The wrapper Ad.
@return {void} | [
"Merges",
"the",
"data",
"between",
"an",
"unwrapped",
"ad",
"and",
"his",
"wrapper",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L416-L457 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | parseCreativeNonLinear | function parseCreativeNonLinear(creativeElement, creativeAttributes) {
var creative = new CreativeNonLinear(creativeAttributes);
parserUtils.childrenByName(creativeElement, 'TrackingEvents').forEach(function (trackingEventsElement) {
var eventName = void 0,
trackingURLTemplate = void 0;
parserUtils... | javascript | function parseCreativeNonLinear(creativeElement, creativeAttributes) {
var creative = new CreativeNonLinear(creativeAttributes);
parserUtils.childrenByName(creativeElement, 'TrackingEvents').forEach(function (trackingEventsElement) {
var eventName = void 0,
trackingURLTemplate = void 0;
parserUtils... | [
"function",
"parseCreativeNonLinear",
"(",
"creativeElement",
",",
"creativeAttributes",
")",
"{",
"var",
"creative",
"=",
"new",
"CreativeNonLinear",
"(",
"creativeAttributes",
")",
";",
"parserUtils",
".",
"childrenByName",
"(",
"creativeElement",
",",
"'TrackingEvent... | This module provides methods to parse a VAST NonLinear Element.
Parses a NonLinear element.
@param {any} creativeElement - The VAST NonLinear element to parse.
@param {any} creativeAttributes - The attributes of the NonLinear (optional).
@return {CreativeNonLinear} | [
"This",
"module",
"provides",
"methods",
"to",
"parse",
"a",
"VAST",
"NonLinear",
"Element",
".",
"Parses",
"a",
"NonLinear",
"element",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L825-L885 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | parseInLine | function parseInLine(inLineElement) {
var childNodes = inLineElement.childNodes;
var ad = new Ad();
ad.id = inLineElement.getAttribute('id') || null;
ad.sequence = inLineElement.getAttribute('sequence') || null;
for (var nodeKey in childNodes) {
var node = childNodes[nodeKey];
switch (node.nodeName)... | javascript | function parseInLine(inLineElement) {
var childNodes = inLineElement.childNodes;
var ad = new Ad();
ad.id = inLineElement.getAttribute('id') || null;
ad.sequence = inLineElement.getAttribute('sequence') || null;
for (var nodeKey in childNodes) {
var node = childNodes[nodeKey];
switch (node.nodeName)... | [
"function",
"parseInLine",
"(",
"inLineElement",
")",
"{",
"var",
"childNodes",
"=",
"inLineElement",
".",
"childNodes",
";",
"var",
"ad",
"=",
"new",
"Ad",
"(",
")",
";",
"ad",
".",
"id",
"=",
"inLineElement",
".",
"getAttribute",
"(",
"'id'",
")",
"||"... | Parses an Inline element.
@param {Object} inLineElement - The VAST Inline element to parse.
@return {Ad} | [
"Parses",
"an",
"Inline",
"element",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L922-L1015 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | parseWrapper | function parseWrapper(wrapperElement) {
var ad = parseInLine(wrapperElement);
var wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURI');
if (wrapperURLElement) {
ad.nextWrapperURL = parserUtils.parseNodeText(wrapperURLElement);
} else {
wrapperURLElement = parserUtils.childByName(... | javascript | function parseWrapper(wrapperElement) {
var ad = parseInLine(wrapperElement);
var wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURI');
if (wrapperURLElement) {
ad.nextWrapperURL = parserUtils.parseNodeText(wrapperURLElement);
} else {
wrapperURLElement = parserUtils.childByName(... | [
"function",
"parseWrapper",
"(",
"wrapperElement",
")",
"{",
"var",
"ad",
"=",
"parseInLine",
"(",
"wrapperElement",
")",
";",
"var",
"wrapperURLElement",
"=",
"parserUtils",
".",
"childByName",
"(",
"wrapperElement",
",",
"'VASTAdTagURI'",
")",
";",
"if",
"(",
... | Parses a Wrapper element without resolving the wrapped urls.
@param {Object} wrapperElement - The VAST Wrapper element to be parsed.
@return {Ad} | [
"Parses",
"a",
"Wrapper",
"element",
"without",
"resolving",
"the",
"wrapped",
"urls",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L1022-L1089 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | VASTParser | function VASTParser() {
classCallCheck(this, VASTParser);
var _this = possibleConstructorReturn(this, (VASTParser.__proto__ || Object.getPrototypeOf(VASTParser)).call(this));
_this.remainingAds = [];
_this.parentURLs = [];
_this.errorURLTemplates = [];
_this.rootErrorURLTemplates = [];
_th... | javascript | function VASTParser() {
classCallCheck(this, VASTParser);
var _this = possibleConstructorReturn(this, (VASTParser.__proto__ || Object.getPrototypeOf(VASTParser)).call(this));
_this.remainingAds = [];
_this.parentURLs = [];
_this.errorURLTemplates = [];
_this.rootErrorURLTemplates = [];
_th... | [
"function",
"VASTParser",
"(",
")",
"{",
"classCallCheck",
"(",
"this",
",",
"VASTParser",
")",
";",
"var",
"_this",
"=",
"possibleConstructorReturn",
"(",
"this",
",",
"(",
"VASTParser",
".",
"__proto__",
"||",
"Object",
".",
"getPrototypeOf",
"(",
"VASTParse... | Creates an instance of VASTParser.
@constructor | [
"Creates",
"an",
"instance",
"of",
"VASTParser",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L1344-L1357 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | VASTClient | function VASTClient(cappingFreeLunch, cappingMinimumTimeInterval, customStorage) {
classCallCheck(this, VASTClient);
this.cappingFreeLunch = cappingFreeLunch || 0;
this.cappingMinimumTimeInterval = cappingMinimumTimeInterval || 0;
this.defaultOptions = {
withCredentials: false,
timeout: 0
... | javascript | function VASTClient(cappingFreeLunch, cappingMinimumTimeInterval, customStorage) {
classCallCheck(this, VASTClient);
this.cappingFreeLunch = cappingFreeLunch || 0;
this.cappingMinimumTimeInterval = cappingMinimumTimeInterval || 0;
this.defaultOptions = {
withCredentials: false,
timeout: 0
... | [
"function",
"VASTClient",
"(",
"cappingFreeLunch",
",",
"cappingMinimumTimeInterval",
",",
"customStorage",
")",
"{",
"classCallCheck",
"(",
"this",
",",
"VASTClient",
")",
";",
"this",
".",
"cappingFreeLunch",
"=",
"cappingFreeLunch",
"||",
"0",
";",
"this",
".",... | Creates an instance of VASTClient.
@param {Number} cappingFreeLunch - The number of first calls to skip.
@param {Number} cappingMinimumTimeInterval - The minimum time interval between two consecutive calls.
@param {Storage} customStorage - A custom storage to use instead of the default one.
@constructor | [
"Creates",
"an",
"instance",
"of",
"VASTClient",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L2006-L2029 | train |
dailymotion/vast-client-js | dist/vast-client-node.js | VASTTracker | function VASTTracker(client, ad, creative) {
var variation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
classCallCheck(this, VASTTracker);
var _this = possibleConstructorReturn(this, (VASTTracker.__proto__ || Object.getPrototypeOf(VASTTracker)).call(this));
_this.ad = ad... | javascript | function VASTTracker(client, ad, creative) {
var variation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
classCallCheck(this, VASTTracker);
var _this = possibleConstructorReturn(this, (VASTTracker.__proto__ || Object.getPrototypeOf(VASTTracker)).call(this));
_this.ad = ad... | [
"function",
"VASTTracker",
"(",
"client",
",",
"ad",
",",
"creative",
")",
"{",
"var",
"variation",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"null",
";",
"c... | Creates an instance of VASTTracker.
@param {VASTClient} client - An instance of VASTClient that can be updated by the tracker. [optional]
@param {Ad} ad - The ad to track.
@param {Creative} creative - The creative to track.
@param {CompanionAd|NonLinearAd} [variation=null] - An optional variation of the creative.
@con... | [
"Creates",
"an",
"instance",
"of",
"VASTTracker",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/dist/vast-client-node.js#L2169-L2211 | train |
dailymotion/vast-client-js | src/parser/ad_parser.js | parseExtensions | function parseExtensions(collection, extensions) {
extensions.forEach(extNode => {
const ext = new AdExtension();
const extNodeAttrs = extNode.attributes;
const childNodes = extNode.childNodes;
if (extNode.attributes) {
for (const extNodeAttrKey in extNodeAttrs) {
const extNodeAttr = ex... | javascript | function parseExtensions(collection, extensions) {
extensions.forEach(extNode => {
const ext = new AdExtension();
const extNodeAttrs = extNode.attributes;
const childNodes = extNode.childNodes;
if (extNode.attributes) {
for (const extNodeAttrKey in extNodeAttrs) {
const extNodeAttr = ex... | [
"function",
"parseExtensions",
"(",
"collection",
",",
"extensions",
")",
"{",
"extensions",
".",
"forEach",
"(",
"extNode",
"=>",
"{",
"const",
"ext",
"=",
"new",
"AdExtension",
"(",
")",
";",
"const",
"extNodeAttrs",
"=",
"extNode",
".",
"attributes",
";",... | Parses an array of Extension elements.
@param {Array} collection - The array used to store the parsed extensions.
@param {Array} extensions - The array of extensions to parse. | [
"Parses",
"an",
"array",
"of",
"Extension",
"elements",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/src/parser/ad_parser.js#L238-L281 | train |
dailymotion/vast-client-js | src/util/util.js | resolveURLTemplates | function resolveURLTemplates(URLTemplates, variables = {}, options = {}) {
const URLs = [];
// Encode String variables, when given
if (variables['ASSETURI']) {
variables['ASSETURI'] = encodeURIComponentRFC3986(variables['ASSETURI']);
}
if (variables['CONTENTPLAYHEAD']) {
variables['CONTENTPLAYHEAD'] ... | javascript | function resolveURLTemplates(URLTemplates, variables = {}, options = {}) {
const URLs = [];
// Encode String variables, when given
if (variables['ASSETURI']) {
variables['ASSETURI'] = encodeURIComponentRFC3986(variables['ASSETURI']);
}
if (variables['CONTENTPLAYHEAD']) {
variables['CONTENTPLAYHEAD'] ... | [
"function",
"resolveURLTemplates",
"(",
"URLTemplates",
",",
"variables",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"URLs",
"=",
"[",
"]",
";",
"// Encode String variables, when given",
"if",
"(",
"variables",
"[",
"'ASSETURI'",
"]",
"... | Replace the provided URLTemplates with the given values
@param {Array} URLTemplates - An array of tracking url templates.
@param {Object} [variables={}] - An optional Object of parameters to be used in the tracking calls.
@param {Object} [options={}] - An optional Object of options to be used in the tracking calls. | [
"Replace",
"the",
"provided",
"URLTemplates",
"with",
"the",
"given",
"values"
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/src/util/util.js#L19-L68 | train |
dailymotion/vast-client-js | src/parser/parser_utils.js | copyNodeAttribute | function copyNodeAttribute(attributeName, nodeSource, nodeDestination) {
const attributeValue = nodeSource.getAttribute(attributeName);
if (attributeValue) {
nodeDestination.setAttribute(attributeName, attributeValue);
}
} | javascript | function copyNodeAttribute(attributeName, nodeSource, nodeDestination) {
const attributeValue = nodeSource.getAttribute(attributeName);
if (attributeValue) {
nodeDestination.setAttribute(attributeName, attributeValue);
}
} | [
"function",
"copyNodeAttribute",
"(",
"attributeName",
",",
"nodeSource",
",",
"nodeDestination",
")",
"{",
"const",
"attributeValue",
"=",
"nodeSource",
".",
"getAttribute",
"(",
"attributeName",
")",
";",
"if",
"(",
"attributeValue",
")",
"{",
"nodeDestination",
... | Copies an attribute from a node to another.
@param {String} attributeName - The name of the attribute to clone.
@param {Object} nodeSource - The source node to copy the attribute from.
@param {Object} nodeDestination - The destination node to copy the attribute at. | [
"Copies",
"an",
"attribute",
"from",
"a",
"node",
"to",
"another",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/src/parser/parser_utils.js#L94-L99 | train |
dailymotion/vast-client-js | src/parser/parser_utils.js | parseDuration | function parseDuration(durationString) {
if (durationString === null || typeof durationString === 'undefined') {
return -1;
}
// Some VAST doesn't have an HH:MM:SS duration format but instead jus the number of seconds
if (util.isNumeric(durationString)) {
return parseInt(durationString);
}
const du... | javascript | function parseDuration(durationString) {
if (durationString === null || typeof durationString === 'undefined') {
return -1;
}
// Some VAST doesn't have an HH:MM:SS duration format but instead jus the number of seconds
if (util.isNumeric(durationString)) {
return parseInt(durationString);
}
const du... | [
"function",
"parseDuration",
"(",
"durationString",
")",
"{",
"if",
"(",
"durationString",
"===",
"null",
"||",
"typeof",
"durationString",
"===",
"'undefined'",
")",
"{",
"return",
"-",
"1",
";",
"}",
"// Some VAST doesn't have an HH:MM:SS duration format but instead j... | Parses a String duration into a Number.
@param {String} durationString - The dureation represented as a string.
@return {Number} | [
"Parses",
"a",
"String",
"duration",
"into",
"a",
"Number",
"."
] | da5626fbc07b5949feb602fcea49b97df6070e61 | https://github.com/dailymotion/vast-client-js/blob/da5626fbc07b5949feb602fcea49b97df6070e61/src/parser/parser_utils.js#L106-L139 | train |
nearform/node-clinic | lib/authenticate.js | loadToken | async function loadToken (url) {
let tokens
try {
const data = await readFile(credentialsPath)
tokens = JSON.parse(data)
} catch (err) {}
return tokens && tokens[url]
} | javascript | async function loadToken (url) {
let tokens
try {
const data = await readFile(credentialsPath)
tokens = JSON.parse(data)
} catch (err) {}
return tokens && tokens[url]
} | [
"async",
"function",
"loadToken",
"(",
"url",
")",
"{",
"let",
"tokens",
"try",
"{",
"const",
"data",
"=",
"await",
"readFile",
"(",
"credentialsPath",
")",
"tokens",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"}... | Load the JWT for an Upload Server URL. | [
"Load",
"the",
"JWT",
"for",
"an",
"Upload",
"Server",
"URL",
"."
] | 7e44899f42451691bc35a7a095fd17c1065ea8e8 | https://github.com/nearform/node-clinic/blob/7e44899f42451691bc35a7a095fd17c1065ea8e8/lib/authenticate.js#L29-L36 | train |
nearform/node-clinic | lib/authenticate.js | validateToken | function validateToken (token) {
const header = jwt.decode(token)
const now = Math.floor(Date.now() / 1000)
return header && header.exp > now
} | javascript | function validateToken (token) {
const header = jwt.decode(token)
const now = Math.floor(Date.now() / 1000)
return header && header.exp > now
} | [
"function",
"validateToken",
"(",
"token",
")",
"{",
"const",
"header",
"=",
"jwt",
".",
"decode",
"(",
"token",
")",
"const",
"now",
"=",
"Math",
".",
"floor",
"(",
"Date",
".",
"now",
"(",
")",
"/",
"1000",
")",
"return",
"header",
"&&",
"header",
... | Check that a JWT has not expired. | [
"Check",
"that",
"a",
"JWT",
"has",
"not",
"expired",
"."
] | 7e44899f42451691bc35a7a095fd17c1065ea8e8 | https://github.com/nearform/node-clinic/blob/7e44899f42451691bc35a7a095fd17c1065ea8e8/lib/authenticate.js#L41-L45 | train |
nearform/node-clinic | lib/authenticate.js | validateAskPermission | function validateAskPermission (token) {
const header = jwt.decode(token)
return validateToken(token) && header[ASK_CLAIM_KEY]
} | javascript | function validateAskPermission (token) {
const header = jwt.decode(token)
return validateToken(token) && header[ASK_CLAIM_KEY]
} | [
"function",
"validateAskPermission",
"(",
"token",
")",
"{",
"const",
"header",
"=",
"jwt",
".",
"decode",
"(",
"token",
")",
"return",
"validateToken",
"(",
"token",
")",
"&&",
"header",
"[",
"ASK_CLAIM_KEY",
"]",
"}"
] | Check that a JWT has Ask terms accepted. | [
"Check",
"that",
"a",
"JWT",
"has",
"Ask",
"terms",
"accepted",
"."
] | 7e44899f42451691bc35a7a095fd17c1065ea8e8 | https://github.com/nearform/node-clinic/blob/7e44899f42451691bc35a7a095fd17c1065ea8e8/lib/authenticate.js#L50-L54 | train |
nearform/node-clinic | lib/authenticate.js | getSession | async function getSession (url) {
const token = await loadToken(url)
if (!token) return null
const header = jwt.decode(token)
if (!header) return null
const now = Math.floor(Date.now() / 1000)
if (header.exp <= now) return null
return header
} | javascript | async function getSession (url) {
const token = await loadToken(url)
if (!token) return null
const header = jwt.decode(token)
if (!header) return null
const now = Math.floor(Date.now() / 1000)
if (header.exp <= now) return null
return header
} | [
"async",
"function",
"getSession",
"(",
"url",
")",
"{",
"const",
"token",
"=",
"await",
"loadToken",
"(",
"url",
")",
"if",
"(",
"!",
"token",
")",
"return",
"null",
"const",
"header",
"=",
"jwt",
".",
"decode",
"(",
"token",
")",
"if",
"(",
"!",
... | Get the session data for an Upload Server URL. | [
"Get",
"the",
"session",
"data",
"for",
"an",
"Upload",
"Server",
"URL",
"."
] | 7e44899f42451691bc35a7a095fd17c1065ea8e8 | https://github.com/nearform/node-clinic/blob/7e44899f42451691bc35a7a095fd17c1065ea8e8/lib/authenticate.js#L59-L67 | train |
nearform/node-clinic | lib/authenticate.js | saveToken | async function saveToken (url, token) {
let tokens
try {
const data = await readFile(credentialsPath)
tokens = JSON.parse(data)
} catch (err) {}
// if it was empty or contained `null` for some reason
if (typeof tokens !== 'object' || !tokens) {
tokens = {}
}
tokens[url] = token
await writ... | javascript | async function saveToken (url, token) {
let tokens
try {
const data = await readFile(credentialsPath)
tokens = JSON.parse(data)
} catch (err) {}
// if it was empty or contained `null` for some reason
if (typeof tokens !== 'object' || !tokens) {
tokens = {}
}
tokens[url] = token
await writ... | [
"async",
"function",
"saveToken",
"(",
"url",
",",
"token",
")",
"{",
"let",
"tokens",
"try",
"{",
"const",
"data",
"=",
"await",
"readFile",
"(",
"credentialsPath",
")",
"tokens",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
"}",
"catch",
"(",
"err",
... | Store the JWT for an Upload Server URL in the credentials file. | [
"Store",
"the",
"JWT",
"for",
"an",
"Upload",
"Server",
"URL",
"in",
"the",
"credentials",
"file",
"."
] | 7e44899f42451691bc35a7a095fd17c1065ea8e8 | https://github.com/nearform/node-clinic/blob/7e44899f42451691bc35a7a095fd17c1065ea8e8/lib/authenticate.js#L72-L87 | train |
squarefeet/ShaderParticleEngine | build/SPE.js | function( arg, type, defaultValue ) {
'use strict';
// If the argument being checked is an array, loop through
// it and ensure all the values are of the correct type,
// falling back to the defaultValue if any aren't.
if ( Array.isArray( arg ) ) {
for ( var i = arg.... | javascript | function( arg, type, defaultValue ) {
'use strict';
// If the argument being checked is an array, loop through
// it and ensure all the values are of the correct type,
// falling back to the defaultValue if any aren't.
if ( Array.isArray( arg ) ) {
for ( var i = arg.... | [
"function",
"(",
"arg",
",",
"type",
",",
"defaultValue",
")",
"{",
"'use strict'",
";",
"// If the argument being checked is an array, loop through",
"// it and ensure all the values are of the correct type,",
"// falling back to the defaultValue if any aren't.",
"if",
"(",
"Array",... | Given an array of values, a type, and a default value,
ensure the given array's contents ALL adhere to the provided type,
returning the default value if type check fails.
If the given value to check isn't an Array, delegates to SPE.utils.ensureTypedArg.
@param {Array|boolean|string|number|object} arg The ar... | [
"Given",
"an",
"array",
"of",
"values",
"a",
"type",
"and",
"a",
"default",
"value",
"ensure",
"the",
"given",
"array",
"s",
"contents",
"ALL",
"adhere",
"to",
"the",
"provided",
"type",
"returning",
"the",
"default",
"value",
"if",
"type",
"check",
"fails... | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1164-L1183 | train | |
squarefeet/ShaderParticleEngine | build/SPE.js | function( arg, instance, defaultValue ) {
'use strict';
// If the argument being checked is an array, loop through
// it and ensure all the values are of the correct type,
// falling back to the defaultValue if any aren't.
if ( Array.isArray( arg ) ) {
for ( var i = ... | javascript | function( arg, instance, defaultValue ) {
'use strict';
// If the argument being checked is an array, loop through
// it and ensure all the values are of the correct type,
// falling back to the defaultValue if any aren't.
if ( Array.isArray( arg ) ) {
for ( var i = ... | [
"function",
"(",
"arg",
",",
"instance",
",",
"defaultValue",
")",
"{",
"'use strict'",
";",
"// If the argument being checked is an array, loop through",
"// it and ensure all the values are of the correct type,",
"// falling back to the defaultValue if any aren't.",
"if",
"(",
"Arr... | Given an array of values, ensure the instances of all items in the array
matches the given instance constructor falling back to a default value if
the check fails.
If given value isn't an Array, delegates to `SPE.utils.ensureInstanceOf`.
@param {Array|Object} arg The value to perform the instanceof check on... | [
"Given",
"an",
"array",
"of",
"values",
"ensure",
"the",
"instances",
"of",
"all",
"items",
"in",
"the",
"array",
"matches",
"the",
"given",
"instance",
"constructor",
"falling",
"back",
"to",
"a",
"default",
"value",
"if",
"the",
"check",
"fails",
"."
] | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1216-L1235 | train | |
squarefeet/ShaderParticleEngine | build/SPE.js | function( value, randomise ) {
'use strict';
var epsilon = 0.00001,
result = value;
result = randomise ? Math.random() * epsilon * 10 : epsilon;
if ( value < 0 && value > -epsilon ) {
result = -result;
}
// if ( value === 0 ) {
// r... | javascript | function( value, randomise ) {
'use strict';
var epsilon = 0.00001,
result = value;
result = randomise ? Math.random() * epsilon * 10 : epsilon;
if ( value < 0 && value > -epsilon ) {
result = -result;
}
// if ( value === 0 ) {
// r... | [
"function",
"(",
"value",
",",
"randomise",
")",
"{",
"'use strict'",
";",
"var",
"epsilon",
"=",
"0.00001",
",",
"result",
"=",
"value",
";",
"result",
"=",
"randomise",
"?",
"Math",
".",
"random",
"(",
")",
"*",
"epsilon",
"*",
"10",
":",
"epsilon",
... | If the given value is less than the epsilon value, then return
a randomised epsilon value if specified, or just the epsilon value if not.
Works for negative numbers as well as positive.
@param {Number} value The value to perform the operation on.
@param {Boolean} randomise Whether the value should be randomised.... | [
"If",
"the",
"given",
"value",
"is",
"less",
"than",
"the",
"epsilon",
"value",
"then",
"return",
"a",
"randomised",
"epsilon",
"value",
"if",
"specified",
"or",
"just",
"the",
"epsilon",
"value",
"if",
"not",
".",
"Works",
"for",
"negative",
"numbers",
"a... | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1337-L1360 | train | |
squarefeet/ShaderParticleEngine | build/SPE.js | function( start, end, delta ) {
'use strict';
var types = this.types,
out;
if ( typeof start === types.NUMBER && typeof end === types.NUMBER ) {
return start + ( ( end - start ) * delta );
}
else if ( start instanceof THREE.Vector2 && end instanceof THRE... | javascript | function( start, end, delta ) {
'use strict';
var types = this.types,
out;
if ( typeof start === types.NUMBER && typeof end === types.NUMBER ) {
return start + ( ( end - start ) * delta );
}
else if ( start instanceof THREE.Vector2 && end instanceof THRE... | [
"function",
"(",
"start",
",",
"end",
",",
"delta",
")",
"{",
"'use strict'",
";",
"var",
"types",
"=",
"this",
".",
"types",
",",
"out",
";",
"if",
"(",
"typeof",
"start",
"===",
"types",
".",
"NUMBER",
"&&",
"typeof",
"end",
"===",
"types",
".",
... | Linearly interpolates two values of various types. The given values
must be of the same type for the interpolation to work.
@param {(number|Object)} start The start value of the lerp.
@param {(number|object)} end The end value of the lerp.
@param {Number} delta The delta posiiton of the lerp operation. Ideally bet... | [
"Linearly",
"interpolates",
"two",
"values",
"of",
"various",
"types",
".",
"The",
"given",
"values",
"must",
"be",
"of",
"the",
"same",
"type",
"for",
"the",
"interpolation",
"to",
"work",
"."
] | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1372-L1412 | train | |
squarefeet/ShaderParticleEngine | build/SPE.js | function( n, multiple ) {
'use strict';
var remainder = 0;
if ( multiple === 0 ) {
return n;
}
remainder = Math.abs( n ) % multiple;
if ( remainder === 0 ) {
return n;
}
if ( n < 0 ) {
return -( Math.abs( n ) - rema... | javascript | function( n, multiple ) {
'use strict';
var remainder = 0;
if ( multiple === 0 ) {
return n;
}
remainder = Math.abs( n ) % multiple;
if ( remainder === 0 ) {
return n;
}
if ( n < 0 ) {
return -( Math.abs( n ) - rema... | [
"function",
"(",
"n",
",",
"multiple",
")",
"{",
"'use strict'",
";",
"var",
"remainder",
"=",
"0",
";",
"if",
"(",
"multiple",
"===",
"0",
")",
"{",
"return",
"n",
";",
"}",
"remainder",
"=",
"Math",
".",
"abs",
"(",
"n",
")",
"%",
"multiple",
"... | Rounds a number to a nearest multiple.
@param {Number} n The number to round.
@param {Number} multiple The multiple to round to.
@return {Number} The result of the round operation. | [
"Rounds",
"a",
"number",
"to",
"a",
"nearest",
"multiple",
"."
] | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1433-L1453 | train | |
squarefeet/ShaderParticleEngine | build/SPE.js | function(
attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp
) {
'use strict';
var depth = 2 * Math.random() - 1,
t = 6.2832 * Math.random(),
r = Math.sqrt( 1 - depth * depth ),
rand = this.randomFloat( radius,... | javascript | function(
attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp
) {
'use strict';
var depth = 2 * Math.random() - 1,
t = 6.2832 * Math.random(),
r = Math.sqrt( 1 - depth * depth ),
rand = this.randomFloat( radius,... | [
"function",
"(",
"attribute",
",",
"index",
",",
"base",
",",
"radius",
",",
"radiusSpread",
",",
"radiusScale",
",",
"radiusSpreadClamp",
",",
"distributionClamp",
")",
"{",
"'use strict'",
";",
"var",
"depth",
"=",
"2",
"*",
"Math",
".",
"random",
"(",
"... | Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the
given values onto a sphere.
@param {Object} attribute The instance of SPE.ShaderAttribute to save the result to.
@param {Number} index The offset in the attribute's TypedArray to save the result from.
@param {Object} base ... | [
"Assigns",
"a",
"random",
"vector",
"3",
"value",
"to",
"an",
"SPE",
".",
"ShaderAttribute",
"instance",
"projecting",
"the",
"given",
"values",
"onto",
"a",
"sphere",
"."
] | ecc2886ce952d8f0ae0739f031bead671445f8a9 | https://github.com/squarefeet/ShaderParticleEngine/blob/ecc2886ce952d8f0ae0739f031bead671445f8a9/build/SPE.js#L1611-L1648 | train | |
vitaly-t/pg-promise | lib/database.js | taskProcessor | function taskProcessor(params, isTX) {
if (typeof params.cb !== 'function') {
return $p.reject(new TypeError('Callback function is required.'));
}
if (params.options.reusable) {
return config.$npm.task.callback(obj.ctx, obj, params.cb, config);
... | javascript | function taskProcessor(params, isTX) {
if (typeof params.cb !== 'function') {
return $p.reject(new TypeError('Callback function is required.'));
}
if (params.options.reusable) {
return config.$npm.task.callback(obj.ctx, obj, params.cb, config);
... | [
"function",
"taskProcessor",
"(",
"params",
",",
"isTX",
")",
"{",
"if",
"(",
"typeof",
"params",
".",
"cb",
"!==",
"'function'",
")",
"{",
"return",
"$p",
".",
"reject",
"(",
"new",
"TypeError",
"(",
"'Callback function is required.'",
")",
")",
";",
"}",... | Task method; Resolves with result from the callback function; | [
"Task",
"method",
";",
"Resolves",
"with",
"result",
"from",
"the",
"callback",
"function",
";"
] | a3ccf5a7fb14425c34892b869cb5502b2847180e | https://github.com/vitaly-t/pg-promise/blob/a3ccf5a7fb14425c34892b869cb5502b2847180e/lib/database.js#L1551-L1598 | train |
vitaly-t/pg-promise | lib/task.js | update | function update(start, success, result) {
const c = ctx.ctx;
if (start) {
npm.utils.addReadProp(c, 'start', new Date());
} else {
c.finish = new Date();
c.success = success;
c.result = result;
c.duration = c.finish - c.start;
... | javascript | function update(start, success, result) {
const c = ctx.ctx;
if (start) {
npm.utils.addReadProp(c, 'start', new Date());
} else {
c.finish = new Date();
c.success = success;
c.result = result;
c.duration = c.finish - c.start;
... | [
"function",
"update",
"(",
"start",
",",
"success",
",",
"result",
")",
"{",
"const",
"c",
"=",
"ctx",
".",
"ctx",
";",
"if",
"(",
"start",
")",
"{",
"npm",
".",
"utils",
".",
"addReadProp",
"(",
"c",
",",
"'start'",
",",
"new",
"Date",
"(",
")",... | updates the task context and notifies the client; | [
"updates",
"the",
"task",
"context",
"and",
"notifies",
"the",
"client",
";"
] | a3ccf5a7fb14425c34892b869cb5502b2847180e | https://github.com/vitaly-t/pg-promise/blob/a3ccf5a7fb14425c34892b869cb5502b2847180e/lib/task.js#L232-L248 | train |
get-alex/alex | index.js | htmlParse | function htmlParse(value, config) {
var allow
if (Array.isArray(config)) {
allow = config
} else if (config) {
allow = config.allow
}
return core(
value,
unified()
.use(html)
.use(rehype2retext, makeText(config))
.use(filter, {allow: allow})
)
} | javascript | function htmlParse(value, config) {
var allow
if (Array.isArray(config)) {
allow = config
} else if (config) {
allow = config.allow
}
return core(
value,
unified()
.use(html)
.use(rehype2retext, makeText(config))
.use(filter, {allow: allow})
)
} | [
"function",
"htmlParse",
"(",
"value",
",",
"config",
")",
"{",
"var",
"allow",
"if",
"(",
"Array",
".",
"isArray",
"(",
"config",
")",
")",
"{",
"allow",
"=",
"config",
"}",
"else",
"if",
"(",
"config",
")",
"{",
"allow",
"=",
"config",
".",
"allo... | Alex, for HTML. | [
"Alex",
"for",
"HTML",
"."
] | 4b9a763735b230c5a312afe9427cd87131bbc17d | https://github.com/get-alex/alex/blob/4b9a763735b230c5a312afe9427cd87131bbc17d/index.js#L63-L79 | train |
get-alex/alex | index.js | noMarkdown | function noMarkdown(value, config) {
var allow
if (Array.isArray(config)) {
allow = config
} else if (config) {
allow = config.allow
}
return core(value, makeText(config).use(filter, {allow: allow}))
} | javascript | function noMarkdown(value, config) {
var allow
if (Array.isArray(config)) {
allow = config
} else if (config) {
allow = config.allow
}
return core(value, makeText(config).use(filter, {allow: allow}))
} | [
"function",
"noMarkdown",
"(",
"value",
",",
"config",
")",
"{",
"var",
"allow",
"if",
"(",
"Array",
".",
"isArray",
"(",
"config",
")",
")",
"{",
"allow",
"=",
"config",
"}",
"else",
"if",
"(",
"config",
")",
"{",
"allow",
"=",
"config",
".",
"all... | Alex, without the markdown. | [
"Alex",
"without",
"the",
"markdown",
"."
] | 4b9a763735b230c5a312afe9427cd87131bbc17d | https://github.com/get-alex/alex/blob/4b9a763735b230c5a312afe9427cd87131bbc17d/index.js#L82-L92 | train |
vuejs/vueify | lib/compilers/sass.js | function (err, res) {
if (err) {
cb(err)
} else {
res.stats.includedFiles.forEach(function (file) {
compiler.emit('dependency', file)
})
cb(null, res.css.toString())
}
} | javascript | function (err, res) {
if (err) {
cb(err)
} else {
res.stats.includedFiles.forEach(function (file) {
compiler.emit('dependency', file)
})
cb(null, res.css.toString())
}
} | [
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"cb",
"(",
"err",
")",
"}",
"else",
"{",
"res",
".",
"stats",
".",
"includedFiles",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"compiler",
".",
"emit",
"(",
... | callback for node-sass > 3.0.0 | [
"callback",
"for",
"node",
"-",
"sass",
">",
"3",
".",
"0",
".",
"0"
] | 0bcabf17b6c44cbe0e4c4ff85e3c79d22a853bd8 | https://github.com/vuejs/vueify/blob/0bcabf17b6c44cbe0e4c4ff85e3c79d22a853bd8/lib/compilers/sass.js#L34-L43 | train | |
csstools/cssdb | tasks/start.js | sortFeatures | function sortFeatures({ stage: a, id: aa }, { stage: b, id: bb }) {
return b - a || (aa < bb ? -1 : aa > bb ? 1 : 0);
} | javascript | function sortFeatures({ stage: a, id: aa }, { stage: b, id: bb }) {
return b - a || (aa < bb ? -1 : aa > bb ? 1 : 0);
} | [
"function",
"sortFeatures",
"(",
"{",
"stage",
":",
"a",
",",
"id",
":",
"aa",
"}",
",",
"{",
"stage",
":",
"b",
",",
"id",
":",
"bb",
"}",
")",
"{",
"return",
"b",
"-",
"a",
"||",
"(",
"aa",
"<",
"bb",
"?",
"-",
"1",
":",
"aa",
">",
"bb"... | sort features by stage or title | [
"sort",
"features",
"by",
"stage",
"or",
"title"
] | 1f69e619ee7fcc4aaf6c879593d120ecc96c2164 | https://github.com/csstools/cssdb/blob/1f69e619ee7fcc4aaf6c879593d120ecc96c2164/tasks/start.js#L97-L99 | train |
csstools/cssdb | tasks/start.js | formatFeature | function formatFeature(feature) {
return Object.assign({}, feature, {
// format title using marked inline lexer
title: marked.inlineLexer(feature.title, [], {}),
// format description using marked inline lexer
description: marked.inlineLexer(feature.description, [], {}),
// format example as syntax-highlight... | javascript | function formatFeature(feature) {
return Object.assign({}, feature, {
// format title using marked inline lexer
title: marked.inlineLexer(feature.title, [], {}),
// format description using marked inline lexer
description: marked.inlineLexer(feature.description, [], {}),
// format example as syntax-highlight... | [
"function",
"formatFeature",
"(",
"feature",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"feature",
",",
"{",
"// format title using marked inline lexer",
"title",
":",
"marked",
".",
"inlineLexer",
"(",
"feature",
".",
"title",
",",
"[",
... | format feature for HTML output | [
"format",
"feature",
"for",
"HTML",
"output"
] | 1f69e619ee7fcc4aaf6c879593d120ecc96c2164 | https://github.com/csstools/cssdb/blob/1f69e619ee7fcc4aaf6c879593d120ecc96c2164/tasks/start.js#L107-L124 | train |
csstools/cssdb | tasks/start.js | postcssToHTML | function postcssToHTML(root, builder) {
function toString(node) {
if ('atrule' === node.type) {
return atruleToString(node);
} if ('rule' === node.type) {
return ruleToString(node);
} else if ('decl' === node.type) {
return declToString(node);
} else if ('comment' === node.type) {
return commentToS... | javascript | function postcssToHTML(root, builder) {
function toString(node) {
if ('atrule' === node.type) {
return atruleToString(node);
} if ('rule' === node.type) {
return ruleToString(node);
} else if ('decl' === node.type) {
return declToString(node);
} else if ('comment' === node.type) {
return commentToS... | [
"function",
"postcssToHTML",
"(",
"root",
",",
"builder",
")",
"{",
"function",
"toString",
"(",
"node",
")",
"{",
"if",
"(",
"'atrule'",
"===",
"node",
".",
"type",
")",
"{",
"return",
"atruleToString",
"(",
"node",
")",
";",
"}",
"if",
"(",
"'rule'",... | format css as syntax-highlighted HTML | [
"format",
"css",
"as",
"syntax",
"-",
"highlighted",
"HTML"
] | 1f69e619ee7fcc4aaf6c879593d120ecc96c2164 | https://github.com/csstools/cssdb/blob/1f69e619ee7fcc4aaf6c879593d120ecc96c2164/tasks/start.js#L166-L211 | train |
stacktracejs/stacktrace.js | stacktrace.js | _merge | function _merge(first, second) {
var target = {};
[first, second].forEach(function(obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
target[prop] = obj[prop];
}
}
return target;
});
ret... | javascript | function _merge(first, second) {
var target = {};
[first, second].forEach(function(obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
target[prop] = obj[prop];
}
}
return target;
});
ret... | [
"function",
"_merge",
"(",
"first",
",",
"second",
")",
"{",
"var",
"target",
"=",
"{",
"}",
";",
"[",
"first",
",",
"second",
"]",
".",
"forEach",
"(",
"function",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"obj",
")",
"{",
"if",
"... | Merge 2 given Objects. If a conflict occurs the second object wins.
Does not do deep merges.
@param {Object} first base object
@param {Object} second overrides
@returns {Object} merged first and second
@private | [
"Merge",
"2",
"given",
"Objects",
".",
"If",
"a",
"conflict",
"occurs",
"the",
"second",
"object",
"wins",
".",
"Does",
"not",
"do",
"deep",
"merges",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L43-L56 | train |
stacktracejs/stacktrace.js | stacktrace.js | StackTrace$$get | function StackTrace$$get(opts) {
var err = _generateError();
return _isShapedLikeParsableError(err) ? this.fromError(err, opts) : this.generateArtificially(opts);
} | javascript | function StackTrace$$get(opts) {
var err = _generateError();
return _isShapedLikeParsableError(err) ? this.fromError(err, opts) : this.generateArtificially(opts);
} | [
"function",
"StackTrace$$get",
"(",
"opts",
")",
"{",
"var",
"err",
"=",
"_generateError",
"(",
")",
";",
"return",
"_isShapedLikeParsableError",
"(",
"err",
")",
"?",
"this",
".",
"fromError",
"(",
"err",
",",
"opts",
")",
":",
"this",
".",
"generateArtif... | Get a backtrace from invocation point.
@param {Object} opts
@returns {Array} of StackFrame | [
"Get",
"a",
"backtrace",
"from",
"invocation",
"point",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L76-L79 | train |
stacktracejs/stacktrace.js | stacktrace.js | StackTrace$$fromError | function StackTrace$$fromError(error, opts) {
opts = _merge(_options, opts);
var gps = new StackTraceGPS(opts);
return new Promise(function(resolve) {
var stackframes = _filtered(ErrorStackParser.parse(error), opts.filter);
resolve(Promise.all(stackfra... | javascript | function StackTrace$$fromError(error, opts) {
opts = _merge(_options, opts);
var gps = new StackTraceGPS(opts);
return new Promise(function(resolve) {
var stackframes = _filtered(ErrorStackParser.parse(error), opts.filter);
resolve(Promise.all(stackfra... | [
"function",
"StackTrace$$fromError",
"(",
"error",
",",
"opts",
")",
"{",
"opts",
"=",
"_merge",
"(",
"_options",
",",
"opts",
")",
";",
"var",
"gps",
"=",
"new",
"StackTraceGPS",
"(",
"opts",
")",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
... | Given an error object, parse it.
@param {Error} error object
@param {Object} opts
@returns {Promise} for Array[StackFrame} | [
"Given",
"an",
"error",
"object",
"parse",
"it",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L102-L117 | train |
stacktracejs/stacktrace.js | stacktrace.js | StackTrace$$generateArtificially | function StackTrace$$generateArtificially(opts) {
opts = _merge(_options, opts);
var stackFrames = StackGenerator.backtrace(opts);
if (typeof opts.filter === 'function') {
stackFrames = stackFrames.filter(opts.filter);
}
return Promise.resolve(... | javascript | function StackTrace$$generateArtificially(opts) {
opts = _merge(_options, opts);
var stackFrames = StackGenerator.backtrace(opts);
if (typeof opts.filter === 'function') {
stackFrames = stackFrames.filter(opts.filter);
}
return Promise.resolve(... | [
"function",
"StackTrace$$generateArtificially",
"(",
"opts",
")",
"{",
"opts",
"=",
"_merge",
"(",
"_options",
",",
"opts",
")",
";",
"var",
"stackFrames",
"=",
"StackGenerator",
".",
"backtrace",
"(",
"opts",
")",
";",
"if",
"(",
"typeof",
"opts",
".",
"f... | Use StackGenerator to generate a backtrace.
@param {Object} opts
@returns {Promise} of Array[StackFrame] | [
"Use",
"StackGenerator",
"to",
"generate",
"a",
"backtrace",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L125-L132 | train |
stacktracejs/stacktrace.js | stacktrace.js | StackTrace$$instrument | function StackTrace$$instrument(fn, callback, errback, thisArg) {
if (typeof fn !== 'function') {
throw new Error('Cannot instrument non-function object');
} else if (typeof fn.__stacktraceOriginalFn === 'function') {
// Already instrumented, return given Function... | javascript | function StackTrace$$instrument(fn, callback, errback, thisArg) {
if (typeof fn !== 'function') {
throw new Error('Cannot instrument non-function object');
} else if (typeof fn.__stacktraceOriginalFn === 'function') {
// Already instrumented, return given Function... | [
"function",
"StackTrace$$instrument",
"(",
"fn",
",",
"callback",
",",
"errback",
",",
"thisArg",
")",
"{",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Cannot instrument non-function object'",
")",
";",
"}",
"else"... | Given a function, wrap it such that invocations trigger a callback that
is called with a stack trace.
@param {Function} fn to be instrumented
@param {Function} callback function to call with a stack trace on invocation
@param {Function} errback optional function to call with error if unable to get stack trace.
@param ... | [
"Given",
"a",
"function",
"wrap",
"it",
"such",
"that",
"invocations",
"trigger",
"a",
"callback",
"that",
"is",
"called",
"with",
"a",
"stack",
"trace",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L143-L165 | train |
stacktracejs/stacktrace.js | stacktrace.js | StackTrace$$report | function StackTrace$$report(stackframes, url, errorMsg, requestOptions) {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
req.onerror = reject;
req.onreadystatechange = function onreadystatechange() {
if (req.... | javascript | function StackTrace$$report(stackframes, url, errorMsg, requestOptions) {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
req.onerror = reject;
req.onreadystatechange = function onreadystatechange() {
if (req.... | [
"function",
"StackTrace$$report",
"(",
"stackframes",
",",
"url",
",",
"errorMsg",
",",
"requestOptions",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"req",
"=",
"new",
"XMLHttpRequest",
"(",
")",
... | Given an error message and Array of StackFrames, serialize and POST to given URL.
@param {Array} stackframes
@param {String} url
@param {String} errorMsg
@param {Object} requestOptions | [
"Given",
"an",
"error",
"message",
"and",
"Array",
"of",
"StackFrames",
"serialize",
"and",
"POST",
"to",
"given",
"URL",
"."
] | 89214a1866da9eb9fb25054d64a65dea06e302dc | https://github.com/stacktracejs/stacktrace.js/blob/89214a1866da9eb9fb25054d64a65dea06e302dc/stacktrace.js#L192-L225 | train |
igvteam/igv.js | js/canvas2svg.js | format | function format(str, args) {
var keys = Object.keys(args), i;
for (i=0; i<keys.length; i++) {
str = str.replace(new RegExp("\\{" + keys[i] + "\\}", "gi"), args[keys[i]]);
}
return str;
} | javascript | function format(str, args) {
var keys = Object.keys(args), i;
for (i=0; i<keys.length; i++) {
str = str.replace(new RegExp("\\{" + keys[i] + "\\}", "gi"), args[keys[i]]);
}
return str;
} | [
"function",
"format",
"(",
"str",
",",
"args",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"args",
")",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"str",
"=",
"str... | helper function to format a string | [
"helper",
"function",
"to",
"format",
"a",
"string"
] | b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6 | https://github.com/igvteam/igv.js/blob/b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6/js/canvas2svg.js#L22-L28 | train |
igvteam/igv.js | js/canvas2svg.js | randomString | function randomString(holder) {
var chars, randomstring, i;
if (!holder) {
throw new Error("cannot create a random attribute name for an undefined object");
}
chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
randomstring = "";
do {
ra... | javascript | function randomString(holder) {
var chars, randomstring, i;
if (!holder) {
throw new Error("cannot create a random attribute name for an undefined object");
}
chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
randomstring = "";
do {
ra... | [
"function",
"randomString",
"(",
"holder",
")",
"{",
"var",
"chars",
",",
"randomstring",
",",
"i",
";",
"if",
"(",
"!",
"holder",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot create a random attribute name for an undefined object\"",
")",
";",
"}",
"chars"... | helper function that generates a random string | [
"helper",
"function",
"that",
"generates",
"a",
"random",
"string"
] | b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6 | https://github.com/igvteam/igv.js/blob/b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6/js/canvas2svg.js#L31-L45 | train |
igvteam/igv.js | js/canvas2svg.js | createNamedToNumberedLookup | function createNamedToNumberedLookup(items, radix) {
var i, entity, lookup = {}, base10, base16;
items = items.split(',');
radix = radix || 10;
// Map from named to numbered entities.
for (i = 0; i < items.length; i += 2) {
entity = '&' + items[i + 1] + ';';
... | javascript | function createNamedToNumberedLookup(items, radix) {
var i, entity, lookup = {}, base10, base16;
items = items.split(',');
radix = radix || 10;
// Map from named to numbered entities.
for (i = 0; i < items.length; i += 2) {
entity = '&' + items[i + 1] + ';';
... | [
"function",
"createNamedToNumberedLookup",
"(",
"items",
",",
"radix",
")",
"{",
"var",
"i",
",",
"entity",
",",
"lookup",
"=",
"{",
"}",
",",
"base10",
",",
"base16",
";",
"items",
"=",
"items",
".",
"split",
"(",
"','",
")",
";",
"radix",
"=",
"rad... | helper function to map named to numbered entities | [
"helper",
"function",
"to",
"map",
"named",
"to",
"numbered",
"entities"
] | b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6 | https://github.com/igvteam/igv.js/blob/b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6/js/canvas2svg.js#L48-L61 | train |
igvteam/igv.js | js/canvas2svg.js | function (vector) {
var len = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]);
return [vector[0] / len, vector[1] / len];
} | javascript | function (vector) {
var len = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]);
return [vector[0] / len, vector[1] / len];
} | [
"function",
"(",
"vector",
")",
"{",
"var",
"len",
"=",
"Math",
".",
"sqrt",
"(",
"vector",
"[",
"0",
"]",
"*",
"vector",
"[",
"0",
"]",
"+",
"vector",
"[",
"1",
"]",
"*",
"vector",
"[",
"1",
"]",
")",
";",
"return",
"[",
"vector",
"[",
"0",
... | Return a new normalized vector of given vector | [
"Return",
"a",
"new",
"normalized",
"vector",
"of",
"given",
"vector"
] | b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6 | https://github.com/igvteam/igv.js/blob/b9473ee0b8565ee4e5eb98f73f8d6161dda2acb6/js/canvas2svg.js#L709-L712 | train | |
skaterdav85/validatorjs | src/validator.js | function (passes, fails) {
var _this = this;
passes = passes || function () {};
fails = fails || function () {};
var failsOne = function (rule, message) {
_this._addFailure(rule, message);
};
var resolvedAll = function (allPassed) {
if (allPassed) {
passes();
} else {... | javascript | function (passes, fails) {
var _this = this;
passes = passes || function () {};
fails = fails || function () {};
var failsOne = function (rule, message) {
_this._addFailure(rule, message);
};
var resolvedAll = function (allPassed) {
if (allPassed) {
passes();
} else {... | [
"function",
"(",
"passes",
",",
"fails",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"passes",
"=",
"passes",
"||",
"function",
"(",
")",
"{",
"}",
";",
"fails",
"=",
"fails",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"failsOne",
"=",
"fu... | Run async validator
@param {function} passes
@param {function} fails
@return {void} | [
"Run",
"async",
"validator"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L92-L143 | train | |
skaterdav85/validatorjs | src/validator.js | function (rule) {
var msg = this.messages.render(rule);
this.errors.add(rule.attribute, msg);
this.errorCount++;
} | javascript | function (rule) {
var msg = this.messages.render(rule);
this.errors.add(rule.attribute, msg);
this.errorCount++;
} | [
"function",
"(",
"rule",
")",
"{",
"var",
"msg",
"=",
"this",
".",
"messages",
".",
"render",
"(",
"rule",
")",
";",
"this",
".",
"errors",
".",
"add",
"(",
"rule",
".",
"attribute",
",",
"msg",
")",
";",
"this",
".",
"errorCount",
"++",
";",
"}"... | Add failure and error message for given rule
@param {Rule} rule | [
"Add",
"failure",
"and",
"error",
"message",
"for",
"given",
"rule"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L150-L154 | train | |
skaterdav85/validatorjs | src/validator.js | function (obj, path) {
if (Object.prototype.hasOwnProperty.call(obj, path)) {
return obj[path];
}
var keys = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".");
var copy = {};
for (var attr in obj) {
if (Object.prototype.hasOwnProperty.call(obj, attr)) {
copy[attr] ... | javascript | function (obj, path) {
if (Object.prototype.hasOwnProperty.call(obj, path)) {
return obj[path];
}
var keys = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".");
var copy = {};
for (var attr in obj) {
if (Object.prototype.hasOwnProperty.call(obj, attr)) {
copy[attr] ... | [
"function",
"(",
"obj",
",",
"path",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"obj",
",",
"path",
")",
")",
"{",
"return",
"obj",
"[",
"path",
"]",
";",
"}",
"var",
"keys",
"=",
"path",
".",
"repla... | Extract value from nested object using string path with dot notation
@param {object} object to search in
@param {string} path inside object
@return {any|void} value under the path | [
"Extract",
"value",
"from",
"nested",
"object",
"using",
"string",
"path",
"with",
"dot",
"notation"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L195-L216 | train | |
skaterdav85/validatorjs | src/validator.js | function (rulesArray) {
var rules = [];
for (var i = 0, len = rulesArray.length; i < len; i++) {
if (typeof rulesArray[i] === 'object') {
for (var rule in rulesArray[i]) {
rules.push({
name: rule,
value: rulesArray[i][rule]
});
}
} else {
... | javascript | function (rulesArray) {
var rules = [];
for (var i = 0, len = rulesArray.length; i < len; i++) {
if (typeof rulesArray[i] === 'object') {
for (var rule in rulesArray[i]) {
rules.push({
name: rule,
value: rulesArray[i][rule]
});
}
} else {
... | [
"function",
"(",
"rulesArray",
")",
"{",
"var",
"rules",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"rulesArray",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"typeof",
"rulesArray",
"[",... | Prepare rules if it comes in Array. Check for objects. Need for type validation.
@param {array} rulesArray
@return {array} | [
"Prepare",
"rules",
"if",
"it",
"comes",
"in",
"Array",
".",
"Check",
"for",
"objects",
".",
"Need",
"for",
"type",
"validation",
"."
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L330-L347 | train | |
skaterdav85/validatorjs | src/validator.js | function (attribute, findRules) {
var rules = this.rules[attribute] || [];
for (var i = 0, len = rules.length; i < len; i++) {
if (findRules.indexOf(rules[i].name) > -1) {
return true;
}
}
return false;
} | javascript | function (attribute, findRules) {
var rules = this.rules[attribute] || [];
for (var i = 0, len = rules.length; i < len; i++) {
if (findRules.indexOf(rules[i].name) > -1) {
return true;
}
}
return false;
} | [
"function",
"(",
"attribute",
",",
"findRules",
")",
"{",
"var",
"rules",
"=",
"this",
".",
"rules",
"[",
"attribute",
"]",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"rules",
".",
"length",
";",
"i",
"<",
"len",
";... | Determine if attribute has any of the given rules
@param {string} attribute
@param {array} findRules
@return {boolean} | [
"Determine",
"if",
"attribute",
"has",
"any",
"of",
"the",
"given",
"rules"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L387-L395 | train | |
skaterdav85/validatorjs | src/validator.js | function (rule, value) {
if (Rules.isImplicit(rule.name)) {
return true;
}
return this.getRule('required').validate(value);
} | javascript | function (rule, value) {
if (Rules.isImplicit(rule.name)) {
return true;
}
return this.getRule('required').validate(value);
} | [
"function",
"(",
"rule",
",",
"value",
")",
"{",
"if",
"(",
"Rules",
".",
"isImplicit",
"(",
"rule",
".",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"this",
".",
"getRule",
"(",
"'required'",
")",
".",
"validate",
"(",
"value",
")... | Determine if rule is validatable
@param {Rule} rule
@param {mixed} value
@return {boolean} | [
"Determine",
"if",
"rule",
"is",
"validatable"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L414-L420 | train | |
skaterdav85/validatorjs | src/validator.js | function (attribute, rulePassed) {
var stopOnAttributes = this.stopOnAttributes;
if (typeof stopOnAttributes === 'undefined' || stopOnAttributes === false || rulePassed === true) {
return false;
}
if (stopOnAttributes instanceof Array) {
return stopOnAttributes.indexOf(attribute) > -1;
... | javascript | function (attribute, rulePassed) {
var stopOnAttributes = this.stopOnAttributes;
if (typeof stopOnAttributes === 'undefined' || stopOnAttributes === false || rulePassed === true) {
return false;
}
if (stopOnAttributes instanceof Array) {
return stopOnAttributes.indexOf(attribute) > -1;
... | [
"function",
"(",
"attribute",
",",
"rulePassed",
")",
"{",
"var",
"stopOnAttributes",
"=",
"this",
".",
"stopOnAttributes",
";",
"if",
"(",
"typeof",
"stopOnAttributes",
"===",
"'undefined'",
"||",
"stopOnAttributes",
"===",
"false",
"||",
"rulePassed",
"===",
"... | Determine if we should stop validating.
@param {string} attribute
@param {boolean} rulePassed
@return {boolean} | [
"Determine",
"if",
"we",
"should",
"stop",
"validating",
"."
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/validator.js#L429-L441 | train | |
skaterdav85/validatorjs | src/rules.js | function(val, req, attribute) {
if (val) {
req = parseFloat(req);
var size = this.getSize();
return size === req;
}
return true;
} | javascript | function(val, req, attribute) {
if (val) {
req = parseFloat(req);
var size = this.getSize();
return size === req;
}
return true;
} | [
"function",
"(",
"val",
",",
"req",
",",
"attribute",
")",
"{",
"if",
"(",
"val",
")",
"{",
"req",
"=",
"parseFloat",
"(",
"req",
")",
";",
"var",
"size",
"=",
"this",
".",
"getSize",
"(",
")",
";",
"return",
"size",
"===",
"req",
";",
"}",
"re... | compares the size of strings with numbers, compares the value | [
"compares",
"the",
"size",
"of",
"strings",
"with",
"numbers",
"compares",
"the",
"value"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L121-L131 | train | |
skaterdav85/validatorjs | src/rules.js | function(inputValue, ruleValue, attribute, callback) {
var fn = this.isMissed() ? missedRuleValidator : this.fn;
return fn.apply(this, [inputValue, ruleValue, attribute, callback]);
} | javascript | function(inputValue, ruleValue, attribute, callback) {
var fn = this.isMissed() ? missedRuleValidator : this.fn;
return fn.apply(this, [inputValue, ruleValue, attribute, callback]);
} | [
"function",
"(",
"inputValue",
",",
"ruleValue",
",",
"attribute",
",",
"callback",
")",
"{",
"var",
"fn",
"=",
"this",
".",
"isMissed",
"(",
")",
"?",
"missedRuleValidator",
":",
"this",
".",
"fn",
";",
"return",
"fn",
".",
"apply",
"(",
"this",
",",
... | Apply validation function
@param {mixed} inputValue
@param {mixed} ruleValue
@param {string} attribute
@param {function} callback
@return {boolean|undefined} | [
"Apply",
"validation",
"function"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L439-L443 | train | |
skaterdav85/validatorjs | src/rules.js | function() {
var value = this.inputValue;
if (value instanceof Array) {
return value.length;
}
if (typeof value === 'number') {
return value;
}
if (this.validator._hasNumericRule(this.attribute)) {
return parseFloat(value, 10);
}
return value.length;
} | javascript | function() {
var value = this.inputValue;
if (value instanceof Array) {
return value.length;
}
if (typeof value === 'number') {
return value;
}
if (this.validator._hasNumericRule(this.attribute)) {
return parseFloat(value, 10);
}
return value.length;
} | [
"function",
"(",
")",
"{",
"var",
"value",
"=",
"this",
".",
"inputValue",
";",
"if",
"(",
"value",
"instanceof",
"Array",
")",
"{",
"return",
"value",
".",
"length",
";",
"}",
"if",
"(",
"typeof",
"value",
"===",
"'number'",
")",
"{",
"return",
"val... | Get true size of value
@return {integer|float} | [
"Get",
"true",
"size",
"of",
"value"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L487-L503 | train | |
skaterdav85/validatorjs | src/rules.js | function(passes, message) {
this.passes = (passes === undefined || passes === true);
this._customMessage = message;
this.callback(this.passes, message);
} | javascript | function(passes, message) {
this.passes = (passes === undefined || passes === true);
this._customMessage = message;
this.callback(this.passes, message);
} | [
"function",
"(",
"passes",
",",
"message",
")",
"{",
"this",
".",
"passes",
"=",
"(",
"passes",
"===",
"undefined",
"||",
"passes",
"===",
"true",
")",
";",
"this",
".",
"_customMessage",
"=",
"message",
";",
"this",
".",
"callback",
"(",
"this",
".",
... | Set the async callback response
@param {boolean|undefined} passes Whether validation passed
@param {string|undefined} message Custom error message
@return {void} | [
"Set",
"the",
"async",
"callback",
"response"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L526-L530 | train | |
skaterdav85/validatorjs | src/rules.js | function(name, validator) {
var async = this.isAsync(name);
var rule = new Rule(name, rules[name], async);
rule.setValidator(validator);
return rule;
} | javascript | function(name, validator) {
var async = this.isAsync(name);
var rule = new Rule(name, rules[name], async);
rule.setValidator(validator);
return rule;
} | [
"function",
"(",
"name",
",",
"validator",
")",
"{",
"var",
"async",
"=",
"this",
".",
"isAsync",
"(",
"name",
")",
";",
"var",
"rule",
"=",
"new",
"Rule",
"(",
"name",
",",
"rules",
"[",
"name",
"]",
",",
"async",
")",
";",
"rule",
".",
"setVali... | Get rule by name
@param {string} name
@param {Validator}
@return {Rule} | [
"Get",
"rule",
"by",
"name"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L579-L584 | train | |
skaterdav85/validatorjs | src/rules.js | function(name) {
for (var i = 0, len = this.asyncRules.length; i < len; i++) {
if (this.asyncRules[i] === name) {
return true;
}
}
return false;
} | javascript | function(name) {
for (var i = 0, len = this.asyncRules.length; i < len; i++) {
if (this.asyncRules[i] === name) {
return true;
}
}
return false;
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"this",
".",
"asyncRules",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"asyncRules",
"[",
"i",
"]",
"===",
"name"... | Determine if given rule is async
@param {string} name
@return {boolean} | [
"Determine",
"if",
"given",
"rule",
"is",
"async"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/rules.js#L592-L599 | train | |
skaterdav85/validatorjs | src/errors.js | function(attribute, message) {
if (!this.has(attribute)) {
this.errors[attribute] = [];
}
if (this.errors[attribute].indexOf(message) === -1) {
this.errors[attribute].push(message);
}
} | javascript | function(attribute, message) {
if (!this.has(attribute)) {
this.errors[attribute] = [];
}
if (this.errors[attribute].indexOf(message) === -1) {
this.errors[attribute].push(message);
}
} | [
"function",
"(",
"attribute",
",",
"message",
")",
"{",
"if",
"(",
"!",
"this",
".",
"has",
"(",
"attribute",
")",
")",
"{",
"this",
".",
"errors",
"[",
"attribute",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"this",
".",
"errors",
"[",
"attribute"... | Add new error message for given attribute
@param {string} attribute
@param {string} message
@return {void} | [
"Add",
"new",
"error",
"message",
"for",
"given",
"attribute"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/errors.js#L15-L23 | train | |
skaterdav85/validatorjs | src/async.js | function(index) {
var rule = this.resolvers[index];
if (rule.passes === true) {
this.passed.push(rule);
} else if (rule.passes === false) {
this.failed.push(rule);
this.onFailedOne(rule);
}
this.fire();
} | javascript | function(index) {
var rule = this.resolvers[index];
if (rule.passes === true) {
this.passed.push(rule);
} else if (rule.passes === false) {
this.failed.push(rule);
this.onFailedOne(rule);
}
this.fire();
} | [
"function",
"(",
"index",
")",
"{",
"var",
"rule",
"=",
"this",
".",
"resolvers",
"[",
"index",
"]",
";",
"if",
"(",
"rule",
".",
"passes",
"===",
"true",
")",
"{",
"this",
".",
"passed",
".",
"push",
"(",
"rule",
")",
";",
"}",
"else",
"if",
"... | Resolve given index
@param {integer} index
@return {void} | [
"Resolve",
"given",
"index"
] | 7cdb58f064a77237de13072057dc35e61755a7f5 | https://github.com/skaterdav85/validatorjs/blob/7cdb58f064a77237de13072057dc35e61755a7f5/src/async.js#L32-L42 | train | |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | ancestors | function ancestors(first, second) {
var path = [];
for (var n in first.path) {
if (first.path[n] !== second.path[n]) break;
path.push(first.path[n]);
}
return path;
} | javascript | function ancestors(first, second) {
var path = [];
for (var n in first.path) {
if (first.path[n] !== second.path[n]) break;
path.push(first.path[n]);
}
return path;
} | [
"function",
"ancestors",
"(",
"first",
",",
"second",
")",
"{",
"var",
"path",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"n",
"in",
"first",
".",
"path",
")",
"{",
"if",
"(",
"first",
".",
"path",
"[",
"n",
"]",
"!==",
"second",
".",
"path",
"[",
... | Finds the common ancestor path between two states.
@param {Object} first The first state.
@param {Object} second The second state.
@return {Array} Returns an array of state names in descending order, not including the root. | [
"Finds",
"the",
"common",
"ancestor",
"path",
"between",
"two",
"states",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L36-L44 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | equalForKeys | function equalForKeys(a, b, keys) {
if (!keys) {
keys = [];
for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility
}
for (var i=0; i<keys.length; i++) {
var k = keys[i];
if (a[k] != b[k]) return false; // Not '===', values aren't necessarily normalized
}
return ... | javascript | function equalForKeys(a, b, keys) {
if (!keys) {
keys = [];
for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility
}
for (var i=0; i<keys.length; i++) {
var k = keys[i];
if (a[k] != b[k]) return false; // Not '===', values aren't necessarily normalized
}
return ... | [
"function",
"equalForKeys",
"(",
"a",
",",
"b",
",",
"keys",
")",
"{",
"if",
"(",
"!",
"keys",
")",
"{",
"keys",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"n",
"in",
"a",
")",
"keys",
".",
"push",
"(",
"n",
")",
";",
"// Used instead of Object.keys(... | Performs a non-strict comparison of the subset of two objects, defined by a list of keys.
@param {Object} a The first object.
@param {Object} b The second object.
@param {Array} keys The list of keys within each object to compare. If the list is empty or not specified,
it defaults to the list of keys in `a`.
@return {... | [
"Performs",
"a",
"non",
"-",
"strict",
"comparison",
"of",
"the",
"subset",
"of",
"two",
"objects",
"defined",
"by",
"a",
"list",
"of",
"keys",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L121-L132 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | filterByKeys | function filterByKeys(keys, values) {
var filtered = {};
forEach(keys, function (name) {
filtered[name] = values[name];
});
return filtered;
} | javascript | function filterByKeys(keys, values) {
var filtered = {};
forEach(keys, function (name) {
filtered[name] = values[name];
});
return filtered;
} | [
"function",
"filterByKeys",
"(",
"keys",
",",
"values",
")",
"{",
"var",
"filtered",
"=",
"{",
"}",
";",
"forEach",
"(",
"keys",
",",
"function",
"(",
"name",
")",
"{",
"filtered",
"[",
"name",
"]",
"=",
"values",
"[",
"name",
"]",
";",
"}",
")",
... | Returns the subset of an object, based on a list of keys.
@param {Array} keys
@param {Object} values
@return {Boolean} Returns a subset of `values`. | [
"Returns",
"the",
"subset",
"of",
"an",
"object",
"based",
"on",
"a",
"list",
"of",
"keys",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L141-L148 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | indexBy | function indexBy(array, propName) {
var result = {};
forEach(array, function(item) {
result[item[propName]] = item;
});
return result;
} | javascript | function indexBy(array, propName) {
var result = {};
forEach(array, function(item) {
result[item[propName]] = item;
});
return result;
} | [
"function",
"indexBy",
"(",
"array",
",",
"propName",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"forEach",
"(",
"array",
",",
"function",
"(",
"item",
")",
"{",
"result",
"[",
"item",
"[",
"propName",
"]",
"]",
"=",
"item",
";",
"}",
")",
";... | like _.indexBy when you know that your index values will be unique, or you want last-one-in to win | [
"like",
"_",
".",
"indexBy",
"when",
"you",
"know",
"that",
"your",
"index",
"values",
"will",
"be",
"unique",
"or",
"you",
"want",
"last",
"-",
"one",
"-",
"in",
"to",
"win"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L152-L158 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | pick | function pick(obj) {
var copy = {};
var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
forEach(keys, function(key) {
if (key in obj) copy[key] = obj[key];
});
return copy;
} | javascript | function pick(obj) {
var copy = {};
var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
forEach(keys, function(key) {
if (key in obj) copy[key] = obj[key];
});
return copy;
} | [
"function",
"pick",
"(",
"obj",
")",
"{",
"var",
"copy",
"=",
"{",
"}",
";",
"var",
"keys",
"=",
"Array",
".",
"prototype",
".",
"concat",
".",
"apply",
"(",
"Array",
".",
"prototype",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",... | extracted from underscore.js Return a copy of the object only containing the whitelisted properties. | [
"extracted",
"from",
"underscore",
".",
"js",
"Return",
"a",
"copy",
"of",
"the",
"object",
"only",
"containing",
"the",
"whitelisted",
"properties",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L162-L169 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/common.js | omit | function omit(obj) {
var copy = {};
var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
for (var key in obj) {
if (indexOf(keys, key) == -1) copy[key] = obj[key];
}
return copy;
} | javascript | function omit(obj) {
var copy = {};
var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
for (var key in obj) {
if (indexOf(keys, key) == -1) copy[key] = obj[key];
}
return copy;
} | [
"function",
"omit",
"(",
"obj",
")",
"{",
"var",
"copy",
"=",
"{",
"}",
";",
"var",
"keys",
"=",
"Array",
".",
"prototype",
".",
"concat",
".",
"apply",
"(",
"Array",
".",
"prototype",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",... | extracted from underscore.js Return a copy of the object omitting the blacklisted properties. | [
"extracted",
"from",
"underscore",
".",
"js",
"Return",
"a",
"copy",
"of",
"the",
"object",
"omitting",
"the",
"blacklisted",
"properties",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/common.js#L173-L180 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/state.js | function(state) {
var url = state.url, config = { params: state.params || {} };
if (isString(url)) {
if (url.charAt(0) == '^') return $urlMatcherFactory.compile(url.substring(1), config);
return (state.parent.navigable || root).url.concat(url, config);
}
if (!url || $urlMatcher... | javascript | function(state) {
var url = state.url, config = { params: state.params || {} };
if (isString(url)) {
if (url.charAt(0) == '^') return $urlMatcherFactory.compile(url.substring(1), config);
return (state.parent.navigable || root).url.concat(url, config);
}
if (!url || $urlMatcher... | [
"function",
"(",
"state",
")",
"{",
"var",
"url",
"=",
"state",
".",
"url",
",",
"config",
"=",
"{",
"params",
":",
"state",
".",
"params",
"||",
"{",
"}",
"}",
";",
"if",
"(",
"isString",
"(",
"url",
")",
")",
"{",
"if",
"(",
"url",
".",
"ch... | Build a URLMatcher if necessary, either via a relative or absolute URL | [
"Build",
"a",
"URLMatcher",
"if",
"necessary",
"either",
"via",
"a",
"relative",
"or",
"absolute",
"URL"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/state.js#L50-L60 | train | |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/state.js | function(state) {
var params = state.url && state.url.params || new $$UMFP.ParamSet();
forEach(state.params || {}, function(config, id) {
if (!params[id]) params[id] = new $$UMFP.Param(id, null, config, "config");
});
return params;
} | javascript | function(state) {
var params = state.url && state.url.params || new $$UMFP.ParamSet();
forEach(state.params || {}, function(config, id) {
if (!params[id]) params[id] = new $$UMFP.Param(id, null, config, "config");
});
return params;
} | [
"function",
"(",
"state",
")",
"{",
"var",
"params",
"=",
"state",
".",
"url",
"&&",
"state",
".",
"url",
".",
"params",
"||",
"new",
"$$UMFP",
".",
"ParamSet",
"(",
")",
";",
"forEach",
"(",
"state",
".",
"params",
"||",
"{",
"}",
",",
"function",... | Own parameters for this state. state.url.params is already built at this point. Create and add non-url params | [
"Own",
"parameters",
"for",
"this",
"state",
".",
"state",
".",
"url",
".",
"params",
"is",
"already",
"built",
"at",
"this",
"point",
".",
"Create",
"and",
"add",
"non",
"-",
"url",
"params"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/state.js#L68-L74 | train | |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/state.js | function(state) {
var views = {};
forEach(isDefined(state.views) ? state.views : { '': state }, function (view, name) {
if (name.indexOf('@') < 0) name += '@' + state.parent.name;
views[name] = view;
});
return views;
} | javascript | function(state) {
var views = {};
forEach(isDefined(state.views) ? state.views : { '': state }, function (view, name) {
if (name.indexOf('@') < 0) name += '@' + state.parent.name;
views[name] = view;
});
return views;
} | [
"function",
"(",
"state",
")",
"{",
"var",
"views",
"=",
"{",
"}",
";",
"forEach",
"(",
"isDefined",
"(",
"state",
".",
"views",
")",
"?",
"state",
".",
"views",
":",
"{",
"''",
":",
"state",
"}",
",",
"function",
"(",
"view",
",",
"name",
")",
... | If there is no explicit multi-view configuration, make one up so we don't have to handle both cases in the view directive later. Note that having an explicit 'views' property will mean the default unnamed view properties are ignored. This is also a good time to resolve view names to absolute names, so everything is a s... | [
"If",
"there",
"is",
"no",
"explicit",
"multi",
"-",
"view",
"configuration",
"make",
"one",
"up",
"so",
"we",
"don",
"t",
"have",
"to",
"handle",
"both",
"cases",
"in",
"the",
"view",
"directive",
"later",
".",
"Note",
"that",
"having",
"an",
"explicit"... | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/state.js#L86-L94 | train | |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/state.js | handleRedirect | function handleRedirect(redirect, state, params, options) {
/**
* @ngdoc event
* @name ui.router.state.$state#$stateNotFound
* @eventOf ui.router.state.$state
* @eventType broadcast on root scope
* @description
* Fired when a requested state **cannot be found** using the ... | javascript | function handleRedirect(redirect, state, params, options) {
/**
* @ngdoc event
* @name ui.router.state.$state#$stateNotFound
* @eventOf ui.router.state.$state
* @eventType broadcast on root scope
* @description
* Fired when a requested state **cannot be found** using the ... | [
"function",
"handleRedirect",
"(",
"redirect",
",",
"state",
",",
"params",
",",
"options",
")",
"{",
"/**\n * @ngdoc event\n * @name ui.router.state.$state#$stateNotFound\n * @eventOf ui.router.state.$state\n * @eventType broadcast on root scope\n * @descriptio... | Handles the case where a state which is the target of a transition is not found, and the user can optionally retry or defer the transition | [
"Handles",
"the",
"case",
"where",
"a",
"state",
"which",
"is",
"the",
"target",
"of",
"a",
"transition",
"is",
"not",
"found",
"and",
"the",
"user",
"can",
"optionally",
"retry",
"or",
"defer",
"the",
"transition"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/state.js#L713-L774 | train |
ionic-team/ng-cordova | demo/www/lib/angular-ui-router/src/urlMatcherFactory.js | getSquashPolicy | function getSquashPolicy(config, isOptional) {
var squash = config.squash;
if (!isOptional || squash === false) return false;
if (!isDefined(squash) || squash == null) return defaultSquashPolicy;
if (squash === true || isString(squash)) return squash;
throw new Error("Invalid squash policy... | javascript | function getSquashPolicy(config, isOptional) {
var squash = config.squash;
if (!isOptional || squash === false) return false;
if (!isDefined(squash) || squash == null) return defaultSquashPolicy;
if (squash === true || isString(squash)) return squash;
throw new Error("Invalid squash policy... | [
"function",
"getSquashPolicy",
"(",
"config",
",",
"isOptional",
")",
"{",
"var",
"squash",
"=",
"config",
".",
"squash",
";",
"if",
"(",
"!",
"isOptional",
"||",
"squash",
"===",
"false",
")",
"return",
"false",
";",
"if",
"(",
"!",
"isDefined",
"(",
... | returns false, true, or the squash value to indicate the "default parameter url squash policy". | [
"returns",
"false",
"true",
"or",
"the",
"squash",
"value",
"to",
"indicate",
"the",
"default",
"parameter",
"url",
"squash",
"policy",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/angular-ui-router/src/urlMatcherFactory.js#L923-L929 | train |
ionic-team/ng-cordova | src/plugins/bluetoothSerial.js | function (address) {
var q = $q.defer();
$window.bluetoothSerial.connectInsecure(address, function () {
q.resolve();
}, function (error) {
q.reject(error);
});
return q.promise;
} | javascript | function (address) {
var q = $q.defer();
$window.bluetoothSerial.connectInsecure(address, function () {
q.resolve();
}, function (error) {
q.reject(error);
});
return q.promise;
} | [
"function",
"(",
"address",
")",
"{",
"var",
"q",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"$window",
".",
"bluetoothSerial",
".",
"connectInsecure",
"(",
"address",
",",
"function",
"(",
")",
"{",
"q",
".",
"resolve",
"(",
")",
";",
"}",
",",
"func... | not supported on iOS | [
"not",
"supported",
"on",
"iOS"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/src/plugins/bluetoothSerial.js#L26-L34 | train | |
ionic-team/ng-cordova | dist/ng-cordova.js | function (workout) {
var q = $q.defer();
$window.plugins.healthkit.saveWorkout(workout,
function (success) {
q.resolve(success);
},
function (err) {
q.resolve(err);
}
);
return q.promise;
} | javascript | function (workout) {
var q = $q.defer();
$window.plugins.healthkit.saveWorkout(workout,
function (success) {
q.resolve(success);
},
function (err) {
q.resolve(err);
}
);
return q.promise;
} | [
"function",
"(",
"workout",
")",
"{",
"var",
"q",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"$window",
".",
"plugins",
".",
"healthkit",
".",
"saveWorkout",
"(",
"workout",
",",
"function",
"(",
"success",
")",
"{",
"q",
".",
"resolve",
"(",
"success",... | Save a workout.
Workout param should be of the format:
{
'activityType': 'HKWorkoutActivityTypeCycling', // HKWorkoutActivityType constant (https://developer.apple.com/library/ios/documentation/HealthKit/Reference/HKWorkout_Class/#//apple_ref/c/tdef/HKWorkoutActivityType)
'quantityType': 'HKQuantityTypeIdentifierDista... | [
"Save",
"a",
"workout",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/dist/ng-cordova.js#L4451-L4462 | train | |
ionic-team/ng-cordova | dist/ng-cordova.js | function (promise){
promise.success = function (fn) {
promise.then(fn);
return promise;
};
promise.error = function (fn) {
promise.then(null, fn);
return promise;
};
} | javascript | function (promise){
promise.success = function (fn) {
promise.then(fn);
return promise;
};
promise.error = function (fn) {
promise.then(null, fn);
return promise;
};
} | [
"function",
"(",
"promise",
")",
"{",
"promise",
".",
"success",
"=",
"function",
"(",
"fn",
")",
"{",
"promise",
".",
"then",
"(",
"fn",
")",
";",
"return",
"promise",
";",
"}",
";",
"promise",
".",
"error",
"=",
"function",
"(",
"fn",
")",
"{",
... | Decorate the promise object.
@param promise The promise object. | [
"Decorate",
"the",
"promise",
"object",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/dist/ng-cordova.js#L6040-L6050 | train | |
ionic-team/ng-cordova | dist/ng-cordova.js | function (key, value, dict) {
var deferred = $q.defer();
var promise = deferred.promise;
function ok(value){
deferred.resolve(value);
}
function errorCallback(error){
deferred.reject(new Error(error));
... | javascript | function (key, value, dict) {
var deferred = $q.defer();
var promise = deferred.promise;
function ok(value){
deferred.resolve(value);
}
function errorCallback(error){
deferred.reject(new Error(error));
... | [
"function",
"(",
"key",
",",
"value",
",",
"dict",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"var",
"promise",
"=",
"deferred",
".",
"promise",
";",
"function",
"ok",
"(",
"value",
")",
"{",
"deferred",
".",
"resolve",
"(... | Store the value of the given dictionary and key.
@param key The key of the preference.
@param value The value to set.
@param dict The dictionary. It's optional.
@returns Returns a promise. | [
"Store",
"the",
"value",
"of",
"the",
"given",
"dictionary",
"and",
"key",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/dist/ng-cordova.js#L6059-L6086 | train | |
ionic-team/ng-cordova | dist/ng-cordova.js | function () {
var deferred = $q.defer();
var promise = deferred.promise;
function ok(value){
deferred.resolve(value);
}
function errorCallback(error){
deferred.reject(new Error(error));
}
... | javascript | function () {
var deferred = $q.defer();
var promise = deferred.promise;
function ok(value){
deferred.resolve(value);
}
function errorCallback(error){
deferred.reject(new Error(error));
}
... | [
"function",
"(",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"var",
"promise",
"=",
"deferred",
".",
"promise",
";",
"function",
"ok",
"(",
"value",
")",
"{",
"deferred",
".",
"resolve",
"(",
"value",
")",
";",
"}",
"functi... | Show the application preferences.
@returns Returns a promise. | [
"Show",
"the",
"application",
"preferences",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/dist/ng-cordova.js#L6160-L6181 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | triggerEvent | function triggerEvent(gesture, eventData){
// create DOM event
var event = ionic.Gestures.DOCUMENT.createEvent('Event');
event.initEvent(gesture, true, true);
event.gesture = eventData;
// trigger on the target if it is in the instance element,
// this is for event delegation tricks... | javascript | function triggerEvent(gesture, eventData){
// create DOM event
var event = ionic.Gestures.DOCUMENT.createEvent('Event');
event.initEvent(gesture, true, true);
event.gesture = eventData;
// trigger on the target if it is in the instance element,
// this is for event delegation tricks... | [
"function",
"triggerEvent",
"(",
"gesture",
",",
"eventData",
")",
"{",
"// create DOM event",
"var",
"event",
"=",
"ionic",
".",
"Gestures",
".",
"DOCUMENT",
".",
"createEvent",
"(",
"'Event'",
")",
";",
"event",
".",
"initEvent",
"(",
"gesture",
",",
"true... | trigger gesture event
@param {String} gesture
@param {Object} eventData
@returns {ionic.Gestures.Instance} | [
"trigger",
"gesture",
"event"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L785-L800 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | getDirection | function getDirection(touch1, touch2) {
var x = Math.abs(touch1.pageX - touch2.pageX),
y = Math.abs(touch1.pageY - touch2.pageY);
if(x >= y) {
return touch1.pageX - touch2.pageX > 0 ? ionic.Gestures.DIRECTION_LEFT : ionic.Gestures.DIRECTION_RIGHT;
}
else {
return touch1.pa... | javascript | function getDirection(touch1, touch2) {
var x = Math.abs(touch1.pageX - touch2.pageX),
y = Math.abs(touch1.pageY - touch2.pageY);
if(x >= y) {
return touch1.pageX - touch2.pageX > 0 ? ionic.Gestures.DIRECTION_LEFT : ionic.Gestures.DIRECTION_RIGHT;
}
else {
return touch1.pa... | [
"function",
"getDirection",
"(",
"touch1",
",",
"touch2",
")",
"{",
"var",
"x",
"=",
"Math",
".",
"abs",
"(",
"touch1",
".",
"pageX",
"-",
"touch2",
".",
"pageX",
")",
",",
"y",
"=",
"Math",
".",
"abs",
"(",
"touch1",
".",
"pageY",
"-",
"touch2",
... | angle to direction define
@param {Touch} touch1
@param {Touch} touch2
@returns {String} direction constant, like ionic.Gestures.DIRECTION_LEFT | [
"angle",
"to",
"direction",
"define"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1227-L1237 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | isVertical | function isVertical(direction) {
return (direction == ionic.Gestures.DIRECTION_UP || direction == ionic.Gestures.DIRECTION_DOWN);
} | javascript | function isVertical(direction) {
return (direction == ionic.Gestures.DIRECTION_UP || direction == ionic.Gestures.DIRECTION_DOWN);
} | [
"function",
"isVertical",
"(",
"direction",
")",
"{",
"return",
"(",
"direction",
"==",
"ionic",
".",
"Gestures",
".",
"DIRECTION_UP",
"||",
"direction",
"==",
"ionic",
".",
"Gestures",
".",
"DIRECTION_DOWN",
")",
";",
"}"
] | boolean if the direction is vertical
@param {String} direction
@returns {Boolean} is_vertical | [
"boolean",
"if",
"the",
"direction",
"is",
"vertical"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1291-L1293 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | stopDefaultBrowserBehavior | function stopDefaultBrowserBehavior(element, css_class) {
// changed from making many style changes to just adding a preset classname
// less DOM manipulations, less code, and easier to control in the CSS side of things
// hammer.js doesn't come with CSS, but ionic does, which is why we prefer this me... | javascript | function stopDefaultBrowserBehavior(element, css_class) {
// changed from making many style changes to just adding a preset classname
// less DOM manipulations, less code, and easier to control in the CSS side of things
// hammer.js doesn't come with CSS, but ionic does, which is why we prefer this me... | [
"function",
"stopDefaultBrowserBehavior",
"(",
"element",
",",
"css_class",
")",
"{",
"// changed from making many style changes to just adding a preset classname",
"// less DOM manipulations, less code, and easier to control in the CSS side of things",
"// hammer.js doesn't come with CSS, but i... | stop browser default behavior with css class
@param {HtmlElement} element
@param {Object} css_class | [
"stop",
"browser",
"default",
"behavior",
"with",
"css",
"class"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1301-L1311 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.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 ionic.Ge... | 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 ionic.Ge... | [
"function",
"detect",
"(",
"eventData",
")",
"{",
"if",
"(",
"!",
"this",
".",
"current",
"||",
"this",
".",
"stopped",
")",
"{",
"return",
";",
"}",
"// extend event data with calculations about scale, distance etc",
"eventData",
"=",
"this",
".",
"extendEventDat... | ionic.Gestures.gesture detection
@param {Object} eventData | [
"ionic",
".",
"Gestures",
".",
"gesture",
"detection"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1358-L1394 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.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 = ionic.Gestures.utils.extend({}, this.current);
// reset the current
this.current = null;
// stopped!
... | 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 = ionic.Gestures.utils.extend({}, this.current);
// reset the current
this.current = null;
// stopped!
... | [
"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",
"=",
"ionic",
".",
"Gestures",
".",
"utils",
".",
"extend",
"(",
... | clear the ionic.Gestures.gesture vars
this is called on endDetect, but can also be used when a final ionic.Gestures.gesture has been detected
to stop other ionic.Gestures.gestures from being fired | [
"clear",
"the",
"ionic",
".",
"Gestures",
".",
"gesture",
"vars",
"this",
"is",
"called",
"on",
"endDetect",
"but",
"can",
"also",
"be",
"used",
"when",
"a",
"final",
"ionic",
".",
"Gestures",
".",
"gesture",
"has",
"been",
"detected",
"to",
"stop",
"oth... | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1402-L1412 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | extendEventData | function extendEventData(ev) {
var startEv = this.current.startEvent;
// if the touches change, set the new touches over the startEvent touches
// this because touchevents don't have all the touches on touchstart, or the
// user must place his fingers at the EXACT same time on the screen, which... | javascript | function extendEventData(ev) {
var startEv = this.current.startEvent;
// if the touches change, set the new touches over the startEvent touches
// this because touchevents don't have all the touches on touchstart, or the
// user must place his fingers at the EXACT same time on the screen, which... | [
"function",
"extendEventData",
"(",
"ev",
")",
"{",
"var",
"startEv",
"=",
"this",
".",
"current",
".",
"startEvent",
";",
"// if the touches change, set the new touches over the startEvent touches",
"// this because touchevents don't have all the touches on touchstart, or the",
"/... | extend eventData for ionic.Gestures.gestures
@param {Object} ev
@returns {Object} ev | [
"extend",
"eventData",
"for",
"ionic",
".",
"Gestures",
".",
"gestures"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L1420-L1460 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(obj) {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < args.length; i++) {
var source = args[i];
if (source) {
for (var prop in source) {
obj[prop] = source[prop];
}
}
}
return obj;
} | javascript | function(obj) {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < args.length; i++) {
var source = args[i];
if (source) {
for (var prop in source) {
obj[prop] = source[prop];
}
}
}
return obj;
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{"... | Extend adapted from Underscore.js | [
"Extend",
"adapted",
"from",
"Underscore",
".",
"js"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L3314-L3325 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function() {
var index = uid.length;
var digit;
while (index) {
index--;
digit = uid[index].charCodeAt(0);
if (digit == 57 /*'9'*/) {
uid[index] = 'A';
return uid.join('');
}
if (digit == 90 /*'Z'*/) {
uid[index] = '0';
} ... | javascript | function() {
var index = uid.length;
var digit;
while (index) {
index--;
digit = uid[index].charCodeAt(0);
if (digit == 57 /*'9'*/) {
uid[index] = 'A';
return uid.join('');
}
if (digit == 90 /*'Z'*/) {
uid[index] = '0';
} ... | [
"function",
"(",
")",
"{",
"var",
"index",
"=",
"uid",
".",
"length",
";",
"var",
"digit",
";",
"while",
"(",
"index",
")",
"{",
"index",
"--",
";",
"digit",
"=",
"uid",
"[",
"index",
"]",
".",
"charCodeAt",
"(",
"0",
")",
";",
"if",
"(",
"digi... | A consistent way of creating unique IDs in angular. The ID is a sequence of alpha numeric
characters such as '012ABC'. The reason why we are not using simply a number counter is that
the number string gets longer over time, and it can also overflow, where as the nextId
will grow much slower, it is a string, and it will... | [
"A",
"consistent",
"way",
"of",
"creating",
"unique",
"IDs",
"in",
"angular",
".",
"The",
"ID",
"is",
"a",
"sequence",
"of",
"alpha",
"numeric",
"characters",
"such",
"as",
"012ABC",
".",
"The",
"reason",
"why",
"we",
"are",
"not",
"using",
"simply",
"a"... | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L3335-L3355 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(stepCallback, verifyCallback, completedCallback, duration, easingMethod, root) {
var start = time();
var lastFrame = start;
var percent = 0;
var dropCounter = 0;
var id = counter++;
if (!root) {
root = document.body;
}
// Compacting running db automati... | javascript | function(stepCallback, verifyCallback, completedCallback, duration, easingMethod, root) {
var start = time();
var lastFrame = start;
var percent = 0;
var dropCounter = 0;
var id = counter++;
if (!root) {
root = document.body;
}
// Compacting running db automati... | [
"function",
"(",
"stepCallback",
",",
"verifyCallback",
",",
"completedCallback",
",",
"duration",
",",
"easingMethod",
",",
"root",
")",
"{",
"var",
"start",
"=",
"time",
"(",
")",
";",
"var",
"lastFrame",
"=",
"start",
";",
"var",
"percent",
"=",
"0",
... | Start the animation.
@param stepCallback {Function} Pointer to function which is executed on every step.
Signature of the method should be `function(percent, now, virtual) { return continueWithAnimation; }`
@param verifyCallback {Function} Executed before every animation step.
Signature of the method should be `functi... | [
"Start",
"the",
"animation",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L4082-L4160 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function() {
// Use publish instead of scrollTo to allow scrolling to out of boundary position
// We don't need to normalize scrollLeft, zoomLevel, etc. here because we only y-scrolling when pull-to-refresh is enabled
this.__publish(this.__scrollLeft, -this.__refreshHeight, this.__zoomLevel, true);
var... | javascript | function() {
// Use publish instead of scrollTo to allow scrolling to out of boundary position
// We don't need to normalize scrollLeft, zoomLevel, etc. here because we only y-scrolling when pull-to-refresh is enabled
this.__publish(this.__scrollLeft, -this.__refreshHeight, this.__zoomLevel, true);
var... | [
"function",
"(",
")",
"{",
"// Use publish instead of scrollTo to allow scrolling to out of boundary position",
"// We don't need to normalize scrollLeft, zoomLevel, etc. here because we only y-scrolling when pull-to-refresh is enabled",
"this",
".",
"__publish",
"(",
"this",
".",
"__scrollL... | Starts pull-to-refresh manually. | [
"Starts",
"pull",
"-",
"to",
"-",
"refresh",
"manually",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L5287-L5298 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(level, animate, originLeft, originTop) {
var self = this;
if (!self.options.zooming) {
throw new Error("Zooming is not enabled!");
}
// Stop deceleration
if (self.__isDecelerating) {
zyngaCore.effect.Animate.stop(self.__isDecelerating);
self.__isDecelerating = false;
... | javascript | function(level, animate, originLeft, originTop) {
var self = this;
if (!self.options.zooming) {
throw new Error("Zooming is not enabled!");
}
// Stop deceleration
if (self.__isDecelerating) {
zyngaCore.effect.Animate.stop(self.__isDecelerating);
self.__isDecelerating = false;
... | [
"function",
"(",
"level",
",",
"animate",
",",
"originLeft",
",",
"originTop",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"self",
".",
"options",
".",
"zooming",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Zooming is not enabled!\"",
")",
... | Zooms to the given level. Supports optional animation. Zooms
the center when no coordinates are given.
@param level {Number} Level to zoom to
@param animate {Boolean} Whether to use animation
@param originLeft {Number} Zoom in at given left coordinate
@param originTop {Number} Zoom in at given top coordinate | [
"Zooms",
"to",
"the",
"given",
"level",
".",
"Supports",
"optional",
"animation",
".",
"Zooms",
"the",
"center",
"when",
"no",
"coordinates",
"are",
"given",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L5367-L5418 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(left, top, animate, zoom, wasResize) {
var self = this;
// Stop deceleration
if (self.__isDecelerating) {
zyngaCore.effect.Animate.stop(self.__isDecelerating);
self.__isDecelerating = false;
}
// Correct coordinates based on new zoom level
if (zoom != null && zoom !== self... | javascript | function(left, top, animate, zoom, wasResize) {
var self = this;
// Stop deceleration
if (self.__isDecelerating) {
zyngaCore.effect.Animate.stop(self.__isDecelerating);
self.__isDecelerating = false;
}
// Correct coordinates based on new zoom level
if (zoom != null && zoom !== self... | [
"function",
"(",
"left",
",",
"top",
",",
"animate",
",",
"zoom",
",",
"wasResize",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Stop deceleration",
"if",
"(",
"self",
".",
"__isDecelerating",
")",
"{",
"zyngaCore",
".",
"effect",
".",
"Animate",
".",
... | Scrolls to the given position. Respect limitations and snapping automatically.
@param left {Number} Horizontal scroll position, keeps current if value is <code>null</code>
@param top {Number} Vertical scroll position, keeps current if value is <code>null</code>
@param animate {Boolean} Whether the scrolling should hap... | [
"Scrolls",
"to",
"the",
"given",
"position",
".",
"Respect",
"limitations",
"and",
"snapping",
"automatically",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L5442-L5512 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function() {
var self = this;
clearTimeout(self.__sizerTimeout);
var sizer = function() {
self.resize();
// if ((self.options.scrollingX && !self.__maxScrollLeft) || (self.options.scrollingY && !self.__maxScrollTop)) {
// //self.__sizerTimeout = setTimeout(sizer, 1000);
// }
... | javascript | function() {
var self = this;
clearTimeout(self.__sizerTimeout);
var sizer = function() {
self.resize();
// if ((self.options.scrollingX && !self.__maxScrollLeft) || (self.options.scrollingY && !self.__maxScrollTop)) {
// //self.__sizerTimeout = setTimeout(sizer, 1000);
// }
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"clearTimeout",
"(",
"self",
".",
"__sizerTimeout",
")",
";",
"var",
"sizer",
"=",
"function",
"(",
")",
"{",
"self",
".",
"resize",
"(",
")",
";",
"// if ((self.options.scrollingX && !self.__maxScr... | If the scroll view isn't sized correctly on start, wait until we have at least some size | [
"If",
"the",
"scroll",
"view",
"isn",
"t",
"sized",
"correctly",
"on",
"start",
"wait",
"until",
"we",
"have",
"at",
"least",
"some",
"size"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L6071-L6086 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(target) {
while (target) {
if (target.classList && target.classList.contains(ITEM_CLASS)) {
return target;
}
target = target.parentNode;
}
return null;
} | javascript | function(target) {
while (target) {
if (target.classList && target.classList.contains(ITEM_CLASS)) {
return target;
}
target = target.parentNode;
}
return null;
} | [
"function",
"(",
"target",
")",
"{",
"while",
"(",
"target",
")",
"{",
"if",
"(",
"target",
".",
"classList",
"&&",
"target",
".",
"classList",
".",
"contains",
"(",
"ITEM_CLASS",
")",
")",
"{",
"return",
"target",
";",
"}",
"target",
"=",
"target",
... | Return the list item from the given target | [
"Return",
"the",
"list",
"item",
"from",
"the",
"given",
"target"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L6832-L6840 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(e) {
var _this = this, content, buttons;
if (Math.abs(e.gesture.deltaY) > 5) {
this._didDragUpOrDown = true;
}
// If we get a drag event, make sure we aren't in another drag, then check if we should
// start one
if (!this.isDragging && !this._dragOp) {
this... | javascript | function(e) {
var _this = this, content, buttons;
if (Math.abs(e.gesture.deltaY) > 5) {
this._didDragUpOrDown = true;
}
// If we get a drag event, make sure we aren't in another drag, then check if we should
// start one
if (!this.isDragging && !this._dragOp) {
this... | [
"function",
"(",
"e",
")",
"{",
"var",
"_this",
"=",
"this",
",",
"content",
",",
"buttons",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"e",
".",
"gesture",
".",
"deltaY",
")",
">",
"5",
")",
"{",
"this",
".",
"_didDragUpOrDown",
"=",
"true",
";",
... | Process the drag event to move the item to the left or right. | [
"Process",
"the",
"drag",
"event",
"to",
"move",
"the",
"item",
"to",
"the",
"left",
"or",
"right",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L6914-L6935 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | shallowCopy | function shallowCopy(src, dst) {
if (isArray(src)) {
dst = dst || [];
for (var i = 0, ii = src.length; i < ii; i++) {
dst[i] = src[i];
}
} else if (isObject(src)) {
dst = dst || {};
for (var key in src) {
if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) {
dst[key] = s... | javascript | function shallowCopy(src, dst) {
if (isArray(src)) {
dst = dst || [];
for (var i = 0, ii = src.length; i < ii; i++) {
dst[i] = src[i];
}
} else if (isObject(src)) {
dst = dst || {};
for (var key in src) {
if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) {
dst[key] = s... | [
"function",
"shallowCopy",
"(",
"src",
",",
"dst",
")",
"{",
"if",
"(",
"isArray",
"(",
"src",
")",
")",
"{",
"dst",
"=",
"dst",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"src",
".",
"length",
";",
"i",
"<",
"ii... | Creates a shallow copy of an object, an array or a primitive.
Assumes that there are no proto properties for objects. | [
"Creates",
"a",
"shallow",
"copy",
"of",
"an",
"object",
"an",
"array",
"or",
"a",
"primitive",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L8667-L8685 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | getter | function getter(obj, path, bindFnToScope) {
if (!path) return obj;
var keys = path.split('.');
var key;
var lastInstance = obj;
var len = keys.length;
for (var i = 0; i < len; i++) {
key = keys[i];
if (obj) {
obj = (lastInstance = obj)[key];
}
}
if (!bindFnToScope && isFunction(obj)) ... | javascript | function getter(obj, path, bindFnToScope) {
if (!path) return obj;
var keys = path.split('.');
var key;
var lastInstance = obj;
var len = keys.length;
for (var i = 0; i < len; i++) {
key = keys[i];
if (obj) {
obj = (lastInstance = obj)[key];
}
}
if (!bindFnToScope && isFunction(obj)) ... | [
"function",
"getter",
"(",
"obj",
",",
"path",
",",
"bindFnToScope",
")",
"{",
"if",
"(",
"!",
"path",
")",
"return",
"obj",
";",
"var",
"keys",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"key",
";",
"var",
"lastInstance",
"=",
"obj",
... | Return the value accessible from the object by path. Any undefined traversals are ignored
@param {Object} obj starting object
@param {String} path path to traverse
@param {boolean} [bindFnToScope=true]
@returns {Object} value as accessible by path
TODO(misko): this function needs to be removed | [
"Return",
"the",
"value",
"accessible",
"from",
"the",
"object",
"by",
"path",
".",
"Any",
"undefined",
"traversals",
"are",
"ignored"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L9423-L9440 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | HashMap | function HashMap(array, isolatedUid) {
if (isolatedUid) {
var uid = 0;
this.nextUid = function() {
return ++uid;
};
}
forEach(array, this.put, this);
} | javascript | function HashMap(array, isolatedUid) {
if (isolatedUid) {
var uid = 0;
this.nextUid = function() {
return ++uid;
};
}
forEach(array, this.put, this);
} | [
"function",
"HashMap",
"(",
"array",
",",
"isolatedUid",
")",
"{",
"if",
"(",
"isolatedUid",
")",
"{",
"var",
"uid",
"=",
"0",
";",
"this",
".",
"nextUid",
"=",
"function",
"(",
")",
"{",
"return",
"++",
"uid",
";",
"}",
";",
"}",
"forEach",
"(",
... | HashMap which can use objects as keys | [
"HashMap",
"which",
"can",
"use",
"objects",
"as",
"keys"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L11134-L11142 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | directiveIsMultiElement | function directiveIsMultiElement(name) {
if (hasDirectives.hasOwnProperty(name)) {
for (var directive, directives = $injector.get(name + Suffix),
i = 0, ii = directives.length; i < ii; i++) {
directive = directives[i];
if (directive.multiElement) {
return true;
... | javascript | function directiveIsMultiElement(name) {
if (hasDirectives.hasOwnProperty(name)) {
for (var directive, directives = $injector.get(name + Suffix),
i = 0, ii = directives.length; i < ii; i++) {
directive = directives[i];
if (directive.multiElement) {
return true;
... | [
"function",
"directiveIsMultiElement",
"(",
"name",
")",
"{",
"if",
"(",
"hasDirectives",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"for",
"(",
"var",
"directive",
",",
"directives",
"=",
"$injector",
".",
"get",
"(",
"name",
"+",
"Suffix",
")",
... | looks up the directive and returns true if it is a multi-element directive,
and therefore requires DOM nodes between -start and -end markers to be grouped
together.
@param {string} name name of the directive to look up.
@returns true if directive was registered as multi-element. | [
"looks",
"up",
"the",
"directive",
"and",
"returns",
"true",
"if",
"it",
"is",
"a",
"multi",
"-",
"element",
"directive",
"and",
"therefore",
"requires",
"DOM",
"nodes",
"between",
"-",
"start",
"and",
"-",
"end",
"markers",
"to",
"be",
"grouped",
"togethe... | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L15616-L15627 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | mergeTemplateAttributes | function mergeTemplateAttributes(dst, src) {
var srcAttr = src.$attr,
dstAttr = dst.$attr,
$element = dst.$$element;
// reapply the old attributes to the new element
forEach(dst, function(value, key) {
if (key.charAt(0) != '$') {
if (src[key] && src[key] !== valu... | javascript | function mergeTemplateAttributes(dst, src) {
var srcAttr = src.$attr,
dstAttr = dst.$attr,
$element = dst.$$element;
// reapply the old attributes to the new element
forEach(dst, function(value, key) {
if (key.charAt(0) != '$') {
if (src[key] && src[key] !== valu... | [
"function",
"mergeTemplateAttributes",
"(",
"dst",
",",
"src",
")",
"{",
"var",
"srcAttr",
"=",
"src",
".",
"$attr",
",",
"dstAttr",
"=",
"dst",
".",
"$attr",
",",
"$element",
"=",
"dst",
".",
"$$element",
";",
"// reapply the old attributes to the new element",... | When the element is replaced with HTML template then the new attributes
on the template need to be merged with the existing attributes in the DOM.
The desired effect is to have both of the attributes present.
@param {object} dst destination attributes (original DOM)
@param {object} src source attributes (from the dire... | [
"When",
"the",
"element",
"is",
"replaced",
"with",
"HTML",
"template",
"then",
"the",
"new",
"attributes",
"on",
"the",
"template",
"need",
"to",
"be",
"merged",
"with",
"the",
"existing",
"attributes",
"in",
"the",
"DOM",
".",
"The",
"desired",
"effect",
... | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L15637-L15668 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | byPriority | function byPriority(a, b) {
var diff = b.priority - a.priority;
if (diff !== 0) return diff;
if (a.name !== b.name) return (a.name < b.name) ? -1 : 1;
return a.index - b.index;
} | javascript | function byPriority(a, b) {
var diff = b.priority - a.priority;
if (diff !== 0) return diff;
if (a.name !== b.name) return (a.name < b.name) ? -1 : 1;
return a.index - b.index;
} | [
"function",
"byPriority",
"(",
"a",
",",
"b",
")",
"{",
"var",
"diff",
"=",
"b",
".",
"priority",
"-",
"a",
".",
"priority",
";",
"if",
"(",
"diff",
"!==",
"0",
")",
"return",
"diff",
";",
"if",
"(",
"a",
".",
"name",
"!==",
"b",
".",
"name",
... | Sorting function for bound directives. | [
"Sorting",
"function",
"for",
"bound",
"directives",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L15789-L15794 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(event) {
// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
// it. In particular the event is not fired when backspace or delete key are pressed or
// when cut operation is performed.
// IE10+ implements 'input' event but it erroneously f... | javascript | function(event) {
// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
// it. In particular the event is not fired when backspace or delete key are pressed or
// when cut operation is performed.
// IE10+ implements 'input' event but it erroneously f... | [
"function",
"(",
"event",
")",
"{",
"// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have",
"// it. In particular the event is not fired when backspace or delete key are pressed or",
"// when cut operation is performed.",
"// IE10+ implements 'input' event but ... | jshint +W018 | [
"jshint",
"+",
"W018"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L23760-L23774 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | urlIsSameOrigin | function urlIsSameOrigin(requestUrl) {
var parsed = (isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
return (parsed.protocol === originUrl.protocol &&
parsed.host === originUrl.host);
} | javascript | function urlIsSameOrigin(requestUrl) {
var parsed = (isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
return (parsed.protocol === originUrl.protocol &&
parsed.host === originUrl.host);
} | [
"function",
"urlIsSameOrigin",
"(",
"requestUrl",
")",
"{",
"var",
"parsed",
"=",
"(",
"isString",
"(",
"requestUrl",
")",
")",
"?",
"urlResolve",
"(",
"requestUrl",
")",
":",
"requestUrl",
";",
"return",
"(",
"parsed",
".",
"protocol",
"===",
"originUrl",
... | Parse a request URL and determine whether this is a same-origin request as the application document.
@param {string|object} requestUrl The url of the request as a string that will be resolved
or a parsed URL object.
@returns {boolean} Whether the request is for the same origin as the application document. | [
"Parse",
"a",
"request",
"URL",
"and",
"determine",
"whether",
"this",
"is",
"a",
"same",
"-",
"origin",
"request",
"as",
"the",
"application",
"document",
"."
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L24140-L24144 | 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.