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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
aurbano/smart-area | dist/smart-area.js | triggerDropdownAutocomplete | function triggerDropdownAutocomplete(){
// First check with the autocomplete words (the ones that are not objects
var autocomplete = [],
suggestions = [],
text = $scope.areaData,
position = getCharacterPosition(),
... | javascript | function triggerDropdownAutocomplete(){
// First check with the autocomplete words (the ones that are not objects
var autocomplete = [],
suggestions = [],
text = $scope.areaData,
position = getCharacterPosition(),
... | [
"function",
"triggerDropdownAutocomplete",
"(",
")",
"{",
"// First check with the autocomplete words (the ones that are not objects",
"var",
"autocomplete",
"=",
"[",
"]",
",",
"suggestions",
"=",
"[",
"]",
",",
"text",
"=",
"$scope",
".",
"areaData",
",",
"position",
... | Trigger a simple autocomplete, this checks the last word and determines
whether any word on the autocomplete lists matches it | [
"Trigger",
"a",
"simple",
"autocomplete",
"this",
"checks",
"the",
"last",
"word",
"and",
"determines",
"whether",
"any",
"word",
"on",
"the",
"autocomplete",
"lists",
"matches",
"it"
] | 372b17f9c4c5541591f181ddde4d0e4475c85f3f | https://github.com/aurbano/smart-area/blob/372b17f9c4c5541591f181ddde4d0e4475c85f3f/dist/smart-area.js#L414-L456 | train |
nufyoot/createsend-node | lib/interface/transactional.js | smartEmailDetails | function smartEmailDetails(details, callback) {
createsend.get('transactional/smartemail/'+details.smartEmailID, null, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function smartEmailDetails(details, callback) {
createsend.get('transactional/smartemail/'+details.smartEmailID, null, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"smartEmailDetails",
"(",
"details",
",",
"callback",
")",
"{",
"createsend",
".",
"get",
"(",
"'transactional/smartemail/'",
"+",
"details",
".",
"smartEmailID",
",",
"null",
",",
"null",
",",
"function",
"(",
"error",
",",
"results",
")",
"{",
... | Get the details for a smart transactional email | [
"Get",
"the",
"details",
"for",
"a",
"smart",
"transactional",
"email"
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L28-L32 | train |
nufyoot/createsend-node | lib/interface/transactional.js | sendSmartEmail | function sendSmartEmail(details, callback) {
createsend.post('transactional/smartemail/'+details.smartEmailID+'/send', null, details, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function sendSmartEmail(details, callback) {
createsend.post('transactional/smartemail/'+details.smartEmailID+'/send', null, details, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"sendSmartEmail",
"(",
"details",
",",
"callback",
")",
"{",
"createsend",
".",
"post",
"(",
"'transactional/smartemail/'",
"+",
"details",
".",
"smartEmailID",
"+",
"'/send'",
",",
"null",
",",
"details",
",",
"function",
"(",
"error",
",",
"resul... | Deliver a smart email. Properties in the data property will be available in your email as variables which can be referenced using our Template Language. | [
"Deliver",
"a",
"smart",
"email",
".",
"Properties",
"in",
"the",
"data",
"property",
"will",
"be",
"available",
"in",
"your",
"email",
"as",
"variables",
"which",
"can",
"be",
"referenced",
"using",
"our",
"Template",
"Language",
"."
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L35-L39 | train |
nufyoot/createsend-node | lib/interface/transactional.js | sendClassicEmail | function sendClassicEmail(details, callback) {
deleteNullProperties(details);
createsend.post('transactional/classicEmail/send', details.clientID, details, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function sendClassicEmail(details, callback) {
deleteNullProperties(details);
createsend.post('transactional/classicEmail/send', details.clientID, details, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"sendClassicEmail",
"(",
"details",
",",
"callback",
")",
"{",
"deleteNullProperties",
"(",
"details",
")",
";",
"createsend",
".",
"post",
"(",
"'transactional/classicEmail/send'",
",",
"details",
".",
"clientID",
",",
"details",
",",
"function",
"(",... | Send an email by providing your own content | [
"Send",
"an",
"email",
"by",
"providing",
"your",
"own",
"content"
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L42-L47 | train |
nufyoot/createsend-node | lib/interface/transactional.js | classicEmailGroupList | function classicEmailGroupList(details, callback) {
createsend.get('transactional/classicEmail/groups', details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function classicEmailGroupList(details, callback) {
createsend.get('transactional/classicEmail/groups', details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"classicEmailGroupList",
"(",
"details",
",",
"callback",
")",
"{",
"createsend",
".",
"get",
"(",
"'transactional/classicEmail/groups'",
",",
"details",
",",
"null",
",",
"function",
"(",
"error",
",",
"results",
")",
"{",
"txResponseCallback",
"(",
... | Get a list of classic email groups | [
"Get",
"a",
"list",
"of",
"classic",
"email",
"groups"
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L50-L54 | train |
nufyoot/createsend-node | lib/interface/transactional.js | statistics | function statistics(details, callback) {
deleteNullProperties(details);
createsend.get('transactional/statistics', details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function statistics(details, callback) {
deleteNullProperties(details);
createsend.get('transactional/statistics', details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"statistics",
"(",
"details",
",",
"callback",
")",
"{",
"deleteNullProperties",
"(",
"details",
")",
";",
"createsend",
".",
"get",
"(",
"'transactional/statistics'",
",",
"details",
",",
"null",
",",
"function",
"(",
"error",
",",
"results",
")",... | Get the delivery and engagement statistics, optionally filter by smart email or classic group. | [
"Get",
"the",
"delivery",
"and",
"engagement",
"statistics",
"optionally",
"filter",
"by",
"smart",
"email",
"or",
"classic",
"group",
"."
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L57-L62 | train |
nufyoot/createsend-node | lib/interface/transactional.js | messageDetails | function messageDetails(details, callback) {
createsend.get('transactional/messages/'+details.messageID, details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function messageDetails(details, callback) {
createsend.get('transactional/messages/'+details.messageID, details, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"messageDetails",
"(",
"details",
",",
"callback",
")",
"{",
"createsend",
".",
"get",
"(",
"'transactional/messages/'",
"+",
"details",
".",
"messageID",
",",
"details",
",",
"null",
",",
"function",
"(",
"error",
",",
"results",
")",
"{",
"txRe... | Get the message details, no matter how it was sent. Includes status. | [
"Get",
"the",
"message",
"details",
"no",
"matter",
"how",
"it",
"was",
"sent",
".",
"Includes",
"status",
"."
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L73-L77 | train |
nufyoot/createsend-node | lib/interface/transactional.js | messageResend | function messageResend(details, callback) {
createsend.post('transactional/messages/'+details.messageID+'/resend', null, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | javascript | function messageResend(details, callback) {
createsend.post('transactional/messages/'+details.messageID+'/resend', null, null, function(error, results) {
txResponseCallback(error, results, callback);
}, true);
} | [
"function",
"messageResend",
"(",
"details",
",",
"callback",
")",
"{",
"createsend",
".",
"post",
"(",
"'transactional/messages/'",
"+",
"details",
".",
"messageID",
"+",
"'/resend'",
",",
"null",
",",
"null",
",",
"function",
"(",
"error",
",",
"results",
... | Resend the message | [
"Resend",
"the",
"message"
] | 13129f097968c8d15e607374b65969443963c8fc | https://github.com/nufyoot/createsend-node/blob/13129f097968c8d15e607374b65969443963c8fc/lib/interface/transactional.js#L80-L84 | train |
hipster-labs/angular-object-diff | angular-object-diff.js | diff | function diff(a, b, shallow, isOwn) {
if (a === b) {
return equalObj(a);
}
var diffValue = {};
var equal = true;
for (var key in a) {
if ((!isOwn && key in b) || (isOwn && typeof b != 'undefined' && b.hasOwnProperty(key))) {
... | javascript | function diff(a, b, shallow, isOwn) {
if (a === b) {
return equalObj(a);
}
var diffValue = {};
var equal = true;
for (var key in a) {
if ((!isOwn && key in b) || (isOwn && typeof b != 'undefined' && b.hasOwnProperty(key))) {
... | [
"function",
"diff",
"(",
"a",
",",
"b",
",",
"shallow",
",",
"isOwn",
")",
"{",
"if",
"(",
"a",
"===",
"b",
")",
"{",
"return",
"equalObj",
"(",
"a",
")",
";",
"}",
"var",
"diffValue",
"=",
"{",
"}",
";",
"var",
"equal",
"=",
"true",
";",
"fo... | diff between object a and b
@param {Object} a
@param {Object} b
@param shallow
@param isOwn
@return {Object} | [
"diff",
"between",
"object",
"a",
"and",
"b"
] | 4299d0680d2aa276ab52cc7e3654df8b2689c521 | https://github.com/hipster-labs/angular-object-diff/blob/4299d0680d2aa276ab52cc7e3654df8b2689c521/angular-object-diff.js#L58-L116 | train |
taskcluster/gdb-js | src/index.js | escape | function escape (script) {
return script.replace(/\\/g, '\\\\').replace(/\n/g, '\\n')
.replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/"/g, '\\"')
} | javascript | function escape (script) {
return script.replace(/\\/g, '\\\\').replace(/\n/g, '\\n')
.replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/"/g, '\\"')
} | [
"function",
"escape",
"(",
"script",
")",
"{",
"return",
"script",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"'\\\\n'",
")",
".",
"replace",
"(",
"/",
"\\r",
"/",
"g",
",",... | Escapes symbols in python code so that we can send it using inline mode.
@param {string} script The Python script.
@returns {string} The escaped python script.
@ignore | [
"Escapes",
"symbols",
"in",
"python",
"code",
"so",
"that",
"we",
"can",
"send",
"it",
"using",
"inline",
"mode",
"."
] | 497be0bb1e16866f4654e79a0a8da0ede396f031 | https://github.com/taskcluster/gdb-js/blob/497be0bb1e16866f4654e79a0a8da0ede396f031/src/index.js#L64-L67 | train |
TodayTix/svg-sprite-webpack-plugin | src/plugin.js | replaceAll | function replaceAll(source, name, oldStr, newStr) {
const transformedSource = new ReplaceSource(source, name);
const reTester = new RegExp(oldStr, 'g');
let reResult = reTester.exec(source.source());
if (reResult == null) {
return source;
}
while (reResult != null) {
transformedSource.replace(
... | javascript | function replaceAll(source, name, oldStr, newStr) {
const transformedSource = new ReplaceSource(source, name);
const reTester = new RegExp(oldStr, 'g');
let reResult = reTester.exec(source.source());
if (reResult == null) {
return source;
}
while (reResult != null) {
transformedSource.replace(
... | [
"function",
"replaceAll",
"(",
"source",
",",
"name",
",",
"oldStr",
",",
"newStr",
")",
"{",
"const",
"transformedSource",
"=",
"new",
"ReplaceSource",
"(",
"source",
",",
"name",
")",
";",
"const",
"reTester",
"=",
"new",
"RegExp",
"(",
"oldStr",
",",
... | Takes a source, and a string to replace, and returns a ReplaceSource with
all the instances of that string replaced.
@param {Source} source The original source
@param {string} name ReplaceSource has a `name` param in its constructor.
I don't actually know why.
@param {string} oldStr The string to be replaced
@para... | [
"Takes",
"a",
"source",
"and",
"a",
"string",
"to",
"replace",
"and",
"returns",
"a",
"ReplaceSource",
"with",
"all",
"the",
"instances",
"of",
"that",
"string",
"replaced",
"."
] | 941a0c5e01887d876f04b26feb5edae95f291080 | https://github.com/TodayTix/svg-sprite-webpack-plugin/blob/941a0c5e01887d876f04b26feb5edae95f291080/src/plugin.js#L18-L38 | train |
bvaughn/jasmine-promise-matchers | source/source.js | function(promise, expectedState, opt_expectedData, opt_util, opt_customEqualityTesters) {
var info = {};
promise.then(
function(data) {
info.actualData = data;
info.actualState = PROMISE_STATE.RESOLVED;
},
function(data) {
info.actualData = data;
info.actualSta... | javascript | function(promise, expectedState, opt_expectedData, opt_util, opt_customEqualityTesters) {
var info = {};
promise.then(
function(data) {
info.actualData = data;
info.actualState = PROMISE_STATE.RESOLVED;
},
function(data) {
info.actualData = data;
info.actualSta... | [
"function",
"(",
"promise",
",",
"expectedState",
",",
"opt_expectedData",
",",
"opt_util",
",",
"opt_customEqualityTesters",
")",
"{",
"var",
"info",
"=",
"{",
"}",
";",
"promise",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"info",
".",
"actualD... | Helper method to verify expectations and return a Jasmine-friendly info-object.
The last 2 parameters are optional and only required for Jasmine 2.
For more info see http://jasmine.github.io/2.0/custom_matcher.html
@param promise Promise to test
@param expectedState PROMISE_STATE enum
@param opt_expectedData Optional... | [
"Helper",
"method",
"to",
"verify",
"expectations",
"and",
"return",
"a",
"Jasmine",
"-",
"friendly",
"info",
"-",
"object",
"."
] | 9214777863fd42e2292ba025ea0ffb3802a6ff21 | https://github.com/bvaughn/jasmine-promise-matchers/blob/9214777863fd42e2292ba025ea0ffb3802a6ff21/source/source.js#L44-L128 | train | |
taion/rrtr | modules/createTransitionManager.js | listenBeforeLeavingRoute | function listenBeforeLeavingRoute(route, hook) {
// TODO: Warn if they register for a route that isn't currently
// active. They're probably doing something wrong, like re-creating
// route objects on every location change.
const routeID = getRouteID(route)
let hooks = RouteHooks[routeID]
if (!... | javascript | function listenBeforeLeavingRoute(route, hook) {
// TODO: Warn if they register for a route that isn't currently
// active. They're probably doing something wrong, like re-creating
// route objects on every location change.
const routeID = getRouteID(route)
let hooks = RouteHooks[routeID]
if (!... | [
"function",
"listenBeforeLeavingRoute",
"(",
"route",
",",
"hook",
")",
"{",
"// TODO: Warn if they register for a route that isn't currently",
"// active. They're probably doing something wrong, like re-creating",
"// route objects on every location change.",
"const",
"routeID",
"=",
"g... | Registers the given hook function to run before leaving the given route.
During a normal transition, the hook function receives the next location
as its only argument and must return either a) a prompt message to show
the user, to make sure they want to leave the page or b) false, to prevent
the transition.
During th... | [
"Registers",
"the",
"given",
"hook",
"function",
"to",
"run",
"before",
"leaving",
"the",
"given",
"route",
"."
] | a8c86d059daffad47ca893d98e9b6049d49eb83c | https://github.com/taion/rrtr/blob/a8c86d059daffad47ca893d98e9b6049d49eb83c/modules/createTransitionManager.js#L210-L253 | train |
taion/rrtr | modules/createTransitionManager.js | listen | function listen(listener) {
// TODO: Only use a single history listener. Otherwise we'll
// end up with multiple concurrent calls to match.
return history.listen(function (location) {
if (state.location === location) {
listener(null, state)
} else {
match(location, function (erro... | javascript | function listen(listener) {
// TODO: Only use a single history listener. Otherwise we'll
// end up with multiple concurrent calls to match.
return history.listen(function (location) {
if (state.location === location) {
listener(null, state)
} else {
match(location, function (erro... | [
"function",
"listen",
"(",
"listener",
")",
"{",
"// TODO: Only use a single history listener. Otherwise we'll",
"// end up with multiple concurrent calls to match.",
"return",
"history",
".",
"listen",
"(",
"function",
"(",
"location",
")",
"{",
"if",
"(",
"state",
".",
... | This is the API for stateful environments. As the location
changes, we update state and call the listener. We can also
gracefully handle errors and redirects. | [
"This",
"is",
"the",
"API",
"for",
"stateful",
"environments",
".",
"As",
"the",
"location",
"changes",
"we",
"update",
"state",
"and",
"call",
"the",
"listener",
".",
"We",
"can",
"also",
"gracefully",
"handle",
"errors",
"and",
"redirects",
"."
] | a8c86d059daffad47ca893d98e9b6049d49eb83c | https://github.com/taion/rrtr/blob/a8c86d059daffad47ca893d98e9b6049d49eb83c/modules/createTransitionManager.js#L260-L284 | train |
gleero/grunt-favicons | tasks/favicons.js | function(args) {
args.unshift("convert");
var ret = execute(args.join(" "));
if (ret.code === 127) {
return grunt.warn(
'You need to have ImageMagick installed in your PATH for this task to work.'
);
}
} | javascript | function(args) {
args.unshift("convert");
var ret = execute(args.join(" "));
if (ret.code === 127) {
return grunt.warn(
'You need to have ImageMagick installed in your PATH for this task to work.'
);
}
} | [
"function",
"(",
"args",
")",
"{",
"args",
".",
"unshift",
"(",
"\"convert\"",
")",
";",
"var",
"ret",
"=",
"execute",
"(",
"args",
".",
"join",
"(",
"\" \"",
")",
")",
";",
"if",
"(",
"ret",
".",
"code",
"===",
"127",
")",
"{",
"return",
"grunt"... | Convert image with imagemagick | [
"Convert",
"image",
"with",
"imagemagick"
] | 99489fce4a0866f321e620534727c9e306c2605d | https://github.com/gleero/grunt-favicons/blob/99489fce4a0866f321e620534727c9e306c2605d/tasks/favicons.js#L58-L66 | train | |
thinkjs/think-model | index.js | injectModel | function injectModel(name, config, m) {
const modelConfig = app.think.config('model', undefined, m);
const cacheConfig = app.think.config('cache', undefined, m);
config = helper.parseAdapterConfig(modelConfig, config);
const instance = model(name, config, m);
instance._cacheConfig = cacheConfig;
... | javascript | function injectModel(name, config, m) {
const modelConfig = app.think.config('model', undefined, m);
const cacheConfig = app.think.config('cache', undefined, m);
config = helper.parseAdapterConfig(modelConfig, config);
const instance = model(name, config, m);
instance._cacheConfig = cacheConfig;
... | [
"function",
"injectModel",
"(",
"name",
",",
"config",
",",
"m",
")",
"{",
"const",
"modelConfig",
"=",
"app",
".",
"think",
".",
"config",
"(",
"'model'",
",",
"undefined",
",",
"m",
")",
";",
"const",
"cacheConfig",
"=",
"app",
".",
"think",
".",
"... | inject model method
@param {String} name
@param {Object} config
@param {String} m | [
"inject",
"model",
"method"
] | 539f74fb54313ceaf20befe4fc8bb206b93cfadc | https://github.com/thinkjs/think-model/blob/539f74fb54313ceaf20befe4fc8bb206b93cfadc/index.js#L42-L49 | train |
RangerMauve/mqtt-regex | index.js | parse | function parse(topic) {
var tokens = tokenize(topic).map(process_token);
var result = {
regex: make_regex(tokens),
getParams: make_pram_getter(tokens),
topic: make_clean_topic(tokens)
};
result.exec = exec.bind(result);
return result;
} | javascript | function parse(topic) {
var tokens = tokenize(topic).map(process_token);
var result = {
regex: make_regex(tokens),
getParams: make_pram_getter(tokens),
topic: make_clean_topic(tokens)
};
result.exec = exec.bind(result);
return result;
} | [
"function",
"parse",
"(",
"topic",
")",
"{",
"var",
"tokens",
"=",
"tokenize",
"(",
"topic",
")",
".",
"map",
"(",
"process_token",
")",
";",
"var",
"result",
"=",
"{",
"regex",
":",
"make_regex",
"(",
"tokens",
")",
",",
"getParams",
":",
"make_pram_g... | Parses topic string with parameters
@param topic Topic string with optional params
@returns {Object} Compiles a regex for matching topics, getParams for getting params, and exec for doing both | [
"Parses",
"topic",
"string",
"with",
"parameters"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L34-L43 | train |
RangerMauve/mqtt-regex | index.js | exec | function exec(topic) {
var regex = this.regex;
var getParams = this.getParams;
var match = regex.exec(topic);
if (match) return getParams(match);
} | javascript | function exec(topic) {
var regex = this.regex;
var getParams = this.getParams;
var match = regex.exec(topic);
if (match) return getParams(match);
} | [
"function",
"exec",
"(",
"topic",
")",
"{",
"var",
"regex",
"=",
"this",
".",
"regex",
";",
"var",
"getParams",
"=",
"this",
".",
"getParams",
";",
"var",
"match",
"=",
"regex",
".",
"exec",
"(",
"topic",
")",
";",
"if",
"(",
"match",
")",
"return"... | Matches regex against topic, returns params if successful
@param topic Topic to match | [
"Matches",
"regex",
"against",
"topic",
"returns",
"params",
"if",
"successful"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L49-L54 | train |
RangerMauve/mqtt-regex | index.js | process_token | function process_token(token, index, tokens) {
var last = (index === (tokens.length - 1));
if (token[0] === "+") return process_single(token, last);
else if (token[0] === "#") return process_multi(token, last);
else return process_raw(token, last);
} | javascript | function process_token(token, index, tokens) {
var last = (index === (tokens.length - 1));
if (token[0] === "+") return process_single(token, last);
else if (token[0] === "#") return process_multi(token, last);
else return process_raw(token, last);
} | [
"function",
"process_token",
"(",
"token",
",",
"index",
",",
"tokens",
")",
"{",
"var",
"last",
"=",
"(",
"index",
"===",
"(",
"tokens",
".",
"length",
"-",
"1",
")",
")",
";",
"if",
"(",
"token",
"[",
"0",
"]",
"===",
"\"+\"",
")",
"return",
"p... | Processes token and determines if it's a `single`, `multi` or `raw` token Each token contains the type, an optional parameter name, and a piece of the regex The piece can have a different syntax for when it is last | [
"Processes",
"token",
"and",
"determines",
"if",
"it",
"s",
"a",
"single",
"multi",
"or",
"raw",
"token",
"Each",
"token",
"contains",
"the",
"type",
"an",
"optional",
"parameter",
"name",
"and",
"a",
"piece",
"of",
"the",
"regex",
"The",
"piece",
"can",
... | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L64-L69 | train |
RangerMauve/mqtt-regex | index.js | process_raw | function process_raw(token) {
var token = escapeRegex(token);
return {
type: "raw",
piece: token + "/",
last: token + "/?"
};
} | javascript | function process_raw(token) {
var token = escapeRegex(token);
return {
type: "raw",
piece: token + "/",
last: token + "/?"
};
} | [
"function",
"process_raw",
"(",
"token",
")",
"{",
"var",
"token",
"=",
"escapeRegex",
"(",
"token",
")",
";",
"return",
"{",
"type",
":",
"\"raw\"",
",",
"piece",
":",
"token",
"+",
"\"/\"",
",",
"last",
":",
"token",
"+",
"\"/?\"",
"}",
";",
"}"
] | Processes a raw string for the path, no special logic is expected | [
"Processes",
"a",
"raw",
"string",
"for",
"the",
"path",
"no",
"special",
"logic",
"is",
"expected"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L95-L102 | train |
RangerMauve/mqtt-regex | index.js | make_clean_topic | function make_clean_topic(tokens) {
return tokens.map(function (token) {
if (token.type === "raw") return token.piece.slice(0, -1);
else if (token.type === "single") return "+";
else if (token.type === "multi") return "#";
else return ""; // Wat
}).join("/");
} | javascript | function make_clean_topic(tokens) {
return tokens.map(function (token) {
if (token.type === "raw") return token.piece.slice(0, -1);
else if (token.type === "single") return "+";
else if (token.type === "multi") return "#";
else return ""; // Wat
}).join("/");
} | [
"function",
"make_clean_topic",
"(",
"tokens",
")",
"{",
"return",
"tokens",
".",
"map",
"(",
"function",
"(",
"token",
")",
"{",
"if",
"(",
"token",
".",
"type",
"===",
"\"raw\"",
")",
"return",
"token",
".",
"piece",
".",
"slice",
"(",
"0",
",",
"-... | Turn a topic pattern into a regular MQTT topic | [
"Turn",
"a",
"topic",
"pattern",
"into",
"a",
"regular",
"MQTT",
"topic"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L105-L112 | train |
RangerMauve/mqtt-regex | index.js | make_regex | function make_regex(tokens) {
var str = tokens.reduce(function (res, token, index) {
var is_last = (index == (tokens.length - 1));
var before_multi = (index === (tokens.length - 2)) && (last(tokens).type == "multi");
return res + ((is_last || before_multi) ? token.last : token.piece);
},
"");
return new ... | javascript | function make_regex(tokens) {
var str = tokens.reduce(function (res, token, index) {
var is_last = (index == (tokens.length - 1));
var before_multi = (index === (tokens.length - 2)) && (last(tokens).type == "multi");
return res + ((is_last || before_multi) ? token.last : token.piece);
},
"");
return new ... | [
"function",
"make_regex",
"(",
"tokens",
")",
"{",
"var",
"str",
"=",
"tokens",
".",
"reduce",
"(",
"function",
"(",
"res",
",",
"token",
",",
"index",
")",
"{",
"var",
"is_last",
"=",
"(",
"index",
"==",
"(",
"tokens",
".",
"length",
"-",
"1",
")"... | Generates the RegExp object from the tokens | [
"Generates",
"the",
"RegExp",
"object",
"from",
"the",
"tokens"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L115-L123 | train |
RangerMauve/mqtt-regex | index.js | make_pram_getter | function make_pram_getter(tokens) {
return function (results) {
// Get only the capturing tokens
var capture_tokens = remove_raw(tokens);
var res = {};
// If the regex didn't actually match, just return an empty object
if (!results) return res;
// Remove the first item and iterate through the capture gro... | javascript | function make_pram_getter(tokens) {
return function (results) {
// Get only the capturing tokens
var capture_tokens = remove_raw(tokens);
var res = {};
// If the regex didn't actually match, just return an empty object
if (!results) return res;
// Remove the first item and iterate through the capture gro... | [
"function",
"make_pram_getter",
"(",
"tokens",
")",
"{",
"return",
"function",
"(",
"results",
")",
"{",
"// Get only the capturing tokens",
"var",
"capture_tokens",
"=",
"remove_raw",
"(",
"tokens",
")",
";",
"var",
"res",
"=",
"{",
"}",
";",
"// If the regex d... | Generates the function for getting the params object from the regex results | [
"Generates",
"the",
"function",
"for",
"getting",
"the",
"params",
"object",
"from",
"the",
"regex",
"results"
] | a9e901df546763117f8d73f5add874bf91f9e995 | https://github.com/RangerMauve/mqtt-regex/blob/a9e901df546763117f8d73f5add874bf91f9e995/index.js#L126-L156 | train |
jmjuanes/electron-ejs | index.js | function () {
//Render the full file
return ejs.renderFile(file, data, options, function (error, content) {
if (error) {
self.emit("error", error);
return callback(-2);
... | javascript | function () {
//Render the full file
return ejs.renderFile(file, data, options, function (error, content) {
if (error) {
self.emit("error", error);
return callback(-2);
... | [
"function",
"(",
")",
"{",
"//Render the full file",
"return",
"ejs",
".",
"renderFile",
"(",
"file",
",",
"data",
",",
"options",
",",
"function",
"(",
"error",
",",
"content",
")",
"{",
"if",
"(",
"error",
")",
"{",
"self",
".",
"emit",
"(",
"\"error... | Render template function | [
"Render",
"template",
"function"
] | dc1ad4c5b43314f6e59edc63c34233930dc83401 | https://github.com/jmjuanes/electron-ejs/blob/dc1ad4c5b43314f6e59edc63c34233930dc83401/index.js#L57-L70 | train | |
jmjuanes/electron-ejs | index.js | ParsePath | function ParsePath(u) {
//Parse the url
let p = url.parse(u);
//Get the path name
let pname = p.pathname;
//Check for Windows
if( process.platform === "win32") {
//Remove the first / from the path
//https://github.com/jmjuanes/electron-ejs/pull/4#issuecomment-219254028
pn... | javascript | function ParsePath(u) {
//Parse the url
let p = url.parse(u);
//Get the path name
let pname = p.pathname;
//Check for Windows
if( process.platform === "win32") {
//Remove the first / from the path
//https://github.com/jmjuanes/electron-ejs/pull/4#issuecomment-219254028
pn... | [
"function",
"ParsePath",
"(",
"u",
")",
"{",
"//Parse the url",
"let",
"p",
"=",
"url",
".",
"parse",
"(",
"u",
")",
";",
"//Get the path name",
"let",
"pname",
"=",
"p",
".",
"pathname",
";",
"//Check for Windows",
"if",
"(",
"process",
".",
"platform",
... | Function to parse the path | [
"Function",
"to",
"parse",
"the",
"path"
] | dc1ad4c5b43314f6e59edc63c34233930dc83401 | https://github.com/jmjuanes/electron-ejs/blob/dc1ad4c5b43314f6e59edc63c34233930dc83401/index.js#L97-L113 | train |
BorisChumichev/everpolate | lib/linearRegression.js | linearRegression | function linearRegression(functionValuesX, functionValuesY){
var regression = {}
, x = functionValuesX
, y = functionValuesY
, n = y.length
, sum_x = 0
, sum_y = 0
, sum_xy = 0
, sum_xx = 0
, sum_yy = 0
for (var i = 0; i < y.length; i++) {
sum_x += x[i]
sum_y += y[i]
sum... | javascript | function linearRegression(functionValuesX, functionValuesY){
var regression = {}
, x = functionValuesX
, y = functionValuesY
, n = y.length
, sum_x = 0
, sum_y = 0
, sum_xy = 0
, sum_xx = 0
, sum_yy = 0
for (var i = 0; i < y.length; i++) {
sum_x += x[i]
sum_y += y[i]
sum... | [
"function",
"linearRegression",
"(",
"functionValuesX",
",",
"functionValuesY",
")",
"{",
"var",
"regression",
"=",
"{",
"}",
",",
"x",
"=",
"functionValuesX",
",",
"y",
"=",
"functionValuesY",
",",
"n",
"=",
"y",
".",
"length",
",",
"sum_x",
"=",
"0",
"... | Computes Linear Regression slope, intercept, r-squared and returns
a function which can be used for evaluating linear regression
at a particular x-value
@param functionValuesX {Array}
@param functionValuesY {Array}
@returns {Object} | [
"Computes",
"Linear",
"Regression",
"slope",
"intercept",
"r",
"-",
"squared",
"and",
"returns",
"a",
"function",
"which",
"can",
"be",
"used",
"for",
"evaluating",
"linear",
"regression",
"at",
"a",
"particular",
"x",
"-",
"value"
] | 00201c964891d37e8cfa6922057c5069db4a37d4 | https://github.com/BorisChumichev/everpolate/blob/00201c964891d37e8cfa6922057c5069db4a37d4/lib/linearRegression.js#L17-L50 | train |
Rob--W/proxy-from-env | index.js | shouldProxy | function shouldProxy(hostname, port) {
var NO_PROXY = getEnv('no_proxy').toLowerCase();
if (!NO_PROXY) {
return true; // Always proxy if NO_PROXY is not set.
}
if (NO_PROXY === '*') {
return false; // Never proxy if wildcard is set.
}
return NO_PROXY.split(/[,\s]/).every(function(proxy) {
if ... | javascript | function shouldProxy(hostname, port) {
var NO_PROXY = getEnv('no_proxy').toLowerCase();
if (!NO_PROXY) {
return true; // Always proxy if NO_PROXY is not set.
}
if (NO_PROXY === '*') {
return false; // Never proxy if wildcard is set.
}
return NO_PROXY.split(/[,\s]/).every(function(proxy) {
if ... | [
"function",
"shouldProxy",
"(",
"hostname",
",",
"port",
")",
"{",
"var",
"NO_PROXY",
"=",
"getEnv",
"(",
"'no_proxy'",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"NO_PROXY",
")",
"{",
"return",
"true",
";",
"// Always proxy if NO_PROXY is not s... | Determines whether a given URL should be proxied.
@param {string} hostname - The host name of the URL.
@param {number} port - The effective port of the URL.
@returns {boolean} Whether the given URL should be proxied.
@private | [
"Determines",
"whether",
"a",
"given",
"URL",
"should",
"be",
"proxied",
"."
] | e0d07a9350568b3a0c3bb28dafd3766206961a02 | https://github.com/Rob--W/proxy-from-env/blob/e0d07a9350568b3a0c3bb28dafd3766206961a02/index.js#L58-L90 | train |
Rob--W/proxy-from-env | index.js | getEnv | function getEnv(key) {
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
} | javascript | function getEnv(key) {
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
} | [
"function",
"getEnv",
"(",
"key",
")",
"{",
"return",
"process",
".",
"env",
"[",
"key",
".",
"toLowerCase",
"(",
")",
"]",
"||",
"process",
".",
"env",
"[",
"key",
".",
"toUpperCase",
"(",
")",
"]",
"||",
"''",
";",
"}"
] | Get the value for an environment variable.
@param {string} key - The name of the environment variable.
@return {string} The value of the environment variable.
@private | [
"Get",
"the",
"value",
"for",
"an",
"environment",
"variable",
"."
] | e0d07a9350568b3a0c3bb28dafd3766206961a02 | https://github.com/Rob--W/proxy-from-env/blob/e0d07a9350568b3a0c3bb28dafd3766206961a02/index.js#L99-L101 | train |
BorisChumichev/everpolate | lib/step.js | step | function step (pointsToEvaluate, functionValuesX, functionValuesY) {
return help.makeItArrayIfItsNot(pointsToEvaluate).map(function (point) {
return functionValuesY[help.findIntervalLeftBorderIndex(point, functionValuesX)]
})
} | javascript | function step (pointsToEvaluate, functionValuesX, functionValuesY) {
return help.makeItArrayIfItsNot(pointsToEvaluate).map(function (point) {
return functionValuesY[help.findIntervalLeftBorderIndex(point, functionValuesX)]
})
} | [
"function",
"step",
"(",
"pointsToEvaluate",
",",
"functionValuesX",
",",
"functionValuesY",
")",
"{",
"return",
"help",
".",
"makeItArrayIfItsNot",
"(",
"pointsToEvaluate",
")",
".",
"map",
"(",
"function",
"(",
"point",
")",
"{",
"return",
"functionValuesY",
"... | Evaluates interpolating step function at the set of numbers
or at a single number
@param {Number|Array} pointsToEvaluate number or set of numbers
for which step is calculated
@param {Array} functionValuesX set of distinct x values
@param {Array} functionValuesY set of distinct y=f(x) values... | [
"Evaluates",
"interpolating",
"step",
"function",
"at",
"the",
"set",
"of",
"numbers",
"or",
"at",
"a",
"single",
"number"
] | 00201c964891d37e8cfa6922057c5069db4a37d4 | https://github.com/BorisChumichev/everpolate/blob/00201c964891d37e8cfa6922057c5069db4a37d4/lib/step.js#L18-L22 | train |
umakantp/jsmart | src/parser/parser.js | function (template) {
var tree = this.getTree(template)
var runTimePlugins
// Copy so far runtime plugins were generated.
runTimePlugins = this.runTimePlugins
var blocks = this.blocks
var outerBlocks = this.outerBlocks
this.clear()
// Nope, we do not want to clear the... | javascript | function (template) {
var tree = this.getTree(template)
var runTimePlugins
// Copy so far runtime plugins were generated.
runTimePlugins = this.runTimePlugins
var blocks = this.blocks
var outerBlocks = this.outerBlocks
this.clear()
// Nope, we do not want to clear the... | [
"function",
"(",
"template",
")",
"{",
"var",
"tree",
"=",
"this",
".",
"getTree",
"(",
"template",
")",
"var",
"runTimePlugins",
"// Copy so far runtime plugins were generated.",
"runTimePlugins",
"=",
"this",
".",
"runTimePlugins",
"var",
"blocks",
"=",
"this",
... | Parse the template and return the data. | [
"Parse",
"the",
"template",
"and",
"return",
"the",
"data",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/src/parser/parser.js#L82-L103 | train | |
umakantp/jsmart | src/parser/parser.js | function (expressionClose, expressionOpen, s) {
var sInner = ''
var closeTag = null
var openTag = null
var findIndex = 0
do {
if (closeTag) {
findIndex += closeTag[0].length
}
closeTag = this.findTag(expressionClose, s)
if (!closeTag) {
... | javascript | function (expressionClose, expressionOpen, s) {
var sInner = ''
var closeTag = null
var openTag = null
var findIndex = 0
do {
if (closeTag) {
findIndex += closeTag[0].length
}
closeTag = this.findTag(expressionClose, s)
if (!closeTag) {
... | [
"function",
"(",
"expressionClose",
",",
"expressionOpen",
",",
"s",
")",
"{",
"var",
"sInner",
"=",
"''",
"var",
"closeTag",
"=",
"null",
"var",
"openTag",
"=",
"null",
"var",
"findIndex",
"=",
"0",
"do",
"{",
"if",
"(",
"closeTag",
")",
"{",
"findInd... | Find closing tag which matches. expressionClose. | [
"Find",
"closing",
"tag",
"which",
"matches",
".",
"expressionClose",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/src/parser/parser.js#L252-L277 | train | |
umakantp/jsmart | src/parser/parser.js | function (s) {
var tree = []
var value = ''
var data
// TODO Refactor, to get this removed.
this.lastTreeInExpression = tree
while (true) {
data = this.lookUp(s.slice(value.length), value)
if (data) {
tree = tree.concat(data.tree)
value = data.val... | javascript | function (s) {
var tree = []
var value = ''
var data
// TODO Refactor, to get this removed.
this.lastTreeInExpression = tree
while (true) {
data = this.lookUp(s.slice(value.length), value)
if (data) {
tree = tree.concat(data.tree)
value = data.val... | [
"function",
"(",
"s",
")",
"{",
"var",
"tree",
"=",
"[",
"]",
"var",
"value",
"=",
"''",
"var",
"data",
"// TODO Refactor, to get this removed.",
"this",
".",
"lastTreeInExpression",
"=",
"tree",
"while",
"(",
"true",
")",
"{",
"data",
"=",
"this",
".",
... | Parse expression. | [
"Parse",
"expression",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/src/parser/parser.js#L592-L617 | train | |
umakantp/jsmart | src/parser/parser.js | function (text) {
var tree = []
if (this.parseEmbeddedVars) {
var re = /([$][\w@]+)|`([^`]*)`/
for (var found = re.exec(text); found; found = re.exec(text)) {
tree.push({type: 'text', data: text.slice(0, found.index)})
var d = this.parseExpression(found[1] ? found[1] : f... | javascript | function (text) {
var tree = []
if (this.parseEmbeddedVars) {
var re = /([$][\w@]+)|`([^`]*)`/
for (var found = re.exec(text); found; found = re.exec(text)) {
tree.push({type: 'text', data: text.slice(0, found.index)})
var d = this.parseExpression(found[1] ? found[1] : f... | [
"function",
"(",
"text",
")",
"{",
"var",
"tree",
"=",
"[",
"]",
"if",
"(",
"this",
".",
"parseEmbeddedVars",
")",
"{",
"var",
"re",
"=",
"/",
"([$][\\w@]+)|`([^`]*)`",
"/",
"for",
"(",
"var",
"found",
"=",
"re",
".",
"exec",
"(",
"text",
")",
";",... | Parse text. | [
"Parse",
"text",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/src/parser/parser.js#L625-L639 | train | |
umakantp/jsmart | src/parser/parser.js | function (tpl) {
var ldelim = new RegExp(this.ldelim + '\\*')
var rdelim = new RegExp('\\*' + this.rdelim)
var newTpl = ''
for (var openTag = tpl.match(ldelim); openTag; openTag = tpl.match(ldelim)) {
newTpl += tpl.slice(0, openTag.index)
tpl = tpl.slice(openTag.index + openTag[... | javascript | function (tpl) {
var ldelim = new RegExp(this.ldelim + '\\*')
var rdelim = new RegExp('\\*' + this.rdelim)
var newTpl = ''
for (var openTag = tpl.match(ldelim); openTag; openTag = tpl.match(ldelim)) {
newTpl += tpl.slice(0, openTag.index)
tpl = tpl.slice(openTag.index + openTag[... | [
"function",
"(",
"tpl",
")",
"{",
"var",
"ldelim",
"=",
"new",
"RegExp",
"(",
"this",
".",
"ldelim",
"+",
"'\\\\*'",
")",
"var",
"rdelim",
"=",
"new",
"RegExp",
"(",
"'\\\\*'",
"+",
"this",
".",
"rdelim",
")",
"var",
"newTpl",
"=",
"''",
"for",
"("... | Remove comments. We do not want to parse them anyway. | [
"Remove",
"comments",
".",
"We",
"do",
"not",
"want",
"to",
"parse",
"them",
"anyway",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/src/parser/parser.js#L657-L672 | train | |
umakantp/jsmart | dist/jsmart.js | findInArray | function findInArray (arr, val) {
if (Array.prototype.indexOf) {
return arr.indexOf(val)
}
for (var i = 0; i < arr.length; ++i) {
if (arr[i] === val) {
return i
}
}
return -1
} | javascript | function findInArray (arr, val) {
if (Array.prototype.indexOf) {
return arr.indexOf(val)
}
for (var i = 0; i < arr.length; ++i) {
if (arr[i] === val) {
return i
}
}
return -1
} | [
"function",
"findInArray",
"(",
"arr",
",",
"val",
")",
"{",
"if",
"(",
"Array",
".",
"prototype",
".",
"indexOf",
")",
"{",
"return",
"arr",
".",
"indexOf",
"(",
"val",
")",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"le... | Find in array. | [
"Find",
"in",
"array",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L58-L68 | train |
umakantp/jsmart | dist/jsmart.js | function (tree, data) {
// Process the tree and get the output.
var output = this.process(tree, data)
if (this.debugging) {
this.plugins.debug.process([], {
includedTemplates: this.includedTemplates,
assignedVars: data
})
}
this.clear()
return {
... | javascript | function (tree, data) {
// Process the tree and get the output.
var output = this.process(tree, data)
if (this.debugging) {
this.plugins.debug.process([], {
includedTemplates: this.includedTemplates,
assignedVars: data
})
}
this.clear()
return {
... | [
"function",
"(",
"tree",
",",
"data",
")",
"{",
"// Process the tree and get the output.",
"var",
"output",
"=",
"this",
".",
"process",
"(",
"tree",
",",
"data",
")",
"if",
"(",
"this",
".",
"debugging",
")",
"{",
"this",
".",
"plugins",
".",
"debug",
"... | Process the tree and return the data. | [
"Process",
"the",
"tree",
"and",
"return",
"the",
"data",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L1504-L1519 | train | |
umakantp/jsmart | dist/jsmart.js | function (tree, data) {
var res = ''
var s
var node
var tmp
var plugin
for (var i = 0; i < tree.length; ++i) {
node = tree[i]
s = ''
if (node.type === 'text') {
s = node.data
} else if (node.type === 'var') {
s = this.getVarValue(... | javascript | function (tree, data) {
var res = ''
var s
var node
var tmp
var plugin
for (var i = 0; i < tree.length; ++i) {
node = tree[i]
s = ''
if (node.type === 'text') {
s = node.data
} else if (node.type === 'var') {
s = this.getVarValue(... | [
"function",
"(",
"tree",
",",
"data",
")",
"{",
"var",
"res",
"=",
"''",
"var",
"s",
"var",
"node",
"var",
"tmp",
"var",
"plugin",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tree",
".",
"length",
";",
"++",
"i",
")",
"{",
"node",
"=",
... | Process the tree and apply data. | [
"Process",
"the",
"tree",
"and",
"apply",
"data",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L1522-L1603 | train | |
umakantp/jsmart | dist/jsmart.js | function (template, options) {
var parsedTemplate
if (!options) {
options = {}
}
if (options.rdelim) {
// If delimiters are passed locally take them.
this.smarty.rdelim = options.rdelim
} else if (jSmart.prototype.right_delimiter) {
// Backward compatible. O... | javascript | function (template, options) {
var parsedTemplate
if (!options) {
options = {}
}
if (options.rdelim) {
// If delimiters are passed locally take them.
this.smarty.rdelim = options.rdelim
} else if (jSmart.prototype.right_delimiter) {
// Backward compatible. O... | [
"function",
"(",
"template",
",",
"options",
")",
"{",
"var",
"parsedTemplate",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
"}",
"if",
"(",
"options",
".",
"rdelim",
")",
"{",
"// If delimiters are passed locally take them.",
"this",
".",
... | Initialize, jSmart, set settings and parse the template. | [
"Initialize",
"jSmart",
"set",
"settings",
"and",
"parse",
"the",
"template",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L2485-L2553 | train | |
umakantp/jsmart | dist/jsmart.js | function (data) {
var outputData = ''
if (!(typeof data === 'object')) {
data = {}
}
// Define smarty inside data and copy smarty vars, so one can use $smarty
// vars inside templates.
data.smarty = {}
objectMerge(data.smarty, this.smarty)
// Take default global... | javascript | function (data) {
var outputData = ''
if (!(typeof data === 'object')) {
data = {}
}
// Define smarty inside data and copy smarty vars, so one can use $smarty
// vars inside templates.
data.smarty = {}
objectMerge(data.smarty, this.smarty)
// Take default global... | [
"function",
"(",
"data",
")",
"{",
"var",
"outputData",
"=",
"''",
"if",
"(",
"!",
"(",
"typeof",
"data",
"===",
"'object'",
")",
")",
"{",
"data",
"=",
"{",
"}",
"}",
"// Define smarty inside data and copy smarty vars, so one can use $smarty",
"// vars inside tem... | Process the generated tree. | [
"Process",
"the",
"generated",
"tree",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L2556-L2593 | train | |
umakantp/jsmart | dist/jsmart.js | function (toPrint, indent, indentEnd) {
if (!indent) {
indent = ' '
}
if (!indentEnd) {
indentEnd = ''
}
var s = ''
var name
if (toPrint instanceof Object) {
s = 'Object (\n'
for (name in toPrint) {
if (toPrint.hasOwnProperty... | javascript | function (toPrint, indent, indentEnd) {
if (!indent) {
indent = ' '
}
if (!indentEnd) {
indentEnd = ''
}
var s = ''
var name
if (toPrint instanceof Object) {
s = 'Object (\n'
for (name in toPrint) {
if (toPrint.hasOwnProperty... | [
"function",
"(",
"toPrint",
",",
"indent",
",",
"indentEnd",
")",
"{",
"if",
"(",
"!",
"indent",
")",
"{",
"indent",
"=",
"' '",
"}",
"if",
"(",
"!",
"indentEnd",
")",
"{",
"indentEnd",
"=",
"''",
"}",
"var",
"s",
"=",
"''",
"var",
"name... | Print the object. | [
"Print",
"the",
"object",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L2604-L2640 | train | |
umakantp/jsmart | dist/jsmart.js | function (type, name, callback) {
if (type === 'modifier') {
this.modifiers[name] = callback
} else {
this.plugins[name] = {'type': type, 'process': callback}
}
} | javascript | function (type, name, callback) {
if (type === 'modifier') {
this.modifiers[name] = callback
} else {
this.plugins[name] = {'type': type, 'process': callback}
}
} | [
"function",
"(",
"type",
",",
"name",
",",
"callback",
")",
"{",
"if",
"(",
"type",
"===",
"'modifier'",
")",
"{",
"this",
".",
"modifiers",
"[",
"name",
"]",
"=",
"callback",
"}",
"else",
"{",
"this",
".",
"plugins",
"[",
"name",
"]",
"=",
"{",
... | Register a plugin. | [
"Register",
"a",
"plugin",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L2643-L2649 | train | |
umakantp/jsmart | dist/jsmart.js | function (type, callback) {
(this.tree ? this.filters : jSmart.prototype.filtersGlobal)[((type === 'output') ? 'post' : type)].push(callback)
} | javascript | function (type, callback) {
(this.tree ? this.filters : jSmart.prototype.filtersGlobal)[((type === 'output') ? 'post' : type)].push(callback)
} | [
"function",
"(",
"type",
",",
"callback",
")",
"{",
"(",
"this",
".",
"tree",
"?",
"this",
".",
"filters",
":",
"jSmart",
".",
"prototype",
".",
"filtersGlobal",
")",
"[",
"(",
"(",
"type",
"===",
"'output'",
")",
"?",
"'post'",
":",
"type",
")",
"... | Register a filter. | [
"Register",
"a",
"filter",
"."
] | 6168e50baa0b4a81605bbcd907108d4bf921b0a7 | https://github.com/umakantp/jsmart/blob/6168e50baa0b4a81605bbcd907108d4bf921b0a7/dist/jsmart.js#L2652-L2654 | train | |
kupriyanenko/jbone | dist/jbone.js | function(el, types, handler, data, selector) {
jBone.setId(el);
var eventHandler = function(e) {
jBone.event.dispatch.call(el, e);
},
events = jBone.getData(el).events,
eventType, t, event;
types = types.split(" ");
t = types.length;
... | javascript | function(el, types, handler, data, selector) {
jBone.setId(el);
var eventHandler = function(e) {
jBone.event.dispatch.call(el, e);
},
events = jBone.getData(el).events,
eventType, t, event;
types = types.split(" ");
t = types.length;
... | [
"function",
"(",
"el",
",",
"types",
",",
"handler",
",",
"data",
",",
"selector",
")",
"{",
"jBone",
".",
"setId",
"(",
"el",
")",
";",
"var",
"eventHandler",
"=",
"function",
"(",
"e",
")",
"{",
"jBone",
".",
"event",
".",
"dispatch",
".",
"call"... | Attach a handler to an event for the elements
@param {Node} el - Events will be attached to this DOM Node
@param {String} types - One or more space-separated event types and optional namespaces
@param {Function} handler - A function to execute when the event is triggered
@param {Object} ... | [
"Attach",
"a",
"handler",
"to",
"an",
"event",
"for",
"the",
"elements"
] | 80b99258ef0fcd23f9d7451fbe4d87e73ded94f1 | https://github.com/kupriyanenko/jbone/blob/80b99258ef0fcd23f9d7451fbe4d87e73ded94f1/dist/jbone.js#L336-L368 | train | |
kupriyanenko/jbone | dist/jbone.js | function(el, types, handler, selector) {
var removeListener = function(events, eventType, index, el, e) {
var callback;
// get callback
if ((handler && e.originfn === handler) || !handler) {
callback = e.fn;
}
... | javascript | function(el, types, handler, selector) {
var removeListener = function(events, eventType, index, el, e) {
var callback;
// get callback
if ((handler && e.originfn === handler) || !handler) {
callback = e.fn;
}
... | [
"function",
"(",
"el",
",",
"types",
",",
"handler",
",",
"selector",
")",
"{",
"var",
"removeListener",
"=",
"function",
"(",
"events",
",",
"eventType",
",",
"index",
",",
"el",
",",
"e",
")",
"{",
"var",
"callback",
";",
"// get callback",
"if",
"("... | Remove an event handler
@param {Node} el - Events will be deattached from this DOM Node
@param {String} types - One or more space-separated event types and optional namespaces
@param {Function} handler - A handler function previously attached for the event(s)
@param {String} [selector] ... | [
"Remove",
"an",
"event",
"handler"
] | 80b99258ef0fcd23f9d7451fbe4d87e73ded94f1 | https://github.com/kupriyanenko/jbone/blob/80b99258ef0fcd23f9d7451fbe4d87e73ded94f1/dist/jbone.js#L377-L448 | train | |
kupriyanenko/jbone | dist/jbone.js | function(el, event) {
var events = [];
if (isString(event)) {
events = event.split(" ").map(function(event) {
return jBone.Event(event);
});
} else {
event = event instanceof Event ? event : jBone.Event(event);
events = [event];
... | javascript | function(el, event) {
var events = [];
if (isString(event)) {
events = event.split(" ").map(function(event) {
return jBone.Event(event);
});
} else {
event = event instanceof Event ? event : jBone.Event(event);
events = [event];
... | [
"function",
"(",
"el",
",",
"event",
")",
"{",
"var",
"events",
"=",
"[",
"]",
";",
"if",
"(",
"isString",
"(",
"event",
")",
")",
"{",
"events",
"=",
"event",
".",
"split",
"(",
"\" \"",
")",
".",
"map",
"(",
"function",
"(",
"event",
")",
"{"... | Execute all handlers and behaviors attached to the matched elements for the given event type.
@param {Node} el - Events will be triggered for thie DOM Node
@param {String} event - One or more space-separated event types and optional namespaces | [
"Execute",
"all",
"handlers",
"and",
"behaviors",
"attached",
"to",
"the",
"matched",
"elements",
"for",
"the",
"given",
"event",
"type",
"."
] | 80b99258ef0fcd23f9d7451fbe4d87e73ded94f1 | https://github.com/kupriyanenko/jbone/blob/80b99258ef0fcd23f9d7451fbe4d87e73ded94f1/dist/jbone.js#L455-L474 | train | |
bhoriuchi/readline-promise | lib/index.js | each | function each(cfg) {
return function(callback) {
return new Promise(function(resolve, reject) {
// create an array to store callbacks
var rl, cbs = [];
// create an interface
try {
rl = readline.createInterface(cfg);
}
catch(err) {
return reject(err);
}
// handle a new line
... | javascript | function each(cfg) {
return function(callback) {
return new Promise(function(resolve, reject) {
// create an array to store callbacks
var rl, cbs = [];
// create an interface
try {
rl = readline.createInterface(cfg);
}
catch(err) {
return reject(err);
}
// handle a new line
... | [
"function",
"each",
"(",
"cfg",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// create an array to store callbacks",
"var",
"rl",
",",
"cbs",
"=",
"[",
"]"... | calls the callback on each line then resolves the callbacks if they are promises | [
"calls",
"the",
"callback",
"on",
"each",
"line",
"then",
"resolves",
"the",
"callbacks",
"if",
"they",
"are",
"promises"
] | 9bb8d1d80a9f0fca91bf99c16b57e281fc424d4a | https://github.com/bhoriuchi/readline-promise/blob/9bb8d1d80a9f0fca91bf99c16b57e281fc424d4a/lib/index.js#L12-L45 | train |
kriskowal/q-connection | q-connection.js | function (message) {
// forward the message to the local promise,
// which will return a response promise
var local = getLocal(message.to).promise;
var response = local.dispatch(message.op, decode(message.args));
var envelope;
// connect the loca... | javascript | function (message) {
// forward the message to the local promise,
// which will return a response promise
var local = getLocal(message.to).promise;
var response = local.dispatch(message.op, decode(message.args));
var envelope;
// connect the loca... | [
"function",
"(",
"message",
")",
"{",
"// forward the message to the local promise,",
"// which will return a response promise",
"var",
"local",
"=",
"getLocal",
"(",
"message",
".",
"to",
")",
".",
"promise",
";",
"var",
"response",
"=",
"local",
".",
"dispatch",
"... | a "send" message forwards messages from a remote promise to a local promise. | [
"a",
"send",
"message",
"forwards",
"messages",
"from",
"a",
"remote",
"promise",
"to",
"a",
"local",
"promise",
"."
] | 85fad079361a1a755004ebec08e7b5fc3455a36c | https://github.com/kriskowal/q-connection/blob/85fad079361a1a755004ebec08e7b5fc3455a36c/q-connection.js#L100-L169 | train | |
kriskowal/q-connection | q-connection.js | makeLocal | function makeLocal(id) {
if (hasLocal(id)) {
return getLocal(id).promise;
} else {
var deferred = Q.defer();
locals.set(id, deferred);
return deferred.promise;
}
} | javascript | function makeLocal(id) {
if (hasLocal(id)) {
return getLocal(id).promise;
} else {
var deferred = Q.defer();
locals.set(id, deferred);
return deferred.promise;
}
} | [
"function",
"makeLocal",
"(",
"id",
")",
"{",
"if",
"(",
"hasLocal",
"(",
"id",
")",
")",
"{",
"return",
"getLocal",
"(",
"id",
")",
".",
"promise",
";",
"}",
"else",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"locals",
".",
... | construct a local promise, such that it can be resolved later by a remote message | [
"construct",
"a",
"local",
"promise",
"such",
"that",
"it",
"can",
"be",
"resolved",
"later",
"by",
"a",
"remote",
"message"
] | 85fad079361a1a755004ebec08e7b5fc3455a36c | https://github.com/kriskowal/q-connection/blob/85fad079361a1a755004ebec08e7b5fc3455a36c/q-connection.js#L182-L190 | train |
kriskowal/q-connection | q-connection.js | makeRemote | function makeRemote(id) {
var remotePromise = Q.makePromise({
when: function () {
return this;
}
}, function (op, args) {
var localId = makeId();
var response = makeLocal(localId);
_debug("sending:", "R" + JSON.stringify(id), JS... | javascript | function makeRemote(id) {
var remotePromise = Q.makePromise({
when: function () {
return this;
}
}, function (op, args) {
var localId = makeId();
var response = makeLocal(localId);
_debug("sending:", "R" + JSON.stringify(id), JS... | [
"function",
"makeRemote",
"(",
"id",
")",
"{",
"var",
"remotePromise",
"=",
"Q",
".",
"makePromise",
"(",
"{",
"when",
":",
"function",
"(",
")",
"{",
"return",
"this",
";",
"}",
"}",
",",
"function",
"(",
"op",
",",
"args",
")",
"{",
"var",
"local... | makes a promise that will send all of its events to a remote object. | [
"makes",
"a",
"promise",
"that",
"will",
"send",
"all",
"of",
"its",
"events",
"to",
"a",
"remote",
"object",
"."
] | 85fad079361a1a755004ebec08e7b5fc3455a36c | https://github.com/kriskowal/q-connection/blob/85fad079361a1a755004ebec08e7b5fc3455a36c/q-connection.js#L201-L221 | train |
dwyl/hapi-auth-google | lib/index.js | create_oauth2_client | function create_oauth2_client () {
var google_client_id = (OPTIONS.GOOGLE_CLIENT_ID) ? OPTIONS.GOOGLE_CLIENT_ID : process.env.GOOGLE_CLIENT_ID;
var google_client_secret = (OPTIONS.GOOGLE_CLIENT_SECRET) ? OPTIONS.GOOGLE_CLIENT_SECRET : process.env.GOOGLE_CLIENT_SECRET;
var base_url = (OPTIONS.BASE_URL) ? OPTIONS.B... | javascript | function create_oauth2_client () {
var google_client_id = (OPTIONS.GOOGLE_CLIENT_ID) ? OPTIONS.GOOGLE_CLIENT_ID : process.env.GOOGLE_CLIENT_ID;
var google_client_secret = (OPTIONS.GOOGLE_CLIENT_SECRET) ? OPTIONS.GOOGLE_CLIENT_SECRET : process.env.GOOGLE_CLIENT_SECRET;
var base_url = (OPTIONS.BASE_URL) ? OPTIONS.B... | [
"function",
"create_oauth2_client",
"(",
")",
"{",
"var",
"google_client_id",
"=",
"(",
"OPTIONS",
".",
"GOOGLE_CLIENT_ID",
")",
"?",
"OPTIONS",
".",
"GOOGLE_CLIENT_ID",
":",
"process",
".",
"env",
".",
"GOOGLE_CLIENT_ID",
";",
"var",
"google_client_secret",
"=",
... | create_oauth2_client creates the OAuth2 client
@param {Object} options - the options passed into the plugin
@returns {Object} oauth2_client - the Google OAuth2 client | [
"create_oauth2_client",
"creates",
"the",
"OAuth2",
"client"
] | 9499d49fabd673594719ae5919103a112f9eaed1 | https://github.com/dwyl/hapi-auth-google/blob/9499d49fabd673594719ae5919103a112f9eaed1/lib/index.js#L12-L22 | train |
dwyl/hapi-auth-google | lib/index.js | generate_google_oauth2_url | function generate_google_oauth2_url () {
var access_type = (OPTIONS.access_type) ? OPTIONS.access_type : 'offline';
var approval_prompt = (OPTIONS.approval_prompt) ? OPTIONS.approval_prompt : 'force';
var url = oauth2_client.generateAuthUrl({
access_type: access_type, // set to offline to force a refresh toke... | javascript | function generate_google_oauth2_url () {
var access_type = (OPTIONS.access_type) ? OPTIONS.access_type : 'offline';
var approval_prompt = (OPTIONS.approval_prompt) ? OPTIONS.approval_prompt : 'force';
var url = oauth2_client.generateAuthUrl({
access_type: access_type, // set to offline to force a refresh toke... | [
"function",
"generate_google_oauth2_url",
"(",
")",
"{",
"var",
"access_type",
"=",
"(",
"OPTIONS",
".",
"access_type",
")",
"?",
"OPTIONS",
".",
"access_type",
":",
"'offline'",
";",
"var",
"approval_prompt",
"=",
"(",
"OPTIONS",
".",
"approval_prompt",
")",
... | getGoogleAuthURL creates a url where the user is sent to authenticate
no param
@returns {String} url - the url where people visit to authenticate | [
"getGoogleAuthURL",
"creates",
"a",
"url",
"where",
"the",
"user",
"is",
"sent",
"to",
"authenticate",
"no",
"param"
] | 9499d49fabd673594719ae5919103a112f9eaed1 | https://github.com/dwyl/hapi-auth-google/blob/9499d49fabd673594719ae5919103a112f9eaed1/lib/index.js#L30-L39 | train |
emmetio/atom-plugin | lib/actions/balance.js | selectionRangesForHTMLNode | function selectionRangesForHTMLNode(node) {
const ranges = [new Range(node.start, node.end)];
if (node.close) {
ranges.push(new Range(node.open.end, node.close.start));
}
return ranges;
} | javascript | function selectionRangesForHTMLNode(node) {
const ranges = [new Range(node.start, node.end)];
if (node.close) {
ranges.push(new Range(node.open.end, node.close.start));
}
return ranges;
} | [
"function",
"selectionRangesForHTMLNode",
"(",
"node",
")",
"{",
"const",
"ranges",
"=",
"[",
"new",
"Range",
"(",
"node",
".",
"start",
",",
"node",
".",
"end",
")",
"]",
";",
"if",
"(",
"node",
".",
"close",
")",
"{",
"ranges",
".",
"push",
"(",
... | Returns possible selection ranges for given HTML node, from outer to inner
@param {Node} node
@return {Range[]} | [
"Returns",
"possible",
"selection",
"ranges",
"for",
"given",
"HTML",
"node",
"from",
"outer",
"to",
"inner"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/balance.js#L84-L91 | train |
emmetio/atom-plugin | lib/actions/balance.js | selectionRangesForCSSNode | function selectionRangesForCSSNode(node) {
const ranges = [new Range(node.start, node.end)];
if (node.type === 'property' && node.valueToken) {
ranges.push(new Range(node.valueToken.start, node.valueToken.end));
} else if (node.type === 'rule' || node.type === 'at-rule') {
ranges.push(new Range(node.contentStar... | javascript | function selectionRangesForCSSNode(node) {
const ranges = [new Range(node.start, node.end)];
if (node.type === 'property' && node.valueToken) {
ranges.push(new Range(node.valueToken.start, node.valueToken.end));
} else if (node.type === 'rule' || node.type === 'at-rule') {
ranges.push(new Range(node.contentStar... | [
"function",
"selectionRangesForCSSNode",
"(",
"node",
")",
"{",
"const",
"ranges",
"=",
"[",
"new",
"Range",
"(",
"node",
".",
"start",
",",
"node",
".",
"end",
")",
"]",
";",
"if",
"(",
"node",
".",
"type",
"===",
"'property'",
"&&",
"node",
".",
"v... | Returns possible selection ranges for given CSS node, from outer to inner
@param {Node} node
@return {Range[]} | [
"Returns",
"possible",
"selection",
"ranges",
"for",
"given",
"CSS",
"node",
"from",
"outer",
"to",
"inner"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/balance.js#L98-L108 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | delegateDynamicValidation | function delegateDynamicValidation() {
if (!options.dynamic.settings.trigger) {
return false;
}
// {debug}
options.debug && window.Debug.log({
'node': node,
'function': 'delegateDynamicValidation()',
'messa... | javascript | function delegateDynamicValidation() {
if (!options.dynamic.settings.trigger) {
return false;
}
// {debug}
options.debug && window.Debug.log({
'node': node,
'function': 'delegateDynamicValidation()',
'messa... | [
"function",
"delegateDynamicValidation",
"(",
")",
"{",
"if",
"(",
"!",
"options",
".",
"dynamic",
".",
"settings",
".",
"trigger",
")",
"{",
"return",
"false",
";",
"}",
"// {debug}",
"options",
".",
"debug",
"&&",
"window",
".",
"Debug",
".",
"log",
"(... | Delegates the dynamic validation on data-validation and data-validation-regex attributes based on trigger.
@returns {Boolean} false if the option is not set | [
"Delegates",
"the",
"dynamic",
"validation",
"on",
"data",
"-",
"validation",
"and",
"data",
"-",
"validation",
"-",
"regex",
"attributes",
"based",
"on",
"trigger",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L321-L389 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | validateForm | function validateForm() {
var isValid = isEmpty(errors);
formData = {};
$.each(
node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
function(index, input) {
input = $(input);
var valu... | javascript | function validateForm() {
var isValid = isEmpty(errors);
formData = {};
$.each(
node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
function(index, input) {
input = $(input);
var valu... | [
"function",
"validateForm",
"(",
")",
"{",
"var",
"isValid",
"=",
"isEmpty",
"(",
"errors",
")",
";",
"formData",
"=",
"{",
"}",
";",
"$",
".",
"each",
"(",
"node",
".",
"find",
"(",
"'input:not([type=\"submit\"]), select, textarea'",
")",
".",
"not",
"(",... | For every "data-validation" & "data-pattern" attributes that are not disabled inside the jQuery "node" object
the "validateInput" function will be called.
@returns {Boolean} true if no error(s) were found (valid form) | [
"For",
"every",
"data",
"-",
"validation",
"&",
"data",
"-",
"pattern",
"attributes",
"that",
"are",
"not",
"disabled",
"inside",
"the",
"jQuery",
"node",
"object",
"the",
"validateInput",
"function",
"will",
"be",
"called",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L470-L509 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | prepareFormData | function prepareFormData() {
var data = {},
matches,
index;
for (var i in formData) {
if (!formData.hasOwnProperty(i)) continue;
index = 0;
matches = i.split(/\[(.+?)]/g);
var tmpObject = {},
... | javascript | function prepareFormData() {
var data = {},
matches,
index;
for (var i in formData) {
if (!formData.hasOwnProperty(i)) continue;
index = 0;
matches = i.split(/\[(.+?)]/g);
var tmpObject = {},
... | [
"function",
"prepareFormData",
"(",
")",
"{",
"var",
"data",
"=",
"{",
"}",
",",
"matches",
",",
"index",
";",
"for",
"(",
"var",
"i",
"in",
"formData",
")",
"{",
"if",
"(",
"!",
"formData",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"continue",
";... | Loop through formData and build an object
@returns {Object} data | [
"Loop",
"through",
"formData",
"and",
"build",
"an",
"object"
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L516-L553 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | validateInput | function validateInput(input, value) {
var inputName = $(input).attr('name'),
value = value || _getInputValue(input);
if (!inputName) {
// {debug}
options.debug && window.Debug.log({
'node': node,
'functio... | javascript | function validateInput(input, value) {
var inputName = $(input).attr('name'),
value = value || _getInputValue(input);
if (!inputName) {
// {debug}
options.debug && window.Debug.log({
'node': node,
'functio... | [
"function",
"validateInput",
"(",
"input",
",",
"value",
")",
"{",
"var",
"inputName",
"=",
"$",
"(",
"input",
")",
".",
"attr",
"(",
"'name'",
")",
",",
"value",
"=",
"value",
"||",
"_getInputValue",
"(",
"input",
")",
";",
"if",
"(",
"!",
"inputNam... | Prepare the information from the data attributes
and call the "validateRule" function.
@param {Object} input Reference of the input element
@returns {Boolean} true if no error(s) were found (valid input) | [
"Prepare",
"the",
"information",
"from",
"the",
"data",
"attributes",
"and",
"call",
"the",
"validateRule",
"function",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L563-L660 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | validateRule | function validateRule(value, rule, reversed) {
// Validate for "data-validation-regex" and "data-validation-regex-reverse"
if (rule instanceof RegExp) {
var isValid = rule.test(value);
if (reversed) {
isValid = !isValid;
}
... | javascript | function validateRule(value, rule, reversed) {
// Validate for "data-validation-regex" and "data-validation-regex-reverse"
if (rule instanceof RegExp) {
var isValid = rule.test(value);
if (reversed) {
isValid = !isValid;
}
... | [
"function",
"validateRule",
"(",
"value",
",",
"rule",
",",
"reversed",
")",
"{",
"// Validate for \"data-validation-regex\" and \"data-validation-regex-reverse\"",
"if",
"(",
"rule",
"instanceof",
"RegExp",
")",
"{",
"var",
"isValid",
"=",
"rule",
".",
"test",
"(",
... | Validate an input value against one rule.
If a "value-rule" mismatch occurs, an error is thrown to the caller function.
@param {String} value
@param {*} rule
@param {Boolean} [reversed]
@returns {*} Error if a mismatch occurred. | [
"Validate",
"an",
"input",
"value",
"against",
"one",
"rule",
".",
"If",
"a",
"value",
"-",
"rule",
"mismatch",
"occurs",
"an",
"error",
"is",
"thrown",
"to",
"the",
"caller",
"function",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L672-L783 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | registerError | function registerError(inputName, error) {
if (!errors[inputName]) {
errors[inputName] = [];
}
error = error.capitalize();
var hasError = false;
for (var i = 0; i < errors[inputName].length; i++) {
if (errors[inputName][i] ==... | javascript | function registerError(inputName, error) {
if (!errors[inputName]) {
errors[inputName] = [];
}
error = error.capitalize();
var hasError = false;
for (var i = 0; i < errors[inputName].length; i++) {
if (errors[inputName][i] ==... | [
"function",
"registerError",
"(",
"inputName",
",",
"error",
")",
"{",
"if",
"(",
"!",
"errors",
"[",
"inputName",
"]",
")",
"{",
"errors",
"[",
"inputName",
"]",
"=",
"[",
"]",
";",
"}",
"error",
"=",
"error",
".",
"capitalize",
"(",
")",
";",
"va... | Register an error into the global "error" variable.
@param {String} inputName Input where the error occurred
@param {String} error Description of the error to be displayed | [
"Register",
"an",
"error",
"into",
"the",
"global",
"error",
"variable",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L791-L811 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | resetOneError | function resetOneError(inputName, input, label, container, group) {
delete errors[inputName];
if (container) {
//window.Validation.hasScrolled = false;
if (options.submit.settings.inputContainer) {
(group ? label : input).parentsUntil(node,... | javascript | function resetOneError(inputName, input, label, container, group) {
delete errors[inputName];
if (container) {
//window.Validation.hasScrolled = false;
if (options.submit.settings.inputContainer) {
(group ? label : input).parentsUntil(node,... | [
"function",
"resetOneError",
"(",
"inputName",
",",
"input",
",",
"label",
",",
"container",
",",
"group",
")",
"{",
"delete",
"errors",
"[",
"inputName",
"]",
";",
"if",
"(",
"container",
")",
"{",
"//window.Validation.hasScrolled = false;",
"if",
"(",
"optio... | Remove an input error.
@param {String} inputName Key reference to delete the error from "errors" global variable
@param {Object} input jQuery object of the input
@param {Object} label jQuery object of the input's label
@param {Object} container jQuery object of the "errorList"
@param {String} [group] Name of the group... | [
"Remove",
"an",
"input",
"error",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L998-L1041 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | destroy | function destroy() {
resetErrors();
node.find('[' + _data.validation + '],[' + _data.regex + ']').off(delegateSuffix + ' ' + resetSuffix);
node.find(options.submit.settings.button).off(delegateSuffix).on('click' + delegateSuffix, function () {
$(this).closest('form'... | javascript | function destroy() {
resetErrors();
node.find('[' + _data.validation + '],[' + _data.regex + ']').off(delegateSuffix + ' ' + resetSuffix);
node.find(options.submit.settings.button).off(delegateSuffix).on('click' + delegateSuffix, function () {
$(this).closest('form'... | [
"function",
"destroy",
"(",
")",
"{",
"resetErrors",
"(",
")",
";",
"node",
".",
"find",
"(",
"'['",
"+",
"_data",
".",
"validation",
"+",
"'],['",
"+",
"_data",
".",
"regex",
"+",
"']'",
")",
".",
"off",
"(",
"delegateSuffix",
"+",
"' '",
"+",
"re... | Destroy the Validation instance
@returns {Boolean} | [
"Destroy",
"the",
"Validation",
"instance"
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L1073-L1086 | train |
running-coder/jquery-form-validation | src/jquery.validation.js | function (node, validation) {
var self = this;
validation = self._splitValidation(validation);
if (!validation) {
return false;
}
return node.each(function () {
var $this = $(this),
validationData = $this... | javascript | function (node, validation) {
var self = this;
validation = self._splitValidation(validation);
if (!validation) {
return false;
}
return node.each(function () {
var $this = $(this),
validationData = $this... | [
"function",
"(",
"node",
",",
"validation",
")",
"{",
"var",
"self",
"=",
"this",
";",
"validation",
"=",
"self",
".",
"_splitValidation",
"(",
"validation",
")",
";",
"if",
"(",
"!",
"validation",
")",
"{",
"return",
"false",
";",
"}",
"return",
"node... | API method to handle the removal of "data-validation" arguments.
@param {Object} node jQuery objects
@param {String|Array} validation arguments to remove in the node(s) "data-validation"
@returns {*} | [
"API",
"method",
"to",
"handle",
"the",
"removal",
"of",
"data",
"-",
"validation",
"arguments",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L1598-L1638 | train | |
running-coder/jquery-form-validation | src/jquery.validation.js | function (ruleObj) {
if (!ruleObj.rule || (!ruleObj.regex && !ruleObj.message)) {
// {debug}
window.Debug.log({
'function': '$.alterValidationRules()',
'message': 'ERROR - Missing one or multiple parameter(s) {rule, regex, message}'
... | javascript | function (ruleObj) {
if (!ruleObj.rule || (!ruleObj.regex && !ruleObj.message)) {
// {debug}
window.Debug.log({
'function': '$.alterValidationRules()',
'message': 'ERROR - Missing one or multiple parameter(s) {rule, regex, message}'
... | [
"function",
"(",
"ruleObj",
")",
"{",
"if",
"(",
"!",
"ruleObj",
".",
"rule",
"||",
"(",
"!",
"ruleObj",
".",
"regex",
"&&",
"!",
"ruleObj",
".",
"message",
")",
")",
"{",
"// {debug}",
"window",
".",
"Debug",
".",
"log",
"(",
"{",
"'function'",
":... | API method to add a validation rule.
@example
$.alterValidationRules({
rule: 'FILENAME',
regex: /^[^\\/:\*\?<>\|\"\']*$/,
message: '$ has an invalid filename.'
})
@param {Object} ruleObj | [
"API",
"method",
"to",
"add",
"a",
"validation",
"rule",
"."
] | 196540a32e6dea66f2c1c2baea078931369c26cd | https://github.com/running-coder/jquery-form-validation/blob/196540a32e6dea66f2c1c2baea078931369c26cd/src/jquery.validation.js#L1852-L1891 | train | |
emmetio/atom-plugin | lib/actions/remove-tag.js | findNextNonSpacePoint | function findNextNonSpacePoint(editor, pos) {
const stream = new BufferStreamReader(editor.getBuffer(), pos);
stream.eatWhile(isSpace);
return stream.pos;
} | javascript | function findNextNonSpacePoint(editor, pos) {
const stream = new BufferStreamReader(editor.getBuffer(), pos);
stream.eatWhile(isSpace);
return stream.pos;
} | [
"function",
"findNextNonSpacePoint",
"(",
"editor",
",",
"pos",
")",
"{",
"const",
"stream",
"=",
"new",
"BufferStreamReader",
"(",
"editor",
".",
"getBuffer",
"(",
")",
",",
"pos",
")",
";",
"stream",
".",
"eatWhile",
"(",
"isSpace",
")",
";",
"return",
... | Finds position of first non-space character next to given `pos`
@param {TextEditor} editor
@param {Point} pos
@return {Point} | [
"Finds",
"position",
"of",
"first",
"non",
"-",
"space",
"character",
"next",
"to",
"given",
"pos"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/remove-tag.js#L67-L71 | train |
emmetio/atom-plugin | lib/actions/remove-tag.js | findPreviousNonSpacePoint | function findPreviousNonSpacePoint(editor, pos) {
const stream = new BufferStreamReader(editor.getBuffer(), pos);
while (!stream.sof()) {
if (!isSpace(stream.backUp(1))) {
stream.next();
break;
}
}
return stream.pos;
} | javascript | function findPreviousNonSpacePoint(editor, pos) {
const stream = new BufferStreamReader(editor.getBuffer(), pos);
while (!stream.sof()) {
if (!isSpace(stream.backUp(1))) {
stream.next();
break;
}
}
return stream.pos;
} | [
"function",
"findPreviousNonSpacePoint",
"(",
"editor",
",",
"pos",
")",
"{",
"const",
"stream",
"=",
"new",
"BufferStreamReader",
"(",
"editor",
".",
"getBuffer",
"(",
")",
",",
"pos",
")",
";",
"while",
"(",
"!",
"stream",
".",
"sof",
"(",
")",
")",
... | Finds position of first non-space character that precedes given `pos`
@param {TextEditor} editor
@param {Point} pos
@return {Point} | [
"Finds",
"position",
"of",
"first",
"non",
"-",
"space",
"character",
"that",
"precedes",
"given",
"pos"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/remove-tag.js#L79-L89 | train |
emmetio/atom-plugin | lib/actions/split-join-tag.js | joinTag | function joinTag(editor, node, syntax) {
// Remove everything between the end of opening tag and the end of closing tag
const open = getText(editor, node.open);
const m = open.match(/\s*>$/);
const start = node.open.end.translate([0, m ? -m[0].length : 0]);
editor.setTextInBufferRange(new Range(start, node.end),
... | javascript | function joinTag(editor, node, syntax) {
// Remove everything between the end of opening tag and the end of closing tag
const open = getText(editor, node.open);
const m = open.match(/\s*>$/);
const start = node.open.end.translate([0, m ? -m[0].length : 0]);
editor.setTextInBufferRange(new Range(start, node.end),
... | [
"function",
"joinTag",
"(",
"editor",
",",
"node",
",",
"syntax",
")",
"{",
"// Remove everything between the end of opening tag and the end of closing tag",
"const",
"open",
"=",
"getText",
"(",
"editor",
",",
"node",
".",
"open",
")",
";",
"const",
"m",
"=",
"op... | Joins given tag into single, unary tag
@param {TextEditor} editor
@param {Node} node
@param {String} syntax Host document syntax, defines how self-closing tag
should be displayed | [
"Joins",
"given",
"tag",
"into",
"single",
"unary",
"tag"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/split-join-tag.js#L65-L72 | train |
emmetio/atom-plugin | lib/actions/toggle-block-comment.js | comment | function comment(editor, range, modelType) {
const commentParts = modelComments[modelType];
editor.setTextInBufferRange(new Range(range.end, range.end), ` ${commentParts.after}`);
editor.setTextInBufferRange(new Range(range.start, range.start), `${commentParts.before} `);
} | javascript | function comment(editor, range, modelType) {
const commentParts = modelComments[modelType];
editor.setTextInBufferRange(new Range(range.end, range.end), ` ${commentParts.after}`);
editor.setTextInBufferRange(new Range(range.start, range.start), `${commentParts.before} `);
} | [
"function",
"comment",
"(",
"editor",
",",
"range",
",",
"modelType",
")",
"{",
"const",
"commentParts",
"=",
"modelComments",
"[",
"modelType",
"]",
";",
"editor",
".",
"setTextInBufferRange",
"(",
"new",
"Range",
"(",
"range",
".",
"end",
",",
"range",
"... | Comments given node in text editor
@param {TextEditor} editor
@param {Range} range
@param {String} modelType | [
"Comments",
"given",
"node",
"in",
"text",
"editor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/toggle-block-comment.js#L73-L77 | train |
emmetio/atom-plugin | lib/actions/toggle-block-comment.js | uncomment | function uncomment(editor, range, modelType) {
const commentParts = modelComments[modelType];
const stream = new BufferStreamReader(editor.getBuffer(), range.start, range);
// narrow down comment range till meanful content
stream.pos = range.start.translate([0, commentParts.before.length]);
stream.eatWhile(isSpac... | javascript | function uncomment(editor, range, modelType) {
const commentParts = modelComments[modelType];
const stream = new BufferStreamReader(editor.getBuffer(), range.start, range);
// narrow down comment range till meanful content
stream.pos = range.start.translate([0, commentParts.before.length]);
stream.eatWhile(isSpac... | [
"function",
"uncomment",
"(",
"editor",
",",
"range",
",",
"modelType",
")",
"{",
"const",
"commentParts",
"=",
"modelComments",
"[",
"modelType",
"]",
";",
"const",
"stream",
"=",
"new",
"BufferStreamReader",
"(",
"editor",
".",
"getBuffer",
"(",
")",
",",
... | Un-comments given range in text editor
@param {TextEditor} editor
@param {Range} range
@param {String} modelType
@return {Object} Returns delta of removed characters from | [
"Un",
"-",
"comments",
"given",
"range",
"in",
"text",
"editor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/toggle-block-comment.js#L86-L119 | train |
emmetio/atom-plugin | lib/actions/toggle-block-comment.js | commentsInRange | function commentsInRange(model, range) {
const intersects = token => getRange(token).intersectsWith(range, true);
if (model.type === 'html') {
// in html model, comments are nodes in model
return iterate(model.dom, node => node.type === 'comment' && intersects(node));
}
if (model.type === 'stylesheet') {
//... | javascript | function commentsInRange(model, range) {
const intersects = token => getRange(token).intersectsWith(range, true);
if (model.type === 'html') {
// in html model, comments are nodes in model
return iterate(model.dom, node => node.type === 'comment' && intersects(node));
}
if (model.type === 'stylesheet') {
//... | [
"function",
"commentsInRange",
"(",
"model",
",",
"range",
")",
"{",
"const",
"intersects",
"=",
"token",
"=>",
"getRange",
"(",
"token",
")",
".",
"intersectsWith",
"(",
"range",
",",
"true",
")",
";",
"if",
"(",
"model",
".",
"type",
"===",
"'html'",
... | Finds all comment ranges that matches given range
@param {SyntaxModel} model
@param {Range} range
@return {Range[]} | [
"Finds",
"all",
"comment",
"ranges",
"that",
"matches",
"given",
"range"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/toggle-block-comment.js#L148-L164 | train |
emmetio/atom-plugin | lib/locate-file.js | resolveRelative | function resolveRelative(base, filePath) {
return getBasePath(base)
.then(basePath => tryFile(path.resolve(basePath, filePath)));
} | javascript | function resolveRelative(base, filePath) {
return getBasePath(base)
.then(basePath => tryFile(path.resolve(basePath, filePath)));
} | [
"function",
"resolveRelative",
"(",
"base",
",",
"filePath",
")",
"{",
"return",
"getBasePath",
"(",
"base",
")",
".",
"then",
"(",
"basePath",
"=>",
"tryFile",
"(",
"path",
".",
"resolve",
"(",
"basePath",
",",
"filePath",
")",
")",
")",
";",
"}"
] | Resolves relative file path
@param {TextEditor|String} base
@param {String} filePath
@return {Promise} | [
"Resolves",
"relative",
"file",
"path"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/locate-file.js#L35-L38 | train |
emmetio/atom-plugin | lib/locate-file.js | getBasePath | function getBasePath(base) {
return new Promise((resolve, reject) => {
if (base && typeof base.getPath === 'function') {
const editorFile = base.getPath();
if (!editorFile) {
return reject(new Error('Unable to get base path: editor contains unsaved file'));
}
base = path.dirname(editorFile);
}
... | javascript | function getBasePath(base) {
return new Promise((resolve, reject) => {
if (base && typeof base.getPath === 'function') {
const editorFile = base.getPath();
if (!editorFile) {
return reject(new Error('Unable to get base path: editor contains unsaved file'));
}
base = path.dirname(editorFile);
}
... | [
"function",
"getBasePath",
"(",
"base",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"base",
"&&",
"typeof",
"base",
".",
"getPath",
"===",
"'function'",
")",
"{",
"const",
"editorFile",
"=",
"bas... | Returns base path from file, opened in given editor
@param {TextEditor|String} base
@return {Promise} | [
"Returns",
"base",
"path",
"from",
"file",
"opened",
"in",
"given",
"editor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/locate-file.js#L73-L90 | train |
helpers/handlebars-utils | index.js | isEmpty | function isEmpty(val) {
if (val === 0 || typeof val === 'boolean') {
return false;
}
if (val == null) {
return true;
}
if (utils.isObject(val)) {
val = Object.keys(val);
}
if (!val.length) {
return true;
}
return false;
} | javascript | function isEmpty(val) {
if (val === 0 || typeof val === 'boolean') {
return false;
}
if (val == null) {
return true;
}
if (utils.isObject(val)) {
val = Object.keys(val);
}
if (!val.length) {
return true;
}
return false;
} | [
"function",
"isEmpty",
"(",
"val",
")",
"{",
"if",
"(",
"val",
"===",
"0",
"||",
"typeof",
"val",
"===",
"'boolean'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"utils",... | Returns true if the given value is "empty".
```js
console.log(utils.isEmpty(0));
//=> false
console.log(utils.isEmpty(''));
//=> true
console.log(utils.isEmpty([]));
//=> true
console.log(utils.isEmpty({}));
//=> true
```
@name .isEmpty
@param {any} `value`
@return {Boolean}
@api public | [
"Returns",
"true",
"if",
"the",
"given",
"value",
"is",
"empty",
"."
] | 846541474dec1aea9a405675c7809a30aa5a4072 | https://github.com/helpers/handlebars-utils/blob/846541474dec1aea9a405675c7809a30aa5a4072/index.js#L421-L435 | train |
emmetio/atom-plugin | lib/image-size.js | getImageSizeFromFile | function getImageSizeFromFile(file) {
return new Promise((resolve, reject) => {
const isDataUrl = file.match(/^data:.+?;base64,/);
if (isDataUrl) {
// NB should use sync version of `sizeOf()` for buffers
try {
const data = Buffer.from(file.slice(isDataUrl[0].length), 'base64');
return resolve(sizeFo... | javascript | function getImageSizeFromFile(file) {
return new Promise((resolve, reject) => {
const isDataUrl = file.match(/^data:.+?;base64,/);
if (isDataUrl) {
// NB should use sync version of `sizeOf()` for buffers
try {
const data = Buffer.from(file.slice(isDataUrl[0].length), 'base64');
return resolve(sizeFo... | [
"function",
"getImageSizeFromFile",
"(",
"file",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"isDataUrl",
"=",
"file",
".",
"match",
"(",
"/",
"^data:.+?;base64,",
"/",
")",
";",
"if",
"(",
"isDataUr... | Get image size from file on local file system
@param {String} file
@return {Promise} | [
"Get",
"image",
"size",
"from",
"file",
"on",
"local",
"file",
"system"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/image-size.js#L27-L49 | train |
emmetio/atom-plugin | lib/image-size.js | getImageSizeFromURL | function getImageSizeFromURL(url) {
return new Promise((resolve, reject) => {
url = parseUrl(url);
const transport = url.protocol === 'https:' ? https : http;
transport.get(url, resp => {
const chunks = [];
let bufSize = 0;
const trySize = chunks => {
try {
const size = sizeOf(Buffer.concat(c... | javascript | function getImageSizeFromURL(url) {
return new Promise((resolve, reject) => {
url = parseUrl(url);
const transport = url.protocol === 'https:' ? https : http;
transport.get(url, resp => {
const chunks = [];
let bufSize = 0;
const trySize = chunks => {
try {
const size = sizeOf(Buffer.concat(c... | [
"function",
"getImageSizeFromURL",
"(",
"url",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"url",
"=",
"parseUrl",
"(",
"url",
")",
";",
"const",
"transport",
"=",
"url",
".",
"protocol",
"===",
"'https:'",
... | Get image size from given remove URL
@param {String} url
@return {Promise} | [
"Get",
"image",
"size",
"from",
"given",
"remove",
"URL"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/image-size.js#L56-L92 | train |
emmetio/atom-plugin | lib/image-size.js | sizeForFileName | function sizeForFileName(fileName, size) {
const m = fileName.match(/@(\d+)x\./);
const scale = m ? +m[1] : 1;
return {
realWidth: size.width,
realHeight: size.height,
width: Math.floor(size.width / scale),
height: Math.floor(size.height / scale)
};
} | javascript | function sizeForFileName(fileName, size) {
const m = fileName.match(/@(\d+)x\./);
const scale = m ? +m[1] : 1;
return {
realWidth: size.width,
realHeight: size.height,
width: Math.floor(size.width / scale),
height: Math.floor(size.height / scale)
};
} | [
"function",
"sizeForFileName",
"(",
"fileName",
",",
"size",
")",
"{",
"const",
"m",
"=",
"fileName",
".",
"match",
"(",
"/",
"@(\\d+)x\\.",
"/",
")",
";",
"const",
"scale",
"=",
"m",
"?",
"+",
"m",
"[",
"1",
"]",
":",
"1",
";",
"return",
"{",
"r... | Returns size object for given file name. If file name contains `@Nx` token,
the final dimentions will be downscaled by N
@param {String} fileName
@param {Object} size
@return {Object} | [
"Returns",
"size",
"object",
"for",
"given",
"file",
"name",
".",
"If",
"file",
"name",
"contains"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/image-size.js#L101-L111 | train |
emmetio/atom-plugin | lib/actions/convert-data-url.js | findTokenForPoint | function findTokenForPoint(parent, point, type) {
if (!parent) {
return null;
}
if (parent.type === type) {
return parent;
}
for (let i = 0, il = parent.size, item; i < il; i++) {
item = parent.item(i);
if (containsPoint(item, point)) {
return findTokenForPoint(item, point, type);
}
}
} | javascript | function findTokenForPoint(parent, point, type) {
if (!parent) {
return null;
}
if (parent.type === type) {
return parent;
}
for (let i = 0, il = parent.size, item; i < il; i++) {
item = parent.item(i);
if (containsPoint(item, point)) {
return findTokenForPoint(item, point, type);
}
}
} | [
"function",
"findTokenForPoint",
"(",
"parent",
",",
"point",
",",
"type",
")",
"{",
"if",
"(",
"!",
"parent",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"parent",
".",
"type",
"===",
"type",
")",
"{",
"return",
"parent",
";",
"}",
"for",
"("... | Finds first deeply nested token of given `type` that contains given `point`
@param {Token} parent Parent CSS token
@param {Point} point
@param {String} type Token type to find
@return {Token} | [
"Finds",
"first",
"deeply",
"nested",
"token",
"of",
"given",
"type",
"that",
"contains",
"given",
"point"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/convert-data-url.js#L126-L141 | train |
emmetio/atom-plugin | lib/actions/convert-data-url.js | saveAsFile | function saveAsFile(editor, data, range) {
return new Promise((resolve, reject) => {
const fileName = atom.getCurrentWindow().showSaveDialog();
if (!fileName) {
return reject(new Error('User cancelled file dialog'));
}
fs.writeFile(fileName, Buffer.from(data, 'base64'), err => {
if (err) {
return re... | javascript | function saveAsFile(editor, data, range) {
return new Promise((resolve, reject) => {
const fileName = atom.getCurrentWindow().showSaveDialog();
if (!fileName) {
return reject(new Error('User cancelled file dialog'));
}
fs.writeFile(fileName, Buffer.from(data, 'base64'), err => {
if (err) {
return re... | [
"function",
"saveAsFile",
"(",
"editor",
",",
"data",
",",
"range",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"fileName",
"=",
"atom",
".",
"getCurrentWindow",
"(",
")",
".",
"showSaveDialog",
"(",... | Saves given base64-encoded string as file on file system
@param {TextEditor} editor
@param {String} data Base64-encoded file
@param {Range} range Editor’s replacement where saved file URL should
be written
@return {Promise} | [
"Saves",
"given",
"base64",
"-",
"encoded",
"string",
"as",
"file",
"on",
"file",
"system"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/convert-data-url.js#L151-L176 | train |
emmetio/atom-plugin | lib/actions/convert-data-url.js | readFile | function readFile(fileName) {
if (/^https?:/.test(fileName)) {
return readFileFromURL(fileName);
}
return new Promise((resolve, reject) => {
fs.readFile(fileName, (err, content) => err ? reject(err) : resolve(content));
});
} | javascript | function readFile(fileName) {
if (/^https?:/.test(fileName)) {
return readFileFromURL(fileName);
}
return new Promise((resolve, reject) => {
fs.readFile(fileName, (err, content) => err ? reject(err) : resolve(content));
});
} | [
"function",
"readFile",
"(",
"fileName",
")",
"{",
"if",
"(",
"/",
"^https?:",
"/",
".",
"test",
"(",
"fileName",
")",
")",
"{",
"return",
"readFileFromURL",
"(",
"fileName",
")",
";",
"}",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject"... | Reads contents of given file path or URL as buffer
@param {String} fileName File path or URL
@return {Promise} | [
"Reads",
"contents",
"of",
"given",
"file",
"path",
"or",
"URL",
"as",
"buffer"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/convert-data-url.js#L206-L214 | train |
emmetio/atom-plugin | lib/actions/insert-line-break.js | hasScope | function hasScope(descriptor, scope) {
for (let i = 0; i < descriptor.scopes.length; i++) {
if (descriptor.scopes[i].includes(scope)) {
return true;
}
}
return false;
} | javascript | function hasScope(descriptor, scope) {
for (let i = 0; i < descriptor.scopes.length; i++) {
if (descriptor.scopes[i].includes(scope)) {
return true;
}
}
return false;
} | [
"function",
"hasScope",
"(",
"descriptor",
",",
"scope",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"descriptor",
".",
"scopes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"descriptor",
".",
"scopes",
"[",
"i",
"]",
".",
... | Check if given scope descriptor contains given scope
@param {ScopeDescriptor} descriptor
@param {String} scope
@return {Boolean} | [
"Check",
"if",
"given",
"scope",
"descriptor",
"contains",
"given",
"scope"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/insert-line-break.js#L46-L54 | train |
emmetio/atom-plugin | lib/actions/insert-line-break.js | insertFormattedLineBreak | function insertFormattedLineBreak(cursor) {
const indent = cursor.editor.getTabText();
const lineIndent = getLineIndent(cursor);
cursor.selection.insertText(`\n${lineIndent}${indent}\n${lineIndent}`, { autoIndent: false });
// Put caret at the end of indented newline
cursor.moveUp();
cursor.moveToEndOfLine();
} | javascript | function insertFormattedLineBreak(cursor) {
const indent = cursor.editor.getTabText();
const lineIndent = getLineIndent(cursor);
cursor.selection.insertText(`\n${lineIndent}${indent}\n${lineIndent}`, { autoIndent: false });
// Put caret at the end of indented newline
cursor.moveUp();
cursor.moveToEndOfLine();
} | [
"function",
"insertFormattedLineBreak",
"(",
"cursor",
")",
"{",
"const",
"indent",
"=",
"cursor",
".",
"editor",
".",
"getTabText",
"(",
")",
";",
"const",
"lineIndent",
"=",
"getLineIndent",
"(",
"cursor",
")",
";",
"cursor",
".",
"selection",
".",
"insert... | Inserts formated line break for given cursor
@param {Cursor} cursor | [
"Inserts",
"formated",
"line",
"break",
"for",
"given",
"cursor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/insert-line-break.js#L68-L77 | train |
emmetio/atom-plugin | lib/actions/edit-point.js | isAtCodePoint | function isAtCodePoint(stream) {
const code = stream.peek();
// between quotes, looks like an empty attribute value
return (isQuote(code) && getPrevCode(stream) === code)
// between tags, e.g. > and <
|| (code === 60 /* < */ && getPrevCode(stream) === 62 /* > */)
// on empty line
|| (isLineBreak(code) && re... | javascript | function isAtCodePoint(stream) {
const code = stream.peek();
// between quotes, looks like an empty attribute value
return (isQuote(code) && getPrevCode(stream) === code)
// between tags, e.g. > and <
|| (code === 60 /* < */ && getPrevCode(stream) === 62 /* > */)
// on empty line
|| (isLineBreak(code) && re... | [
"function",
"isAtCodePoint",
"(",
"stream",
")",
"{",
"const",
"code",
"=",
"stream",
".",
"peek",
"(",
")",
";",
"// between quotes, looks like an empty attribute value",
"return",
"(",
"isQuote",
"(",
"code",
")",
"&&",
"getPrevCode",
"(",
"stream",
")",
"==="... | Check if stream is currently at edit code point
@param {BufferStreamReader} stream
@return {Boolean} | [
"Check",
"if",
"stream",
"is",
"currently",
"at",
"edit",
"code",
"point"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/edit-point.js#L57-L66 | train |
emmetio/atom-plugin | lib/actions/edit-point.js | getPrevCode | function getPrevCode(stream) {
if (!stream.sof()) {
const code = stream.backUp(1);
stream.next();
return code;
}
} | javascript | function getPrevCode(stream) {
if (!stream.sof()) {
const code = stream.backUp(1);
stream.next();
return code;
}
} | [
"function",
"getPrevCode",
"(",
"stream",
")",
"{",
"if",
"(",
"!",
"stream",
".",
"sof",
"(",
")",
")",
"{",
"const",
"code",
"=",
"stream",
".",
"backUp",
"(",
"1",
")",
";",
"stream",
".",
"next",
"(",
")",
";",
"return",
"code",
";",
"}",
"... | Returns precediong character code for current position
@param {BufferStreamReader} stream
@return {Number} | [
"Returns",
"precediong",
"character",
"code",
"for",
"current",
"position"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/edit-point.js#L73-L79 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | updateImageSizeHTML | function updateImageSizeHTML(editor, model) {
const pos = editor.getCursorBufferPosition();
const src = getImageSrcHTML( getImageHTMLNode(editor, model, pos) );
if (!src) {
return Promise.reject(new Error('No valid image source'));
}
locateFile(editor, src)
.then(getImageSize)
.then(size => {
// since this... | javascript | function updateImageSizeHTML(editor, model) {
const pos = editor.getCursorBufferPosition();
const src = getImageSrcHTML( getImageHTMLNode(editor, model, pos) );
if (!src) {
return Promise.reject(new Error('No valid image source'));
}
locateFile(editor, src)
.then(getImageSize)
.then(size => {
// since this... | [
"function",
"updateImageSizeHTML",
"(",
"editor",
",",
"model",
")",
"{",
"const",
"pos",
"=",
"editor",
".",
"getCursorBufferPosition",
"(",
")",
";",
"const",
"src",
"=",
"getImageSrcHTML",
"(",
"getImageHTMLNode",
"(",
"editor",
",",
"model",
",",
"pos",
... | Updates image size of context tag of HTML model
@param {TextEditor} editor
@param {SyntaxModel} model
@return {Promise} | [
"Updates",
"image",
"size",
"of",
"context",
"tag",
"of",
"HTML",
"model"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L31-L50 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | updateImageSizeCSS | function updateImageSizeCSS(editor, model) {
const pos = editor.getCursorBufferPosition();
const property = getImageCSSNode(editor, model, pos);
const urlToken = findUrlToken(property, pos);
const src = urlToken && getImageSrcCSS(urlToken);
if (!src) {
return Promise.reject(new Error('No valid image source'));
... | javascript | function updateImageSizeCSS(editor, model) {
const pos = editor.getCursorBufferPosition();
const property = getImageCSSNode(editor, model, pos);
const urlToken = findUrlToken(property, pos);
const src = urlToken && getImageSrcCSS(urlToken);
if (!src) {
return Promise.reject(new Error('No valid image source'));
... | [
"function",
"updateImageSizeCSS",
"(",
"editor",
",",
"model",
")",
"{",
"const",
"pos",
"=",
"editor",
".",
"getCursorBufferPosition",
"(",
")",
";",
"const",
"property",
"=",
"getImageCSSNode",
"(",
"editor",
",",
"model",
",",
"pos",
")",
";",
"const",
... | Updates image size of context rule of stylesheet model
@param {TextEditor} editor
@param {SyntaxModel} model
@return {Promise} | [
"Updates",
"image",
"size",
"of",
"context",
"rule",
"of",
"stylesheet",
"model"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L58-L78 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | updateHTMLTag | function updateHTMLTag(editor, node, width, height) {
const srcAttr = getAttribute(node, 'src');
const widthAttr = getAttribute(node, 'width');
const heightAttr = getAttribute(node, 'height');
editor.transact(() => {
// apply changes from right to left, first for height, then for width
let point;
const quote... | javascript | function updateHTMLTag(editor, node, width, height) {
const srcAttr = getAttribute(node, 'src');
const widthAttr = getAttribute(node, 'width');
const heightAttr = getAttribute(node, 'height');
editor.transact(() => {
// apply changes from right to left, first for height, then for width
let point;
const quote... | [
"function",
"updateHTMLTag",
"(",
"editor",
",",
"node",
",",
"width",
",",
"height",
")",
"{",
"const",
"srcAttr",
"=",
"getAttribute",
"(",
"node",
",",
"'src'",
")",
";",
"const",
"widthAttr",
"=",
"getAttribute",
"(",
"node",
",",
"'width'",
")",
";"... | Updates size of given HTML node
@param {TextEditor} editor
@param {Node} node
@param {Number} width
@param {Number} height | [
"Updates",
"size",
"of",
"given",
"HTML",
"node"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L134-L160 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | updateCSSNode | function updateCSSNode(editor, srcProp, width, height) {
const rule = srcProp.parent;
const widthProp = getProperty(rule, 'width');
const heightProp = getProperty(rule, 'height');
// Detect formatting
const separator = srcProp.separator || ': ';
const before = getBefore(editor, srcProp);
const insertOpt = { aut... | javascript | function updateCSSNode(editor, srcProp, width, height) {
const rule = srcProp.parent;
const widthProp = getProperty(rule, 'width');
const heightProp = getProperty(rule, 'height');
// Detect formatting
const separator = srcProp.separator || ': ';
const before = getBefore(editor, srcProp);
const insertOpt = { aut... | [
"function",
"updateCSSNode",
"(",
"editor",
",",
"srcProp",
",",
"width",
",",
"height",
")",
"{",
"const",
"rule",
"=",
"srcProp",
".",
"parent",
";",
"const",
"widthProp",
"=",
"getProperty",
"(",
"rule",
",",
"'width'",
")",
";",
"const",
"heightProp",
... | Updates size of given CSS rule
@param {TextEditor} editor
@param {Node} srcProp
@param {Number} width
@param {Number} height | [
"Updates",
"size",
"of",
"given",
"CSS",
"rule"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L169-L204 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | findUrlToken | function findUrlToken(node, pos) {
for (let i = 0, il = node.parsedValue.length, url; i < il; i++) {
iterateCSSToken(node.parsedValue[i], token => {
if (token.type === 'url' && containsPoint(token, pos)) {
url = token;
return false;
}
});
if (url) {
return url;
}
}
} | javascript | function findUrlToken(node, pos) {
for (let i = 0, il = node.parsedValue.length, url; i < il; i++) {
iterateCSSToken(node.parsedValue[i], token => {
if (token.type === 'url' && containsPoint(token, pos)) {
url = token;
return false;
}
});
if (url) {
return url;
}
}
} | [
"function",
"findUrlToken",
"(",
"node",
",",
"pos",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"il",
"=",
"node",
".",
"parsedValue",
".",
"length",
",",
"url",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"{",
"iterateCSSToken",
"(",
"node",... | Finds 'url' token for given `pos` point in given CSS property `node`
@param {Node} node
@param {Point} pos
@return {Token} | [
"Finds",
"url",
"token",
"for",
"given",
"pos",
"point",
"in",
"given",
"CSS",
"property",
"node"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L235-L248 | train |
emmetio/atom-plugin | lib/actions/update-image-size.js | getProperty | function getProperty(rule, name) {
return rule.children.find(node => node.type === 'property' && node.name === name);
} | javascript | function getProperty(rule, name) {
return rule.children.find(node => node.type === 'property' && node.name === name);
} | [
"function",
"getProperty",
"(",
"rule",
",",
"name",
")",
"{",
"return",
"rule",
".",
"children",
".",
"find",
"(",
"node",
"=>",
"node",
".",
"type",
"===",
"'property'",
"&&",
"node",
".",
"name",
"===",
"name",
")",
";",
"}"
] | Returns `name` CSS property from given `rule`
@param {Node} rule
@param {String} name
@return {Node} | [
"Returns",
"name",
"CSS",
"property",
"from",
"given",
"rule"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/update-image-size.js#L256-L258 | train |
emmetio/atom-plugin | lib/actions/select-item.js | selectItem | function selectItem(editor, model, getItemRange) {
editor.transact(() => {
const selections = editor.getSelectedBufferRanges()
.map(anchor => getItemRange(model, anchor) || anchor);
editor.setSelectedBufferRanges(selections);
});
} | javascript | function selectItem(editor, model, getItemRange) {
editor.transact(() => {
const selections = editor.getSelectedBufferRanges()
.map(anchor => getItemRange(model, anchor) || anchor);
editor.setSelectedBufferRanges(selections);
});
} | [
"function",
"selectItem",
"(",
"editor",
",",
"model",
",",
"getItemRange",
")",
"{",
"editor",
".",
"transact",
"(",
"(",
")",
"=>",
"{",
"const",
"selections",
"=",
"editor",
".",
"getSelectedBufferRanges",
"(",
")",
".",
"map",
"(",
"anchor",
"=>",
"g... | Selects each item, returned by `getItem` method, in given editor
@param {TextEditor} editor
@param {SyntaxModel} model
@param {Function} getItemRange | [
"Selects",
"each",
"item",
"returned",
"by",
"getItem",
"method",
"in",
"given",
"editor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L45-L52 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getNextItemRange | function getNextItemRange(model, anchor, getItemRanges) {
// Find HTML node for next selection
let node = nodeForPoint(model, anchor.start, 'next');
let range;
// We might need to narrow down node context to find best token match
while (node && !range) {
range = getNextRange(getItemRanges(node), anchor);
node... | javascript | function getNextItemRange(model, anchor, getItemRanges) {
// Find HTML node for next selection
let node = nodeForPoint(model, anchor.start, 'next');
let range;
// We might need to narrow down node context to find best token match
while (node && !range) {
range = getNextRange(getItemRanges(node), anchor);
node... | [
"function",
"getNextItemRange",
"(",
"model",
",",
"anchor",
",",
"getItemRanges",
")",
"{",
"// Find HTML node for next selection",
"let",
"node",
"=",
"nodeForPoint",
"(",
"model",
",",
"anchor",
".",
"start",
",",
"'next'",
")",
";",
"let",
"range",
";",
"/... | Returns selection range of useful code part of given `model` next to given
`anchor` range.
@param {SyntaxModel} model
@param {Range} anchor
@param {Function} getItemRanges A function to retreive node ranges
@return {Range} | [
"Returns",
"selection",
"range",
"of",
"useful",
"code",
"part",
"of",
"given",
"model",
"next",
"to",
"given",
"anchor",
"range",
"."
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L102-L114 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getPreviousItemRange | function getPreviousItemRange(model, anchor, getItemRanges) {
// Find HTML node for next selection
let node = nodeForPoint(model, anchor.start, 'previous');
let range;
// We might need to narrow down node context to find best token match
while (node) {
range = getPreviousRange(getItemRanges(node), anchor);
if... | javascript | function getPreviousItemRange(model, anchor, getItemRanges) {
// Find HTML node for next selection
let node = nodeForPoint(model, anchor.start, 'previous');
let range;
// We might need to narrow down node context to find best token match
while (node) {
range = getPreviousRange(getItemRanges(node), anchor);
if... | [
"function",
"getPreviousItemRange",
"(",
"model",
",",
"anchor",
",",
"getItemRanges",
")",
"{",
"// Find HTML node for next selection",
"let",
"node",
"=",
"nodeForPoint",
"(",
"model",
",",
"anchor",
".",
"start",
",",
"'previous'",
")",
";",
"let",
"range",
"... | Returns selection range of useful code part of given `model` that precedes
given `anchor` range.
@param {SyntaxModel} model
@param {Range} anchor
@param {Function} getItemRanges A function to retreive node ranges
@return {Range} | [
"Returns",
"selection",
"range",
"of",
"useful",
"code",
"part",
"of",
"given",
"model",
"that",
"precedes",
"given",
"anchor",
"range",
"."
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L124-L139 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getNextRange | function getNextRange(ranges, anchor) {
for (let i = 0; i < ranges.length; i++) {
if (anchor.isEqual(ranges[i])) {
// NB may return `undefined`, which is totally fine and means that
// we should move to next element
return ranges[i + 1];
}
}
// Keep ranges which are not on the left of given selection
... | javascript | function getNextRange(ranges, anchor) {
for (let i = 0; i < ranges.length; i++) {
if (anchor.isEqual(ranges[i])) {
// NB may return `undefined`, which is totally fine and means that
// we should move to next element
return ranges[i + 1];
}
}
// Keep ranges which are not on the left of given selection
... | [
"function",
"getNextRange",
"(",
"ranges",
",",
"anchor",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"ranges",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"anchor",
".",
"isEqual",
"(",
"ranges",
"[",
"i",
"]",
")",
")",... | Tries to find range that equals given `anchor` range in `ranges` and returns
next one. Otherwise returns next to given `anchor` range
@param {Range[]} ranges
@param {Range} anchor
@return {Range} May return `undefined` if there’s no valid next range | [
"Tries",
"to",
"find",
"range",
"that",
"equals",
"given",
"anchor",
"range",
"in",
"ranges",
"and",
"returns",
"next",
"one",
".",
"Otherwise",
"returns",
"next",
"to",
"given",
"anchor",
"range"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L148-L161 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getPreviousRange | function getPreviousRange(ranges, anchor) {
for (let i = 0; i < ranges.length; i++) {
if (anchor.isEqual(ranges[i])) {
// NB may return `undefined`, which is totally fine and means that
// we should move to next element
return ranges[i - 1];
}
}
// Keep ranges which are not on the left of given selecti... | javascript | function getPreviousRange(ranges, anchor) {
for (let i = 0; i < ranges.length; i++) {
if (anchor.isEqual(ranges[i])) {
// NB may return `undefined`, which is totally fine and means that
// we should move to next element
return ranges[i - 1];
}
}
// Keep ranges which are not on the left of given selecti... | [
"function",
"getPreviousRange",
"(",
"ranges",
",",
"anchor",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"ranges",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"anchor",
".",
"isEqual",
"(",
"ranges",
"[",
"i",
"]",
")",
... | Tries to find range that equals given `anchor` range in `ranges` and returns
previous one. Otherwise returns previous to given `anchor` range
@param {Range[]} ranges
@param {Range} anchor
@return {Range} May return `undefined` if there’s no valid next range | [
"Tries",
"to",
"find",
"range",
"that",
"equals",
"given",
"anchor",
"range",
"in",
"ranges",
"and",
"returns",
"previous",
"one",
".",
"Otherwise",
"returns",
"previous",
"to",
"given",
"anchor",
"range"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L170-L183 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getRangesFromHTMLNode | function getRangesFromHTMLNode(node) {
if (node.type !== 'tag') {
return [];
}
let ranges = [ getRange(node.open.name) ];
if (node.attributes) {
node.attributes.forEach(attr => {
ranges.push(getRange(attr));
if (!attr.boolean) {
// add attribute value (unquoted) range for non-boolean attributes
... | javascript | function getRangesFromHTMLNode(node) {
if (node.type !== 'tag') {
return [];
}
let ranges = [ getRange(node.open.name) ];
if (node.attributes) {
node.attributes.forEach(attr => {
ranges.push(getRange(attr));
if (!attr.boolean) {
// add attribute value (unquoted) range for non-boolean attributes
... | [
"function",
"getRangesFromHTMLNode",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"!==",
"'tag'",
")",
"{",
"return",
"[",
"]",
";",
"}",
"let",
"ranges",
"=",
"[",
"getRange",
"(",
"node",
".",
"open",
".",
"name",
")",
"]",
";",
"if",
... | Returns possible selection ranges for given HTML model node
@param {Node} node
@return {Range[]} | [
"Returns",
"possible",
"selection",
"ranges",
"for",
"given",
"HTML",
"model",
"node"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L190-L216 | train |
emmetio/atom-plugin | lib/actions/select-item.js | getRangesFromCSSNode | function getRangesFromCSSNode(node) {
let ranges;
if (node.type === 'rule') {
ranges = [ getRange(node.selectorToken) ].concat(node.parsedSelector.map(getRange));
} else if (node.type === 'at-rule') {
const nameEndToken = node.expressionToken || node.nameToken;
ranges = [
new Range(node.nameToken.start, na... | javascript | function getRangesFromCSSNode(node) {
let ranges;
if (node.type === 'rule') {
ranges = [ getRange(node.selectorToken) ].concat(node.parsedSelector.map(getRange));
} else if (node.type === 'at-rule') {
const nameEndToken = node.expressionToken || node.nameToken;
ranges = [
new Range(node.nameToken.start, na... | [
"function",
"getRangesFromCSSNode",
"(",
"node",
")",
"{",
"let",
"ranges",
";",
"if",
"(",
"node",
".",
"type",
"===",
"'rule'",
")",
"{",
"ranges",
"=",
"[",
"getRange",
"(",
"node",
".",
"selectorToken",
")",
"]",
".",
"concat",
"(",
"node",
".",
... | Returns possible selection ranges from given CSS model node
@param {Node} node
@return {Range[]} | [
"Returns",
"possible",
"selection",
"ranges",
"from",
"given",
"CSS",
"model",
"node"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L223-L272 | train |
emmetio/atom-plugin | lib/actions/select-item.js | nodeForPoint | function nodeForPoint(model, point, direction) {
const node = model.nodeForPoint(point);
if (node) {
return node;
}
// Looks like caret is outside of any top-level node.
const topLevelNodes = model.dom.children;
if (direction === 'next') {
// Find next node, which is closest top-level to given position
r... | javascript | function nodeForPoint(model, point, direction) {
const node = model.nodeForPoint(point);
if (node) {
return node;
}
// Looks like caret is outside of any top-level node.
const topLevelNodes = model.dom.children;
if (direction === 'next') {
// Find next node, which is closest top-level to given position
r... | [
"function",
"nodeForPoint",
"(",
"model",
",",
"point",
",",
"direction",
")",
"{",
"const",
"node",
"=",
"model",
".",
"nodeForPoint",
"(",
"point",
")",
";",
"if",
"(",
"node",
")",
"{",
"return",
"node",
";",
"}",
"// Looks like caret is outside of any to... | Returns best matching node for given position. If on direct position match,
tries to find closest one on givrn direction
@param {SyntaxModel} model
@param {Point} point
@param {String} direction 'next' or 'previous'
@return {Node} | [
"Returns",
"best",
"matching",
"node",
"for",
"given",
"position",
".",
"If",
"on",
"direct",
"position",
"match",
"tries",
"to",
"find",
"closest",
"one",
"on",
"givrn",
"direction"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L307-L328 | train |
emmetio/atom-plugin | lib/actions/select-item.js | nextSibling | function nextSibling(node) {
while (node) {
if (node.nextSibling) {
return node.nextSibling;
}
node = node.parent;
}
} | javascript | function nextSibling(node) {
while (node) {
if (node.nextSibling) {
return node.nextSibling;
}
node = node.parent;
}
} | [
"function",
"nextSibling",
"(",
"node",
")",
"{",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"nextSibling",
")",
"{",
"return",
"node",
".",
"nextSibling",
";",
"}",
"node",
"=",
"node",
".",
"parent",
";",
"}",
"}"
] | Returns next sibling element for given node. If no direct sibling found, tries
to find it from its parent and so on
@param {Node} node
@return {Node} | [
"Returns",
"next",
"sibling",
"element",
"for",
"given",
"node",
".",
"If",
"no",
"direct",
"sibling",
"found",
"tries",
"to",
"find",
"it",
"from",
"its",
"parent",
"and",
"so",
"on"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/actions/select-item.js#L336-L343 | train |
emmetio/atom-plugin | lib/abbreviation-marker.js | toggleEditorClass | function toggleEditorClass(editor, enabled) {
const view = atom.views.getView(editor);
if (view) {
view.classList.toggle('has-emmet-abbreviation', enabled);
}
} | javascript | function toggleEditorClass(editor, enabled) {
const view = atom.views.getView(editor);
if (view) {
view.classList.toggle('has-emmet-abbreviation', enabled);
}
} | [
"function",
"toggleEditorClass",
"(",
"editor",
",",
"enabled",
")",
"{",
"const",
"view",
"=",
"atom",
".",
"views",
".",
"getView",
"(",
"editor",
")",
";",
"if",
"(",
"view",
")",
"{",
"view",
".",
"classList",
".",
"toggle",
"(",
"'has-emmet-abbrevia... | Toggles HTML class on given editor view indicating whether Emmet abbreviation
is available in given editor
@param {TextEditor} editor [description]
@param {Boolean} enabled | [
"Toggles",
"HTML",
"class",
"on",
"given",
"editor",
"view",
"indicating",
"whether",
"Emmet",
"abbreviation",
"is",
"available",
"in",
"given",
"editor"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/abbreviation-marker.js#L184-L189 | train |
emmetio/atom-plugin | lib/abbreviation-marker.js | allowedForAutoActivation | function allowedForAutoActivation(model) {
const rootNode = model.ast.children[0];
// The very first node should start with alpha character
// Skips falsy activations for something like `$foo` etc.
return rootNode && /^[a-z]/i.test(rootNode.name);
} | javascript | function allowedForAutoActivation(model) {
const rootNode = model.ast.children[0];
// The very first node should start with alpha character
// Skips falsy activations for something like `$foo` etc.
return rootNode && /^[a-z]/i.test(rootNode.name);
} | [
"function",
"allowedForAutoActivation",
"(",
"model",
")",
"{",
"const",
"rootNode",
"=",
"model",
".",
"ast",
".",
"children",
"[",
"0",
"]",
";",
"// The very first node should start with alpha character",
"// Skips falsy activations for something like `$foo` etc.",
"return... | Check if given abbreviation model is allowed for auto-activated abbreviation
marker. Used to reduce falsy activations
@param {Object} model Parsed abbreviation model (see `createAbbreviationModel()`)
@return {Boolean} | [
"Check",
"if",
"given",
"abbreviation",
"model",
"is",
"allowed",
"for",
"auto",
"-",
"activated",
"abbreviation",
"marker",
".",
"Used",
"to",
"reduce",
"falsy",
"activations"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/abbreviation-marker.js#L197-L202 | train |
emmetio/atom-plugin | lib/autocomplete/abbreviation.js | getExpandedAbbreviationCompletion | function getExpandedAbbreviationCompletion({editor, bufferPosition, prefix, activatedManually}) {
// We should expand marked abbreviation only.
// If there’s no marked abbreviation, try to mark it but only if
// user invoked automomplete popup manually
let marker = findMarker(editor, bufferPosition);
if (!marker &... | javascript | function getExpandedAbbreviationCompletion({editor, bufferPosition, prefix, activatedManually}) {
// We should expand marked abbreviation only.
// If there’s no marked abbreviation, try to mark it but only if
// user invoked automomplete popup manually
let marker = findMarker(editor, bufferPosition);
if (!marker &... | [
"function",
"getExpandedAbbreviationCompletion",
"(",
"{",
"editor",
",",
"bufferPosition",
",",
"prefix",
",",
"activatedManually",
"}",
")",
"{",
"// We should expand marked abbreviation only.",
"// If there’s no marked abbreviation, try to mark it but only if",
"// user invoked au... | Returns completion option for Emmet abbreviation found in given autocomplete
invocation options
@param {Object} event Autocomplete invocation event
@return {Object} Completion with expanded Emmet abbreviation or `null` if
no valid abbreviation found at given context | [
"Returns",
"completion",
"option",
"for",
"Emmet",
"abbreviation",
"found",
"in",
"given",
"autocomplete",
"invocation",
"options"
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/autocomplete/abbreviation.js#L85-L112 | 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.