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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
freedomjs/freedom | demo/aboutme/aboutme.js | function(resp) {
if (resp.name) {
resp.details = "Speaks: " + resp.locale + ", Gender: " + resp.gender;
}
page.emit('profile', resp);
} | javascript | function(resp) {
if (resp.name) {
resp.details = "Speaks: " + resp.locale + ", Gender: " + resp.gender;
}
page.emit('profile', resp);
} | [
"function",
"(",
"resp",
")",
"{",
"if",
"(",
"resp",
".",
"name",
")",
"{",
"resp",
".",
"details",
"=",
"\"Speaks: \"",
"+",
"resp",
".",
"locale",
"+",
"\", Gender: \"",
"+",
"resp",
".",
"gender",
";",
"}",
"page",
".",
"emit",
"(",
"'profile'",
... | onProfile is called by the script included by importScripts above. | [
"onProfile",
"is",
"called",
"by",
"the",
"script",
"included",
"by",
"importScripts",
"above",
"."
] | 9638e840aec9598c4d60383ed22444c525aefbf5 | https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/aboutme/aboutme.js#L56-L61 | train | |
freedomjs/freedom | spec/providers/coreIntegration/rtcpeerconnection.integration.src.js | function(payload, callback) {
var alice, bob, aliceChannel, bobChannel,
aliceCandidates = [],
aliceOffer;
alice = peercon();
bob = peercon();
bob.on('ondatachannel', function (msg) {
bobChannel = datachan(msg.channel);
bobChannel.setBinaryType('arraybuffer', function () {});
... | javascript | function(payload, callback) {
var alice, bob, aliceChannel, bobChannel,
aliceCandidates = [],
aliceOffer;
alice = peercon();
bob = peercon();
bob.on('ondatachannel', function (msg) {
bobChannel = datachan(msg.channel);
bobChannel.setBinaryType('arraybuffer', function () {});
... | [
"function",
"(",
"payload",
",",
"callback",
")",
"{",
"var",
"alice",
",",
"bob",
",",
"aliceChannel",
",",
"bobChannel",
",",
"aliceCandidates",
"=",
"[",
"]",
",",
"aliceOffer",
";",
"alice",
"=",
"peercon",
"(",
")",
";",
"bob",
"=",
"peercon",
"("... | Establishes a peerconnection with one datachannel, sends a message on the datachannel and calls back with the message received by the other peer. | [
"Establishes",
"a",
"peerconnection",
"with",
"one",
"datachannel",
"sends",
"a",
"message",
"on",
"the",
"datachannel",
"and",
"calls",
"back",
"with",
"the",
"message",
"received",
"by",
"the",
"other",
"peer",
"."
] | 9638e840aec9598c4d60383ed22444c525aefbf5 | https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/spec/providers/coreIntegration/rtcpeerconnection.integration.src.js#L19-L77 | train | |
freedomjs/freedom | spec/providers/transport/transport.webrtc.unit.spec.js | makeEventTarget | function makeEventTarget(target) {
var listeners = {};
target.on = function(event, func) {
if (listeners[event]) {
listeners[event].push(func);
} else {
listeners[event] = [func];
}
};
target.fireEvent = function(event, data) {
expect(target.on).toHaveBeenCalledWi... | javascript | function makeEventTarget(target) {
var listeners = {};
target.on = function(event, func) {
if (listeners[event]) {
listeners[event].push(func);
} else {
listeners[event] = [func];
}
};
target.fireEvent = function(event, data) {
expect(target.on).toHaveBeenCalledWi... | [
"function",
"makeEventTarget",
"(",
"target",
")",
"{",
"var",
"listeners",
"=",
"{",
"}",
";",
"target",
".",
"on",
"=",
"function",
"(",
"event",
",",
"func",
")",
"{",
"if",
"(",
"listeners",
"[",
"event",
"]",
")",
"{",
"listeners",
"[",
"event",... | Adds "on" listener that can register event listeners, which can later be fired through "fireEvent". It is expected that listeners will be regstered before events are fired. | [
"Adds",
"on",
"listener",
"that",
"can",
"register",
"event",
"listeners",
"which",
"can",
"later",
"be",
"fired",
"through",
"fireEvent",
".",
"It",
"is",
"expected",
"that",
"listeners",
"will",
"be",
"regstered",
"before",
"events",
"are",
"fired",
"."
] | 9638e840aec9598c4d60383ed22444c525aefbf5 | https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/spec/providers/transport/transport.webrtc.unit.spec.js#L35-L54 | train |
freedomjs/freedom | spec/providers/transport/transport.webrtc.unit.spec.js | function() {
var iface = testUtil.mockIface([
["setup", undefined],
["send", undefined],
["openDataChannel", undefined],
["close", undefined],
["getBufferedAmount", 0]
]);
peerconnection = iface();
makeEventTarget(peerconnection);
... | javascript | function() {
var iface = testUtil.mockIface([
["setup", undefined],
["send", undefined],
["openDataChannel", undefined],
["close", undefined],
["getBufferedAmount", 0]
]);
peerconnection = iface();
makeEventTarget(peerconnection);
... | [
"function",
"(",
")",
"{",
"var",
"iface",
"=",
"testUtil",
".",
"mockIface",
"(",
"[",
"[",
"\"setup\"",
",",
"undefined",
"]",
",",
"[",
"\"send\"",
",",
"undefined",
"]",
",",
"[",
"\"openDataChannel\"",
",",
"undefined",
"]",
",",
"[",
"\"close\"",
... | We can't use mockIface alone, we need to make peerconnection an event target. | [
"We",
"can",
"t",
"use",
"mockIface",
"alone",
"we",
"need",
"to",
"make",
"peerconnection",
"an",
"event",
"target",
"."
] | 9638e840aec9598c4d60383ed22444c525aefbf5 | https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/spec/providers/transport/transport.webrtc.unit.spec.js#L62-L73 | train | |
freedomjs/freedom | src/consumer.js | function (interfaceCls, debug) {
this.id = Consumer.nextId();
this.interfaceCls = interfaceCls;
this.debug = debug;
util.handleEvents(this);
this.ifaces = {};
this.closeHandlers = {};
this.errorHandlers = {};
this.emits = {};
} | javascript | function (interfaceCls, debug) {
this.id = Consumer.nextId();
this.interfaceCls = interfaceCls;
this.debug = debug;
util.handleEvents(this);
this.ifaces = {};
this.closeHandlers = {};
this.errorHandlers = {};
this.emits = {};
} | [
"function",
"(",
"interfaceCls",
",",
"debug",
")",
"{",
"this",
".",
"id",
"=",
"Consumer",
".",
"nextId",
"(",
")",
";",
"this",
".",
"interfaceCls",
"=",
"interfaceCls",
";",
"this",
".",
"debug",
"=",
"debug",
";",
"util",
".",
"handleEvents",
"(",... | A freedom port for a user-accessable api.
@class Consumer
@implements Port
@uses handleEvents
@param {Object} interfaceCls The api interface exposed by this consumer.
@param {Debug} debug The debugger to use for logging.
@constructor | [
"A",
"freedom",
"port",
"for",
"a",
"user",
"-",
"accessable",
"api",
"."
] | 9638e840aec9598c4d60383ed22444c525aefbf5 | https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/consumer.js#L14-L24 | train | |
jarradseers/consign | lib/consign.js | Consign | function Consign(options) {
options = options || {};
this._options = {
cwd: process.cwd(),
locale: 'en-us',
logger: console,
verbose: true,
extensions: [],
loggingType: 'info'
};
this._files = [];
this._object = {};
this._extensions = this._options.extensions.concat(['.js', '.json'... | javascript | function Consign(options) {
options = options || {};
this._options = {
cwd: process.cwd(),
locale: 'en-us',
logger: console,
verbose: true,
extensions: [],
loggingType: 'info'
};
this._files = [];
this._object = {};
this._extensions = this._options.extensions.concat(['.js', '.json'... | [
"function",
"Consign",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"_options",
"=",
"{",
"cwd",
":",
"process",
".",
"cwd",
"(",
")",
",",
"locale",
":",
"'en-us'",
",",
"logger",
":",
"console",
",",
"ver... | Consign constructor.
@param options
@returns | [
"Consign",
"constructor",
"."
] | 45c69476c421fde6f45e18221ade5d1755523483 | https://github.com/jarradseers/consign/blob/45c69476c421fde6f45e18221ade5d1755523483/lib/consign.js#L24-L54 | train |
vissense/vissense | lib/vissense.js | extend | function extend(dest, source, callback) {
var index = -1,
props = Object.keys(source),
length = props.length,
ask = isFunction(callback);
while (++index < length) {
var key = props[index];
dest[key] = ask ?
callback(dest[key], source[key], key, dest, source) : source[key];
}
return d... | javascript | function extend(dest, source, callback) {
var index = -1,
props = Object.keys(source),
length = props.length,
ask = isFunction(callback);
while (++index < length) {
var key = props[index];
dest[key] = ask ?
callback(dest[key], source[key], key, dest, source) : source[key];
}
return d... | [
"function",
"extend",
"(",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"props",
"=",
"Object",
".",
"keys",
"(",
"source",
")",
",",
"length",
"=",
"props",
".",
"length",
",",
"ask",
"=",
"isFunction",
"("... | This callback lets you intercept the assignment of
individual properties. The return value will be assigned
to the `destKey` property of the `dest` object.
If this callback is not provided `sourceValue` will be assigned.
@callback extendCallback
@memberof VisSense.Utils
@param {*} destValue The destination value that... | [
"This",
"callback",
"lets",
"you",
"intercept",
"the",
"assignment",
"of",
"individual",
"properties",
".",
"The",
"return",
"value",
"will",
"be",
"assigned",
"to",
"the",
"destKey",
"property",
"of",
"the",
"dest",
"object",
".",
"If",
"this",
"callback",
... | f169c9347dc98d3895de65fbb6bcd725351d6248 | https://github.com/vissense/vissense/blob/f169c9347dc98d3895de65fbb6bcd725351d6248/lib/vissense.js#L245-L258 | train |
wtfaremyinitials/osa-imessage | index.js | fromAppleTime | function fromAppleTime(ts) {
if (ts == 0) {
return null
}
// unpackTime returns 0 if the timestamp wasn't packed
// TODO: see `packTimeConditionally`'s comment
if (unpackTime(ts) != 0) {
ts = unpackTime(ts)
}
return new Date((ts + DATE_OFFSET) * 1000)
} | javascript | function fromAppleTime(ts) {
if (ts == 0) {
return null
}
// unpackTime returns 0 if the timestamp wasn't packed
// TODO: see `packTimeConditionally`'s comment
if (unpackTime(ts) != 0) {
ts = unpackTime(ts)
}
return new Date((ts + DATE_OFFSET) * 1000)
} | [
"function",
"fromAppleTime",
"(",
"ts",
")",
"{",
"if",
"(",
"ts",
"==",
"0",
")",
"{",
"return",
"null",
"}",
"// unpackTime returns 0 if the timestamp wasn't packed",
"// TODO: see `packTimeConditionally`'s comment",
"if",
"(",
"unpackTime",
"(",
"ts",
")",
"!=",
... | Transforms an Apple-style timestamp to a proper unix timestamp | [
"Transforms",
"an",
"Apple",
"-",
"style",
"timestamp",
"to",
"a",
"proper",
"unix",
"timestamp"
] | 6532d837524d86d6cabdb7d1ce75fc1fab462044 | https://github.com/wtfaremyinitials/osa-imessage/blob/6532d837524d86d6cabdb7d1ce75fc1fab462044/index.js#L44-L56 | train |
wtfaremyinitials/osa-imessage | index.js | handleForName | function handleForName(name) {
assert(typeof name == 'string', 'name must be a string')
return osa(name => {
const Messages = Application('Messages')
return Messages.buddies.whose({ name: name })[0].handle()
})(name)
} | javascript | function handleForName(name) {
assert(typeof name == 'string', 'name must be a string')
return osa(name => {
const Messages = Application('Messages')
return Messages.buddies.whose({ name: name })[0].handle()
})(name)
} | [
"function",
"handleForName",
"(",
"name",
")",
"{",
"assert",
"(",
"typeof",
"name",
"==",
"'string'",
",",
"'name must be a string'",
")",
"return",
"osa",
"(",
"name",
"=>",
"{",
"const",
"Messages",
"=",
"Application",
"(",
"'Messages'",
")",
"return",
"M... | Gets the proper handle string for a contact with the given name | [
"Gets",
"the",
"proper",
"handle",
"string",
"for",
"a",
"contact",
"with",
"the",
"given",
"name"
] | 6532d837524d86d6cabdb7d1ce75fc1fab462044 | https://github.com/wtfaremyinitials/osa-imessage/blob/6532d837524d86d6cabdb7d1ce75fc1fab462044/index.js#L76-L82 | train |
wtfaremyinitials/osa-imessage | index.js | send | function send(handle, message) {
assert(typeof handle == 'string', 'handle must be a string')
assert(typeof message == 'string', 'message must be a string')
return osa((handle, message) => {
const Messages = Application('Messages')
let target
try {
target = Messages.bud... | javascript | function send(handle, message) {
assert(typeof handle == 'string', 'handle must be a string')
assert(typeof message == 'string', 'message must be a string')
return osa((handle, message) => {
const Messages = Application('Messages')
let target
try {
target = Messages.bud... | [
"function",
"send",
"(",
"handle",
",",
"message",
")",
"{",
"assert",
"(",
"typeof",
"handle",
"==",
"'string'",
",",
"'handle must be a string'",
")",
"assert",
"(",
"typeof",
"message",
"==",
"'string'",
",",
"'message must be a string'",
")",
"return",
"osa"... | Sends a message to the given handle | [
"Sends",
"a",
"message",
"to",
"the",
"given",
"handle"
] | 6532d837524d86d6cabdb7d1ce75fc1fab462044 | https://github.com/wtfaremyinitials/osa-imessage/blob/6532d837524d86d6cabdb7d1ce75fc1fab462044/index.js#L95-L117 | train |
voilab/voilab-pdf-table | plugins/fitcolumn.js | function (table) {
table
.onBodyAdd(this.setWidth.bind(this))
.onColumnAdded(this.onColumnAdded.bind(this))
.onColumnPropertyChanged(this.onColumnPropertyChanged.bind(this));
} | javascript | function (table) {
table
.onBodyAdd(this.setWidth.bind(this))
.onColumnAdded(this.onColumnAdded.bind(this))
.onColumnPropertyChanged(this.onColumnPropertyChanged.bind(this));
} | [
"function",
"(",
"table",
")",
"{",
"table",
".",
"onBodyAdd",
"(",
"this",
".",
"setWidth",
".",
"bind",
"(",
"this",
")",
")",
".",
"onColumnAdded",
"(",
"this",
".",
"onColumnAdded",
".",
"bind",
"(",
"this",
")",
")",
".",
"onColumnPropertyChanged",
... | Configure plugin by attaching functions to table events
@param {PdfTable}
@return {void} | [
"Configure",
"plugin",
"by",
"attaching",
"functions",
"to",
"table",
"events"
] | 03ac40155d41d3f871d40ae2281a30c7eaf10392 | https://github.com/voilab/voilab-pdf-table/blob/03ac40155d41d3f871d40ae2281a30c7eaf10392/plugins/fitcolumn.js#L47-L52 | train | |
voilab/voilab-pdf-table | plugins/fitcolumn.js | function (table) {
if (!table.pdf.page) {
return;
}
if (this.calculatedWidth === null) {
var self = this,
content_width = this.maxWidth,
width = lodash.sumBy(table.getColumns(), function (column) {
return column.id !== s... | javascript | function (table) {
if (!table.pdf.page) {
return;
}
if (this.calculatedWidth === null) {
var self = this,
content_width = this.maxWidth,
width = lodash.sumBy(table.getColumns(), function (column) {
return column.id !== s... | [
"function",
"(",
"table",
")",
"{",
"if",
"(",
"!",
"table",
".",
"pdf",
".",
"page",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"calculatedWidth",
"===",
"null",
")",
"{",
"var",
"self",
"=",
"this",
",",
"content_width",
"=",
"this",
... | Check the max width of the stretched column. This method is called just
before we start to add data rows
@param {PdfTable} table
@return {void} | [
"Check",
"the",
"max",
"width",
"of",
"the",
"stretched",
"column",
".",
"This",
"method",
"is",
"called",
"just",
"before",
"we",
"start",
"to",
"add",
"data",
"rows"
] | 03ac40155d41d3f871d40ae2281a30c7eaf10392 | https://github.com/voilab/voilab-pdf-table/blob/03ac40155d41d3f871d40ae2281a30c7eaf10392/plugins/fitcolumn.js#L109-L132 | train | |
lokiuz/redraft | src/RawParser.js | createNodes | function createNodes(entityRanges, decoratorRanges = [], textArray, block) {
let lastIndex = 0;
const mergedRanges = [...entityRanges, ...decoratorRanges].sort((a, b) => a.offset - b.offset);
const nodes = [];
// if thers no entities will return just a single item
if (mergedRanges.length < 1) {
nodes.push... | javascript | function createNodes(entityRanges, decoratorRanges = [], textArray, block) {
let lastIndex = 0;
const mergedRanges = [...entityRanges, ...decoratorRanges].sort((a, b) => a.offset - b.offset);
const nodes = [];
// if thers no entities will return just a single item
if (mergedRanges.length < 1) {
nodes.push... | [
"function",
"createNodes",
"(",
"entityRanges",
",",
"decoratorRanges",
"=",
"[",
"]",
",",
"textArray",
",",
"block",
")",
"{",
"let",
"lastIndex",
"=",
"0",
";",
"const",
"mergedRanges",
"=",
"[",
"...",
"entityRanges",
",",
"...",
"decoratorRanges",
"]",
... | creates nodes with entity keys and the endOffset | [
"creates",
"nodes",
"with",
"entity",
"keys",
"and",
"the",
"endOffset"
] | f2c776e4277ee74b98311bba8dc9345a37e8e130 | https://github.com/lokiuz/redraft/blob/f2c776e4277ee74b98311bba8dc9345a37e8e130/src/RawParser.js#L12-L52 | train |
lokiuz/redraft | src/RawParser.js | getRelevantIndexes | function getRelevantIndexes(text, inlineRanges, entityRanges = [], decoratorRanges = []) {
let relevantIndexes = [];
// set indexes to corresponding keys to ensure uniquenes
relevantIndexes = addIndexes(relevantIndexes, inlineRanges);
relevantIndexes = addIndexes(relevantIndexes, entityRanges);
relevantIndexe... | javascript | function getRelevantIndexes(text, inlineRanges, entityRanges = [], decoratorRanges = []) {
let relevantIndexes = [];
// set indexes to corresponding keys to ensure uniquenes
relevantIndexes = addIndexes(relevantIndexes, inlineRanges);
relevantIndexes = addIndexes(relevantIndexes, entityRanges);
relevantIndexe... | [
"function",
"getRelevantIndexes",
"(",
"text",
",",
"inlineRanges",
",",
"entityRanges",
"=",
"[",
"]",
",",
"decoratorRanges",
"=",
"[",
"]",
")",
"{",
"let",
"relevantIndexes",
"=",
"[",
"]",
";",
"// set indexes to corresponding keys to ensure uniquenes",
"releva... | Creates an array of sorted char indexes to avoid iterating over every single character | [
"Creates",
"an",
"array",
"of",
"sorted",
"char",
"indexes",
"to",
"avoid",
"iterating",
"over",
"every",
"single",
"character"
] | f2c776e4277ee74b98311bba8dc9345a37e8e130 | https://github.com/lokiuz/redraft/blob/f2c776e4277ee74b98311bba8dc9345a37e8e130/src/RawParser.js#L65-L79 | train |
lo-th/uil | build/uil.module.js | function ( type, css, obj, dom, id ) {
return Tools.dom( type, css, obj, dom, id );
} | javascript | function ( type, css, obj, dom, id ) {
return Tools.dom( type, css, obj, dom, id );
} | [
"function",
"(",
"type",
",",
"css",
",",
"obj",
",",
"dom",
",",
"id",
")",
"{",
"return",
"Tools",
".",
"dom",
"(",
"type",
",",
"css",
",",
"obj",
",",
"dom",
",",
"id",
")",
";",
"}"
] | TRANS FUNCTIONS from Tools | [
"TRANS",
"FUNCTIONS",
"from",
"Tools"
] | 92d3b3e0181acd6549976f71fb4ff44a0258b57e | https://github.com/lo-th/uil/blob/92d3b3e0181acd6549976f71fb4ff44a0258b57e/build/uil.module.js#L1509-L1513 | train | |
lo-th/uil | build/uil.module.js | function ( n ) {
var i = this.uis.indexOf( n );
if ( i !== -1 ) {
this.inner.removeChild( this.uis[i].c[0] );
this.uis.splice( i, 1 );
}
} | javascript | function ( n ) {
var i = this.uis.indexOf( n );
if ( i !== -1 ) {
this.inner.removeChild( this.uis[i].c[0] );
this.uis.splice( i, 1 );
}
} | [
"function",
"(",
"n",
")",
"{",
"var",
"i",
"=",
"this",
".",
"uis",
".",
"indexOf",
"(",
"n",
")",
";",
"if",
"(",
"i",
"!==",
"-",
"1",
")",
"{",
"this",
".",
"inner",
".",
"removeChild",
"(",
"this",
".",
"uis",
"[",
"i",
"]",
".",
"c",
... | call after uis clear | [
"call",
"after",
"uis",
"clear"
] | 92d3b3e0181acd6549976f71fb4ff44a0258b57e | https://github.com/lo-th/uil/blob/92d3b3e0181acd6549976f71fb4ff44a0258b57e/build/uil.module.js#L5652-L5660 | train | |
lo-th/uil | _OLD/uil-1.0/build/uil.module.js | function( canvas, content, w, h ){
var ctx = canvas.getContext("2d");
var dcopy = null;
if( typeof content === 'string' ){
dcopy = Tools.dom( 'iframe', 'position:abolute; left:0; top:0; width:'+w+'px; height:'+h+'px;' );
dcopy.src = content;
}else{
... | javascript | function( canvas, content, w, h ){
var ctx = canvas.getContext("2d");
var dcopy = null;
if( typeof content === 'string' ){
dcopy = Tools.dom( 'iframe', 'position:abolute; left:0; top:0; width:'+w+'px; height:'+h+'px;' );
dcopy.src = content;
}else{
... | [
"function",
"(",
"canvas",
",",
"content",
",",
"w",
",",
"h",
")",
"{",
"var",
"ctx",
"=",
"canvas",
".",
"getContext",
"(",
"\"2d\"",
")",
";",
"var",
"dcopy",
"=",
"null",
";",
"if",
"(",
"typeof",
"content",
"===",
"'string'",
")",
"{",
"dcopy"... | svg to canvas test | [
"svg",
"to",
"canvas",
"test"
] | 92d3b3e0181acd6549976f71fb4ff44a0258b57e | https://github.com/lo-th/uil/blob/92d3b3e0181acd6549976f71fb4ff44a0258b57e/_OLD/uil-1.0/build/uil.module.js#L423-L484 | train | |
jakiestfu/himawari.js | index.js | resolveDate | function resolveDate (base_url, input, callback) {
var date = input;
// If provided a date string
if ((typeof input == "string" || typeof input == "number") && input !== "latest") {
date = new Date(input);
}
// If provided a date object
if (moment.isDate(date)) { return callback(null, date); }
// ... | javascript | function resolveDate (base_url, input, callback) {
var date = input;
// If provided a date string
if ((typeof input == "string" || typeof input == "number") && input !== "latest") {
date = new Date(input);
}
// If provided a date object
if (moment.isDate(date)) { return callback(null, date); }
// ... | [
"function",
"resolveDate",
"(",
"base_url",
",",
"input",
",",
"callback",
")",
"{",
"var",
"date",
"=",
"input",
";",
"// If provided a date string",
"if",
"(",
"(",
"typeof",
"input",
"==",
"\"string\"",
"||",
"typeof",
"input",
"==",
"\"number\"",
")",
"&... | Takes an input, either a date object, a date timestamp, or the string "latest"
and resolves to a native Date object.
@param {String|Date} input The incoming date or the string "latest"
@param {Function} callback The function to be called when date is resolved | [
"Takes",
"an",
"input",
"either",
"a",
"date",
"object",
"a",
"date",
"timestamp",
"or",
"the",
"string",
"latest",
"and",
"resolves",
"to",
"a",
"native",
"Date",
"object",
"."
] | d83797be23181906367b82875f43eef8d94da479 | https://github.com/jakiestfu/himawari.js/blob/d83797be23181906367b82875f43eef8d94da479/index.js#L237-L266 | train |
filamentgroup/Ajax-Include-Pattern | libs/shoestring-dev.js | recordProxy | function recordProxy( old, name ) {
return function() {
var tracked;
try {
tracked = JSON.parse(window.localStorage.getItem( shoestring.trackedMethodsKey ) || "{}");
} catch (e) {
if( e instanceof SyntaxError) {
tracked = {};
}
}
tracked[ name ] = true;
window.localStora... | javascript | function recordProxy( old, name ) {
return function() {
var tracked;
try {
tracked = JSON.parse(window.localStorage.getItem( shoestring.trackedMethodsKey ) || "{}");
} catch (e) {
if( e instanceof SyntaxError) {
tracked = {};
}
}
tracked[ name ] = true;
window.localStora... | [
"function",
"recordProxy",
"(",
"old",
",",
"name",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"tracked",
";",
"try",
"{",
"tracked",
"=",
"JSON",
".",
"parse",
"(",
"window",
".",
"localStorage",
".",
"getItem",
"(",
"shoestring",
".",
"tra... | return a new function closed over the old implementation | [
"return",
"a",
"new",
"function",
"closed",
"over",
"the",
"old",
"implementation"
] | ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe | https://github.com/filamentgroup/Ajax-Include-Pattern/blob/ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe/libs/shoestring-dev.js#L2356-L2372 | train |
filamentgroup/Ajax-Include-Pattern | dist/ajaxInclude.js | function( url, els, isHijax ) {
$.get( url, function( data, status, xhr ) {
els.trigger( "ajaxIncludeResponse", [ data, xhr ] );
});
} | javascript | function( url, els, isHijax ) {
$.get( url, function( data, status, xhr ) {
els.trigger( "ajaxIncludeResponse", [ data, xhr ] );
});
} | [
"function",
"(",
"url",
",",
"els",
",",
"isHijax",
")",
"{",
"$",
".",
"get",
"(",
"url",
",",
"function",
"(",
"data",
",",
"status",
",",
"xhr",
")",
"{",
"els",
".",
"trigger",
"(",
"\"ajaxIncludeResponse\"",
",",
"[",
"data",
",",
"xhr",
"]",
... | request a url and trigger ajaxInclude on elements upon response | [
"request",
"a",
"url",
"and",
"trigger",
"ajaxInclude",
"on",
"elements",
"upon",
"response"
] | ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe | https://github.com/filamentgroup/Ajax-Include-Pattern/blob/ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe/dist/ajaxInclude.js#L11-L15 | train | |
filamentgroup/Ajax-Include-Pattern | dist/ajaxInclude.js | queueOrRequest | function queueOrRequest( el ){
var url = el.data( "url" );
if( o.proxy && $.inArray( url, urllist ) === -1 ){
urllist.push( url );
elQueue = elQueue.add( el );
}
else{
AI.makeReq( url, el );
}
} | javascript | function queueOrRequest( el ){
var url = el.data( "url" );
if( o.proxy && $.inArray( url, urllist ) === -1 ){
urllist.push( url );
elQueue = elQueue.add( el );
}
else{
AI.makeReq( url, el );
}
} | [
"function",
"queueOrRequest",
"(",
"el",
")",
"{",
"var",
"url",
"=",
"el",
".",
"data",
"(",
"\"url\"",
")",
";",
"if",
"(",
"o",
".",
"proxy",
"&&",
"$",
".",
"inArray",
"(",
"url",
",",
"urllist",
")",
"===",
"-",
"1",
")",
"{",
"urllist",
"... | if it's a proxy, queue the element and its url, if not, request immediately | [
"if",
"it",
"s",
"a",
"proxy",
"queue",
"the",
"element",
"and",
"its",
"url",
"if",
"not",
"request",
"immediately"
] | ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe | https://github.com/filamentgroup/Ajax-Include-Pattern/blob/ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe/dist/ajaxInclude.js#L36-L45 | train |
filamentgroup/Ajax-Include-Pattern | dist/ajaxInclude.js | runQueue | function runQueue(){
if( urllist.length ){
AI.makeReq( o.proxy + urllist.join( "," ), elQueue );
elQueue = $();
urllist = [];
}
} | javascript | function runQueue(){
if( urllist.length ){
AI.makeReq( o.proxy + urllist.join( "," ), elQueue );
elQueue = $();
urllist = [];
}
} | [
"function",
"runQueue",
"(",
")",
"{",
"if",
"(",
"urllist",
".",
"length",
")",
"{",
"AI",
".",
"makeReq",
"(",
"o",
".",
"proxy",
"+",
"urllist",
".",
"join",
"(",
"\",\"",
")",
",",
"elQueue",
")",
";",
"elQueue",
"=",
"$",
"(",
")",
";",
"u... | if there's a url queue | [
"if",
"there",
"s",
"a",
"url",
"queue"
] | ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe | https://github.com/filamentgroup/Ajax-Include-Pattern/blob/ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe/dist/ajaxInclude.js#L48-L54 | train |
filamentgroup/Ajax-Include-Pattern | dist/ajaxInclude.js | bindForLater | function bindForLater( el, media ){
var mm = win.matchMedia( media );
function cb(){
queueOrRequest( el );
runQueue();
mm.removeListener( cb );
}
if( mm.addListener ){
mm.addListener( cb );
}
} | javascript | function bindForLater( el, media ){
var mm = win.matchMedia( media );
function cb(){
queueOrRequest( el );
runQueue();
mm.removeListener( cb );
}
if( mm.addListener ){
mm.addListener( cb );
}
} | [
"function",
"bindForLater",
"(",
"el",
",",
"media",
")",
"{",
"var",
"mm",
"=",
"win",
".",
"matchMedia",
"(",
"media",
")",
";",
"function",
"cb",
"(",
")",
"{",
"queueOrRequest",
"(",
"el",
")",
";",
"runQueue",
"(",
")",
";",
"mm",
".",
"remove... | bind a listener to a currently-inapplicable media query for potential later changes | [
"bind",
"a",
"listener",
"to",
"a",
"currently",
"-",
"inapplicable",
"media",
"query",
"for",
"potential",
"later",
"changes"
] | ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe | https://github.com/filamentgroup/Ajax-Include-Pattern/blob/ab3f2aff182f7c9c73227fbdadd28c4f3bc02ffe/dist/ajaxInclude.js#L57-L67 | train |
bzarras/newsapi | src/index.js | splitArgsIntoOptionsAndCallback | function splitArgsIntoOptionsAndCallback (args) {
let params;
let options;
let cb;
if (args.length > 1) {
const possibleCb = args[args.length - 1];
if ('function' === typeof possibleCb) {
cb = possibleCb;
options = args.length === 3 ? args[1] : undefined;
} else {
options = args[1]... | javascript | function splitArgsIntoOptionsAndCallback (args) {
let params;
let options;
let cb;
if (args.length > 1) {
const possibleCb = args[args.length - 1];
if ('function' === typeof possibleCb) {
cb = possibleCb;
options = args.length === 3 ? args[1] : undefined;
} else {
options = args[1]... | [
"function",
"splitArgsIntoOptionsAndCallback",
"(",
"args",
")",
"{",
"let",
"params",
";",
"let",
"options",
";",
"let",
"cb",
";",
"if",
"(",
"args",
".",
"length",
">",
"1",
")",
"{",
"const",
"possibleCb",
"=",
"args",
"[",
"args",
".",
"length",
"... | Takes a variable-length array that represents arguments to a function and attempts to split it into
an 'options' object and a 'cb' callback function.
@param {Array} args The arguments to the function
@return {Object} | [
"Takes",
"a",
"variable",
"-",
"length",
"array",
"that",
"represents",
"arguments",
"to",
"a",
"function",
"and",
"attempts",
"to",
"split",
"it",
"into",
"an",
"options",
"object",
"and",
"a",
"cb",
"callback",
"function",
"."
] | fd6fd40e5d3d5625d68ba004f7b19680598bb881 | https://github.com/bzarras/newsapi/blob/fd6fd40e5d3d5625d68ba004f7b19680598bb881/src/index.js#L71-L90 | train |
bzarras/newsapi | src/index.js | createUrlFromEndpointAndOptions | function createUrlFromEndpointAndOptions (endpoint, options) {
const query = qs.stringify(options);
const baseURL = `${host}${endpoint}`;
return query ? `${baseURL}?${query}` : baseURL;
} | javascript | function createUrlFromEndpointAndOptions (endpoint, options) {
const query = qs.stringify(options);
const baseURL = `${host}${endpoint}`;
return query ? `${baseURL}?${query}` : baseURL;
} | [
"function",
"createUrlFromEndpointAndOptions",
"(",
"endpoint",
",",
"options",
")",
"{",
"const",
"query",
"=",
"qs",
".",
"stringify",
"(",
"options",
")",
";",
"const",
"baseURL",
"=",
"`",
"${",
"host",
"}",
"${",
"endpoint",
"}",
"`",
";",
"return",
... | Creates a url string from an endpoint and an options object by appending the endpoint
to the global "host" const and appending the options as querystring parameters.
@param {String} endpoint
@param {Object} [options]
@return {String} | [
"Creates",
"a",
"url",
"string",
"from",
"an",
"endpoint",
"and",
"an",
"options",
"object",
"by",
"appending",
"the",
"endpoint",
"to",
"the",
"global",
"host",
"const",
"and",
"appending",
"the",
"options",
"as",
"querystring",
"parameters",
"."
] | fd6fd40e5d3d5625d68ba004f7b19680598bb881 | https://github.com/bzarras/newsapi/blob/fd6fd40e5d3d5625d68ba004f7b19680598bb881/src/index.js#L99-L103 | train |
bzarras/newsapi | src/index.js | getDataFromWeb | function getDataFromWeb(url, options, apiKey, cb) {
let useCallback = 'function' === typeof cb;
const reqOptions = { headers: {} };
if (apiKey) {
reqOptions.headers['X-Api-Key'] = apiKey;
}
if (options && options.noCache === true) {
reqOptions.headers['X-No-Cache'] = 'true';
}
return fetch(url, re... | javascript | function getDataFromWeb(url, options, apiKey, cb) {
let useCallback = 'function' === typeof cb;
const reqOptions = { headers: {} };
if (apiKey) {
reqOptions.headers['X-Api-Key'] = apiKey;
}
if (options && options.noCache === true) {
reqOptions.headers['X-No-Cache'] = 'true';
}
return fetch(url, re... | [
"function",
"getDataFromWeb",
"(",
"url",
",",
"options",
",",
"apiKey",
",",
"cb",
")",
"{",
"let",
"useCallback",
"=",
"'function'",
"===",
"typeof",
"cb",
";",
"const",
"reqOptions",
"=",
"{",
"headers",
":",
"{",
"}",
"}",
";",
"if",
"(",
"apiKey",... | Takes a URL string and returns a Promise containing
a buffer with the data from the web.
@param {String} url A URL String
@param {String} apiKey (Optional) A key to be used for authentication
@return {Promise<Buffer>} A Promise containing a Buffer | [
"Takes",
"a",
"URL",
"string",
"and",
"returns",
"a",
"Promise",
"containing",
"a",
"buffer",
"with",
"the",
"data",
"from",
"the",
"web",
"."
] | fd6fd40e5d3d5625d68ba004f7b19680598bb881 | https://github.com/bzarras/newsapi/blob/fd6fd40e5d3d5625d68ba004f7b19680598bb881/src/index.js#L112-L135 | train |
Shopify/graphql-to-js-client-builder | src/sort-definitions.js | visitFragment | function visitFragment(fragment, fragments, fragmentsHash) {
if (fragment.marked) {
throw Error('Fragments cannot contain a cycle');
}
if (!fragment.visited) {
fragment.marked = true;
// Visit every spread in this fragment definition
visit(fragment, {
FragmentSpread(node) {
// Visit ... | javascript | function visitFragment(fragment, fragments, fragmentsHash) {
if (fragment.marked) {
throw Error('Fragments cannot contain a cycle');
}
if (!fragment.visited) {
fragment.marked = true;
// Visit every spread in this fragment definition
visit(fragment, {
FragmentSpread(node) {
// Visit ... | [
"function",
"visitFragment",
"(",
"fragment",
",",
"fragments",
",",
"fragmentsHash",
")",
"{",
"if",
"(",
"fragment",
".",
"marked",
")",
"{",
"throw",
"Error",
"(",
"'Fragments cannot contain a cycle'",
")",
";",
"}",
"if",
"(",
"!",
"fragment",
".",
"visi... | Recursive helper function for sortDefinitions | [
"Recursive",
"helper",
"function",
"for",
"sortDefinitions"
] | b23829fc52c69916b4e9728062d6e6b25ea53b79 | https://github.com/Shopify/graphql-to-js-client-builder/blob/b23829fc52c69916b4e9728062d6e6b25ea53b79/src/sort-definitions.js#L4-L21 | train |
rguerreiro/express-device | lib/device.js | customCheck | function customCheck(req, mydevice) {
var useragent = req.headers['user-agent'];
if (!useragent || useragent === '') {
if (req.headers['cloudfront-is-mobile-viewer'] === 'true') return 'phone';
if (req.headers['cloudfront-is-tablet-viewer'] === 'true') return 'tablet';
if (req.hea... | javascript | function customCheck(req, mydevice) {
var useragent = req.headers['user-agent'];
if (!useragent || useragent === '') {
if (req.headers['cloudfront-is-mobile-viewer'] === 'true') return 'phone';
if (req.headers['cloudfront-is-tablet-viewer'] === 'true') return 'tablet';
if (req.hea... | [
"function",
"customCheck",
"(",
"req",
",",
"mydevice",
")",
"{",
"var",
"useragent",
"=",
"req",
".",
"headers",
"[",
"'user-agent'",
"]",
";",
"if",
"(",
"!",
"useragent",
"||",
"useragent",
"===",
"''",
")",
"{",
"if",
"(",
"req",
".",
"headers",
... | should this be on 'device' instead? | [
"should",
"this",
"be",
"on",
"device",
"instead?"
] | 621ac384754de7a3d97e0c10a1a9e495da408ddf | https://github.com/rguerreiro/express-device/blob/621ac384754de7a3d97e0c10a1a9e495da408ddf/lib/device.js#L21-L33 | train |
AssemblyScript/prototype | bin/asc.js | writeText | function writeText(wasmModule, format, output, callback) {
if (format === "linear" || format === "stack") {
if (!assemblyscript.util.wabt) {
process.stderr.write("\nwabt.js not found\n");
return callback(EFAILURE);
}
var binary = wasmModule.ascCurrentBinary || (wasmModule.ascCurrentBinary = wa... | javascript | function writeText(wasmModule, format, output, callback) {
if (format === "linear" || format === "stack") {
if (!assemblyscript.util.wabt) {
process.stderr.write("\nwabt.js not found\n");
return callback(EFAILURE);
}
var binary = wasmModule.ascCurrentBinary || (wasmModule.ascCurrentBinary = wa... | [
"function",
"writeText",
"(",
"wasmModule",
",",
"format",
",",
"output",
",",
"callback",
")",
"{",
"if",
"(",
"format",
"===",
"\"linear\"",
"||",
"format",
"===",
"\"stack\"",
")",
"{",
"if",
"(",
"!",
"assemblyscript",
".",
"util",
".",
"wabt",
")",
... | Writes text format of the specified module, using the specified format. | [
"Writes",
"text",
"format",
"of",
"the",
"specified",
"module",
"using",
"the",
"specified",
"format",
"."
] | a44bf654dda58f8bdd782e6ff170ccc6f0de92a8 | https://github.com/AssemblyScript/prototype/blob/a44bf654dda58f8bdd782e6ff170ccc6f0de92a8/bin/asc.js#L188-L203 | train |
AssemblyScript/prototype | bin/asc.js | writeBinary | function writeBinary(wasmModule, output, callback) {
output.write(Buffer.from(wasmModule.emitBinary()), end);
function end(err) {
if (err || output === process.stdout) return callback(err);
output.end(callback);
}
} | javascript | function writeBinary(wasmModule, output, callback) {
output.write(Buffer.from(wasmModule.emitBinary()), end);
function end(err) {
if (err || output === process.stdout) return callback(err);
output.end(callback);
}
} | [
"function",
"writeBinary",
"(",
"wasmModule",
",",
"output",
",",
"callback",
")",
"{",
"output",
".",
"write",
"(",
"Buffer",
".",
"from",
"(",
"wasmModule",
".",
"emitBinary",
"(",
")",
")",
",",
"end",
")",
";",
"function",
"end",
"(",
"err",
")",
... | Writes a binary of the specified module. | [
"Writes",
"a",
"binary",
"of",
"the",
"specified",
"module",
"."
] | a44bf654dda58f8bdd782e6ff170ccc6f0de92a8 | https://github.com/AssemblyScript/prototype/blob/a44bf654dda58f8bdd782e6ff170ccc6f0de92a8/bin/asc.js#L208-L215 | train |
AssemblyScript/prototype | bin/asc.js | writeAsmjs | function writeAsmjs(wasmModule, output, callback) {
output.write(Buffer.from(wasmModule.emitAsmjs()), end);
function end(err) {
if (err || output === process.stdout) return callback(err);
output.end(callback);
}
} | javascript | function writeAsmjs(wasmModule, output, callback) {
output.write(Buffer.from(wasmModule.emitAsmjs()), end);
function end(err) {
if (err || output === process.stdout) return callback(err);
output.end(callback);
}
} | [
"function",
"writeAsmjs",
"(",
"wasmModule",
",",
"output",
",",
"callback",
")",
"{",
"output",
".",
"write",
"(",
"Buffer",
".",
"from",
"(",
"wasmModule",
".",
"emitAsmjs",
"(",
")",
")",
",",
"end",
")",
";",
"function",
"end",
"(",
"err",
")",
"... | Writes the asm.js representation of the specified module. | [
"Writes",
"the",
"asm",
".",
"js",
"representation",
"of",
"the",
"specified",
"module",
"."
] | a44bf654dda58f8bdd782e6ff170ccc6f0de92a8 | https://github.com/AssemblyScript/prototype/blob/a44bf654dda58f8bdd782e6ff170ccc6f0de92a8/bin/asc.js#L218-L225 | train |
spirit/spirit | src/loadAnimation.js | createFromData | function createFromData(data, container) {
if (data === undefined) {
return Promise.resolve([])
}
if (!(isObject(data) || Array.isArray(data))) {
return Promise.reject(new Error('Invalid animation data'))
}
return Promise.resolve(create(data, container))
} | javascript | function createFromData(data, container) {
if (data === undefined) {
return Promise.resolve([])
}
if (!(isObject(data) || Array.isArray(data))) {
return Promise.reject(new Error('Invalid animation data'))
}
return Promise.resolve(create(data, container))
} | [
"function",
"createFromData",
"(",
"data",
",",
"container",
")",
"{",
"if",
"(",
"data",
"===",
"undefined",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"[",
"]",
")",
"}",
"if",
"(",
"!",
"(",
"isObject",
"(",
"data",
")",
"||",
"Array",
... | Create from data
@param {object|Array} data
@param {Element} container
@return {Promise<Array|object>} | [
"Create",
"from",
"data"
] | 7403dfdba99dca7c03b149d4a830fadff80c3769 | https://github.com/spirit/spirit/blob/7403dfdba99dca7c03b149d4a830fadff80c3769/src/loadAnimation.js#L22-L31 | train |
spirit/spirit | src/loadAnimation.js | loadFromPath | function loadFromPath(path, container) {
if (path && typeof path === 'string' && path.length > 0) {
return load(path, container)
}
return Promise.resolve([])
} | javascript | function loadFromPath(path, container) {
if (path && typeof path === 'string' && path.length > 0) {
return load(path, container)
}
return Promise.resolve([])
} | [
"function",
"loadFromPath",
"(",
"path",
",",
"container",
")",
"{",
"if",
"(",
"path",
"&&",
"typeof",
"path",
"===",
"'string'",
"&&",
"path",
".",
"length",
">",
"0",
")",
"{",
"return",
"load",
"(",
"path",
",",
"container",
")",
"}",
"return",
"... | Load from path
@param {string} path
@param {Element} container
@return {Promise<Array|object>} | [
"Load",
"from",
"path"
] | 7403dfdba99dca7c03b149d4a830fadff80c3769 | https://github.com/spirit/spirit/blob/7403dfdba99dca7c03b149d4a830fadff80c3769/src/loadAnimation.js#L40-L45 | train |
spirit/spirit | src/data/parser.js | groupsFactory | function groupsFactory() {
let list = []
const getGroupsByRoot = function(root) {
for (let i = 0; i < list.length; i++) {
let groups = list[i]
if (groups.rootEl === root) {
return groups
}
}
return null
}
return {
add: function(root, group) {
let groups = getGro... | javascript | function groupsFactory() {
let list = []
const getGroupsByRoot = function(root) {
for (let i = 0; i < list.length; i++) {
let groups = list[i]
if (groups.rootEl === root) {
return groups
}
}
return null
}
return {
add: function(root, group) {
let groups = getGro... | [
"function",
"groupsFactory",
"(",
")",
"{",
"let",
"list",
"=",
"[",
"]",
"const",
"getGroupsByRoot",
"=",
"function",
"(",
"root",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"let",... | Create groups factory
@return {{add: {function} add, groups: {array|Groups} groups}} | [
"Create",
"groups",
"factory"
] | 7403dfdba99dca7c03b149d4a830fadff80c3769 | https://github.com/spirit/spirit/blob/7403dfdba99dca7c03b149d4a830fadff80c3769/src/data/parser.js#L9-L40 | train |
browserify/common-shakeify | index.js | isUsed | function isUsed (name) {
if (module.isUsed(name)) {
return true
}
if (dupes.length > 0) {
return dupes.some((dupe) => {
const m = analyzer.modules.get(dupe.file)
return m && m.isUsed(name)
})
}
return false
} | javascript | function isUsed (name) {
if (module.isUsed(name)) {
return true
}
if (dupes.length > 0) {
return dupes.some((dupe) => {
const m = analyzer.modules.get(dupe.file)
return m && m.isUsed(name)
})
}
return false
} | [
"function",
"isUsed",
"(",
"name",
")",
"{",
"if",
"(",
"module",
".",
"isUsed",
"(",
"name",
")",
")",
"{",
"return",
"true",
"}",
"if",
"(",
"dupes",
".",
"length",
">",
"0",
")",
"{",
"return",
"dupes",
".",
"some",
"(",
"(",
"dupe",
")",
"=... | Check if a name was used in this module, or in any of this module's deduped versions. | [
"Check",
"if",
"a",
"name",
"was",
"used",
"in",
"this",
"module",
"or",
"in",
"any",
"of",
"this",
"module",
"s",
"deduped",
"versions",
"."
] | 1325412e3480b49cbfee4e0931a7fbf14d9e9beb | https://github.com/browserify/common-shakeify/blob/1325412e3480b49cbfee4e0931a7fbf14d9e9beb/index.js#L156-L167 | train |
rexxars/sse-channel | lib/sse-channel.js | function(options) {
var opts = options || {};
if (opts.cors !== false) {
this.cors = access(merge({
origins: [],
methods: ['GET', 'HEAD', 'OPTIONS'],
headers: ['Last-Event-ID']
}, opts.cors || {}));
}
var jsonEncode = (
typeof opts.jsonEncode ... | javascript | function(options) {
var opts = options || {};
if (opts.cors !== false) {
this.cors = access(merge({
origins: [],
methods: ['GET', 'HEAD', 'OPTIONS'],
headers: ['Last-Event-ID']
}, opts.cors || {}));
}
var jsonEncode = (
typeof opts.jsonEncode ... | [
"function",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"opts",
".",
"cors",
"!==",
"false",
")",
"{",
"this",
".",
"cors",
"=",
"access",
"(",
"merge",
"(",
"{",
"origins",
":",
"[",
"]",
",",
"meth... | Server-Sent Events "Channel"
The "channel"-concept is simply a collection of clients which should receive the same messages.
This is useful if you want to have one server which can easily handle different sources and
clients. History is automatically handled for you, as long as each event is accompanied by
a numeric I... | [
"Server",
"-",
"Sent",
"Events",
"Channel"
] | dc7c42e3c402cb59db256fbcfd5a17775197cede | https://github.com/rexxars/sse-channel/blob/dc7c42e3c402cb59db256fbcfd5a17775197cede/lib/sse-channel.js#L38-L77 | train | |
rexxars/sse-channel | lib/sse-channel.js | initializeConnection | function initializeConnection(opts) {
opts.request.socket.setTimeout(0);
opts.request.socket.setNoDelay(true);
opts.request.socket.setKeepAlive(true);
opts.response.writeHead(200, {
'Content-Type': 'text/event-stream;charset=UTF-8',
'Cache-Control': 'no-cache',
'Connection': 'kee... | javascript | function initializeConnection(opts) {
opts.request.socket.setTimeout(0);
opts.request.socket.setNoDelay(true);
opts.request.socket.setKeepAlive(true);
opts.response.writeHead(200, {
'Content-Type': 'text/event-stream;charset=UTF-8',
'Cache-Control': 'no-cache',
'Connection': 'kee... | [
"function",
"initializeConnection",
"(",
"opts",
")",
"{",
"opts",
".",
"request",
".",
"socket",
".",
"setTimeout",
"(",
"0",
")",
";",
"opts",
".",
"request",
".",
"socket",
".",
"setNoDelay",
"(",
"true",
")",
";",
"opts",
".",
"request",
".",
"sock... | Sends the initial, required headers for the connection
@param {Object} opts Options object
@param {Request} opts.request Request object to use
@param {Response} opts.response Response object to use
@param {Number} opts.retry Time in milliseconds to specify as reconnection timeout
@param {Boolean}... | [
"Sends",
"the",
"initial",
"required",
"headers",
"for",
"the",
"connection"
] | dc7c42e3c402cb59db256fbcfd5a17775197cede | https://github.com/rexxars/sse-channel/blob/dc7c42e3c402cb59db256fbcfd5a17775197cede/lib/sse-channel.js#L265-L290 | train |
rexxars/sse-channel | lib/sse-channel.js | broadcast | function broadcast(connections, packet) {
var i = connections.length;
while (i--) {
connections[i].write(packet);
flush(connections[i]);
}
} | javascript | function broadcast(connections, packet) {
var i = connections.length;
while (i--) {
connections[i].write(packet);
flush(connections[i]);
}
} | [
"function",
"broadcast",
"(",
"connections",
",",
"packet",
")",
"{",
"var",
"i",
"=",
"connections",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"connections",
"[",
"i",
"]",
".",
"write",
"(",
"packet",
")",
";",
"flush",
"(",
"connectio... | Broadcast a packet to all connected clients
@param {Array} connections Array of connections (response instances) to write to
@param {String} packet The chunk of data to broadcast | [
"Broadcast",
"a",
"packet",
"to",
"all",
"connected",
"clients"
] | dc7c42e3c402cb59db256fbcfd5a17775197cede | https://github.com/rexxars/sse-channel/blob/dc7c42e3c402cb59db256fbcfd5a17775197cede/lib/sse-channel.js#L298-L304 | train |
rexxars/sse-channel | lib/sse-channel.js | parseTextData | function parseTextData(text) {
var data = String(text).replace(/(\r\n|\r|\n)/g, '\n');
var lines = data.split(/\n/), line;
var output = '';
for (var i = 0, l = lines.length; i < l; ++i) {
line = lines[i];
output += 'data: ' + line;
output += (i + 1) === l ? '\n\n' : '\n';
}... | javascript | function parseTextData(text) {
var data = String(text).replace(/(\r\n|\r|\n)/g, '\n');
var lines = data.split(/\n/), line;
var output = '';
for (var i = 0, l = lines.length; i < l; ++i) {
line = lines[i];
output += 'data: ' + line;
output += (i + 1) === l ? '\n\n' : '\n';
}... | [
"function",
"parseTextData",
"(",
"text",
")",
"{",
"var",
"data",
"=",
"String",
"(",
"text",
")",
".",
"replace",
"(",
"/",
"(\\r\\n|\\r|\\n)",
"/",
"g",
",",
"'\\n'",
")",
";",
"var",
"lines",
"=",
"data",
".",
"split",
"(",
"/",
"\\n",
"/",
")"... | Parse text data, ensuring it doesn't break the SSE-protocol
@param {String} text
@return {String} | [
"Parse",
"text",
"data",
"ensuring",
"it",
"doesn",
"t",
"break",
"the",
"SSE",
"-",
"protocol"
] | dc7c42e3c402cb59db256fbcfd5a17775197cede | https://github.com/rexxars/sse-channel/blob/dc7c42e3c402cb59db256fbcfd5a17775197cede/lib/sse-channel.js#L365-L378 | train |
rexxars/sse-channel | examples/client/client-example.js | drawChart | function drawChart(canvas, data) {
var ctx = canvas.getContext('2d'),
color = 'rgba(0, 0, 0, 0.75)',
height = canvas.height - 2,
width = canvas.width,
total = data.length,
max = Math.max.apply(Math, data),
xstep = 1,
ystep = max... | javascript | function drawChart(canvas, data) {
var ctx = canvas.getContext('2d'),
color = 'rgba(0, 0, 0, 0.75)',
height = canvas.height - 2,
width = canvas.width,
total = data.length,
max = Math.max.apply(Math, data),
xstep = 1,
ystep = max... | [
"function",
"drawChart",
"(",
"canvas",
",",
"data",
")",
"{",
"var",
"ctx",
"=",
"canvas",
".",
"getContext",
"(",
"'2d'",
")",
",",
"color",
"=",
"'rgba(0, 0, 0, 0.75)'",
",",
"height",
"=",
"canvas",
".",
"height",
"-",
"2",
",",
"width",
"=",
"canv... | Just a simple chart drawer, not related to SSE-channel | [
"Just",
"a",
"simple",
"chart",
"drawer",
"not",
"related",
"to",
"SSE",
"-",
"channel"
] | dc7c42e3c402cb59db256fbcfd5a17775197cede | https://github.com/rexxars/sse-channel/blob/dc7c42e3c402cb59db256fbcfd5a17775197cede/examples/client/client-example.js#L70-L95 | train |
dirkgroenen/simple-jQuery-slider | src/jquery.simpleslider.js | triggerSlideEnd | function triggerSlideEnd(){
if(!slided){
if(options.transition == "fade"){
$(options.slidesContainer).find(options.slides).each(function(index){
if($(this).data('index') == obj.currentSlide){
$(this).... | javascript | function triggerSlideEnd(){
if(!slided){
if(options.transition == "fade"){
$(options.slidesContainer).find(options.slides).each(function(index){
if($(this).data('index') == obj.currentSlide){
$(this).... | [
"function",
"triggerSlideEnd",
"(",
")",
"{",
"if",
"(",
"!",
"slided",
")",
"{",
"if",
"(",
"options",
".",
"transition",
"==",
"\"fade\"",
")",
"{",
"$",
"(",
"options",
".",
"slidesContainer",
")",
".",
"find",
"(",
"options",
".",
"slides",
")",
... | Create trigger point after a slide slides. All the slides return a TransitionEnd; to prevent a repeating trigger we keep a slided var | [
"Create",
"trigger",
"point",
"after",
"a",
"slide",
"slides",
".",
"All",
"the",
"slides",
"return",
"a",
"TransitionEnd",
";",
"to",
"prevent",
"a",
"repeating",
"trigger",
"we",
"keep",
"a",
"slided",
"var"
] | d4cf1c3192fcba28510598831f607b41cad88354 | https://github.com/dirkgroenen/simple-jQuery-slider/blob/d4cf1c3192fcba28510598831f607b41cad88354/src/jquery.simpleslider.js#L423-L465 | train |
jaywcjlove/svgtofont | src/generate.js | buildPathsObject | async function buildPathsObject(files) {
return Promise.all(
files.map(async filepath => {
const name = path.basename(filepath, '.svg');
const svg = fs.readFileSync(filepath, 'utf-8');
const pathStrings = await svgo.optimize(svg, { path: filepath })
.then(({ data }) => data.match(/ d="[^... | javascript | async function buildPathsObject(files) {
return Promise.all(
files.map(async filepath => {
const name = path.basename(filepath, '.svg');
const svg = fs.readFileSync(filepath, 'utf-8');
const pathStrings = await svgo.optimize(svg, { path: filepath })
.then(({ data }) => data.match(/ d="[^... | [
"async",
"function",
"buildPathsObject",
"(",
"files",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"files",
".",
"map",
"(",
"async",
"filepath",
"=>",
"{",
"const",
"name",
"=",
"path",
".",
"basename",
"(",
"filepath",
",",
"'.svg'",
")",
";",
"c... | Loads SVG file for each icon, extracts path strings `d="path-string"`,
and constructs map of icon name to array of path strings.
@param {array} files | [
"Loads",
"SVG",
"file",
"for",
"each",
"icon",
"extracts",
"path",
"strings",
"d",
"=",
"path",
"-",
"string",
"and",
"constructs",
"map",
"of",
"icon",
"name",
"to",
"array",
"of",
"path",
"strings",
"."
] | 59473c853868e01968569e6ca6292d322cdc68fa | https://github.com/jaywcjlove/svgtofont/blob/59473c853868e01968569e6ca6292d322cdc68fa/src/generate.js#L29-L40 | train |
blake-regalia/graphy.js | src/future/linked.js | mk_NodeSet | function mk_NodeSet(k_graph, a_terms, s_term_types) {
// prep to reduce nodes to a set
let h_nodes = {};
// nodes are all NamedNodes
if('NamedNode' === s_term_types) {
for(let i_term=0; i_term<a_terms.length; i_term++) {
let h_term = a_terms[i_term];
h_nodes[h_term.value] = h_term;
}
}
// nodes are all... | javascript | function mk_NodeSet(k_graph, a_terms, s_term_types) {
// prep to reduce nodes to a set
let h_nodes = {};
// nodes are all NamedNodes
if('NamedNode' === s_term_types) {
for(let i_term=0; i_term<a_terms.length; i_term++) {
let h_term = a_terms[i_term];
h_nodes[h_term.value] = h_term;
}
}
// nodes are all... | [
"function",
"mk_NodeSet",
"(",
"k_graph",
",",
"a_terms",
",",
"s_term_types",
")",
"{",
"// prep to reduce nodes to a set",
"let",
"h_nodes",
"=",
"{",
"}",
";",
"// nodes are all NamedNodes",
"if",
"(",
"'NamedNode'",
"===",
"s_term_types",
")",
"{",
"for",
"(",... | makes a new NodeSet | [
"makes",
"a",
"new",
"NodeSet"
] | fa1373c59167ca448600eb94cd8690c21509d071 | https://github.com/blake-regalia/graphy.js/blob/fa1373c59167ca448600eb94cd8690c21509d071/src/future/linked.js#L250-L304 | train |
blake-regalia/graphy.js | src/future/linked.js | mk_LiteralBunch | function mk_LiteralBunch(k_graph, a_terms) {
// append local methods to hash
let h_methods = Object.assign(Object.create(LiteralBunch_prototype), {
graph: k_graph,
terms: a_terms,
// for returning a different sample each time
sample_counter: 0,
});
// construct 'that'
let f_bound = LiteralBunch_operator.... | javascript | function mk_LiteralBunch(k_graph, a_terms) {
// append local methods to hash
let h_methods = Object.assign(Object.create(LiteralBunch_prototype), {
graph: k_graph,
terms: a_terms,
// for returning a different sample each time
sample_counter: 0,
});
// construct 'that'
let f_bound = LiteralBunch_operator.... | [
"function",
"mk_LiteralBunch",
"(",
"k_graph",
",",
"a_terms",
")",
"{",
"// append local methods to hash",
"let",
"h_methods",
"=",
"Object",
".",
"assign",
"(",
"Object",
".",
"create",
"(",
"LiteralBunch_prototype",
")",
",",
"{",
"graph",
":",
"k_graph",
","... | makes a new LiteralBunch | [
"makes",
"a",
"new",
"LiteralBunch"
] | fa1373c59167ca448600eb94cd8690c21509d071 | https://github.com/blake-regalia/graphy.js/blob/fa1373c59167ca448600eb94cd8690c21509d071/src/future/linked.js#L355-L371 | train |
blake-regalia/graphy.js | src/future/linked.js | LiteralBunch_operator | function LiteralBunch_operator(z_literal_filter) {
// user wants to filter literal by language or datatype
if('string' === typeof z_literal_filter) {
// by language tag
if('@' === z_literal_filter[0]) {
// ref language tag
let s_language = z_literal_filter.slice(1).toLowerCase();
// apply filter
this... | javascript | function LiteralBunch_operator(z_literal_filter) {
// user wants to filter literal by language or datatype
if('string' === typeof z_literal_filter) {
// by language tag
if('@' === z_literal_filter[0]) {
// ref language tag
let s_language = z_literal_filter.slice(1).toLowerCase();
// apply filter
this... | [
"function",
"LiteralBunch_operator",
"(",
"z_literal_filter",
")",
"{",
"// user wants to filter literal by language or datatype",
"if",
"(",
"'string'",
"===",
"typeof",
"z_literal_filter",
")",
"{",
"// by language tag",
"if",
"(",
"'@'",
"===",
"z_literal_filter",
"[",
... | mutates the LiteralBunch exactly once with the given filter argument | [
"mutates",
"the",
"LiteralBunch",
"exactly",
"once",
"with",
"the",
"given",
"filter",
"argument"
] | fa1373c59167ca448600eb94cd8690c21509d071 | https://github.com/blake-regalia/graphy.js/blob/fa1373c59167ca448600eb94cd8690c21509d071/src/future/linked.js#L374-L406 | train |
mkloubert/nativescript-bitmap-factory | plugin/index.js | asBitmap | function asBitmap(v, throwException) {
if (throwException === void 0) { throwException = true; }
var result = BitmapFactory.asBitmapObject(v);
if (throwException && (false === result)) {
throw "No valid value for a bitmap!";
}
return result;
} | javascript | function asBitmap(v, throwException) {
if (throwException === void 0) { throwException = true; }
var result = BitmapFactory.asBitmapObject(v);
if (throwException && (false === result)) {
throw "No valid value for a bitmap!";
}
return result;
} | [
"function",
"asBitmap",
"(",
"v",
",",
"throwException",
")",
"{",
"if",
"(",
"throwException",
"===",
"void",
"0",
")",
"{",
"throwException",
"=",
"true",
";",
"}",
"var",
"result",
"=",
"BitmapFactory",
".",
"asBitmapObject",
"(",
"v",
")",
";",
"if",... | Returns a value as bitmap object.
@param any v The input value.
@param {Boolean} [throwException] Throw exception if 'v' is invalid or return (false).
@throws Input value is invalid.
@return {IBitmap} The output value or (false) if input value is invalid. | [
"Returns",
"a",
"value",
"as",
"bitmap",
"object",
"."
] | 0e16a64f4b7c5794a1c66cd025c6f5759be899f6 | https://github.com/mkloubert/nativescript-bitmap-factory/blob/0e16a64f4b7c5794a1c66cd025c6f5759be899f6/plugin/index.js#L71-L78 | train |
mkloubert/nativescript-bitmap-factory | plugin/index.js | create | function create(width, height, opts) {
if (TypeUtils.isNullOrUndefined(height)) {
height = width;
}
if (arguments.length < 3) {
opts = getDefaultOptions();
}
if (TypeUtils.isNullOrUndefined(opts)) {
opts = {};
}
return BitmapFactory.createBitmap(width, heigh... | javascript | function create(width, height, opts) {
if (TypeUtils.isNullOrUndefined(height)) {
height = width;
}
if (arguments.length < 3) {
opts = getDefaultOptions();
}
if (TypeUtils.isNullOrUndefined(opts)) {
opts = {};
}
return BitmapFactory.createBitmap(width, heigh... | [
"function",
"create",
"(",
"width",
",",
"height",
",",
"opts",
")",
"{",
"if",
"(",
"TypeUtils",
".",
"isNullOrUndefined",
"(",
"height",
")",
")",
"{",
"height",
"=",
"width",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"{",
"... | Creates a new bitmap.
@param {Number} width The width of the new image.
@param {Number} [height] The optional height of the new image. If not defined, the width is taken as value.
@param {ICreateBitmapOptions} [opts] Additional options for creating the bitmap.
@return {IBitmap} The new bitmap. | [
"Creates",
"a",
"new",
"bitmap",
"."
] | 0e16a64f4b7c5794a1c66cd025c6f5759be899f6 | https://github.com/mkloubert/nativescript-bitmap-factory/blob/0e16a64f4b7c5794a1c66cd025c6f5759be899f6/plugin/index.js#L89-L100 | train |
prawnsalad/KiwiIRC | client/src/models/member.js | function (modes) {
var that = this;
return modes.sort(function (a, b) {
var a_idx, b_idx, i;
var user_prefixes = that.get('user_prefixes');
for (i = 0; i < user_prefixes.length; i++) {
if (user_prefixes[i].mode === a) {
a... | javascript | function (modes) {
var that = this;
return modes.sort(function (a, b) {
var a_idx, b_idx, i;
var user_prefixes = that.get('user_prefixes');
for (i = 0; i < user_prefixes.length; i++) {
if (user_prefixes[i].mode === a) {
a... | [
"function",
"(",
"modes",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"modes",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"a_idx",
",",
"b_idx",
",",
"i",
";",
"var",
"user_prefixes",
"=",
"that",
".",
"get",
"(",... | Sort modes in order of importance | [
"Sort",
"modes",
"in",
"order",
"of",
"importance"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/member.js#L24-L51 | train | |
prawnsalad/KiwiIRC | client/src/models/member.js | function (modes) {
var prefix = '';
var user_prefixes = this.get('user_prefixes');
if (typeof modes[0] !== 'undefined') {
prefix = _.detect(user_prefixes, function (prefix) {
return prefix.mode === modes[0];
});
prefix = (prefix) ? p... | javascript | function (modes) {
var prefix = '';
var user_prefixes = this.get('user_prefixes');
if (typeof modes[0] !== 'undefined') {
prefix = _.detect(user_prefixes, function (prefix) {
return prefix.mode === modes[0];
});
prefix = (prefix) ? p... | [
"function",
"(",
"modes",
")",
"{",
"var",
"prefix",
"=",
"''",
";",
"var",
"user_prefixes",
"=",
"this",
".",
"get",
"(",
"'user_prefixes'",
")",
";",
"if",
"(",
"typeof",
"modes",
"[",
"0",
"]",
"!==",
"'undefined'",
")",
"{",
"prefix",
"=",
"_",
... | Figure out a valid prefix given modes.
If a user is an op but also has voice, the prefix
should be the op as it is more important. | [
"Figure",
"out",
"a",
"valid",
"prefix",
"given",
"modes",
".",
"If",
"a",
"user",
"is",
"an",
"op",
"but",
"also",
"has",
"voice",
"the",
"prefix",
"should",
"be",
"the",
"op",
"as",
"it",
"is",
"more",
"important",
"."
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/member.js#L94-L107 | train | |
prawnsalad/KiwiIRC | client/src/models/member.js | function (nick) {
var tmp = nick, i, j, k, nick_char;
var user_prefixes = this.get('user_prefixes');
i = 0;
nick_character_loop:
for (j = 0; j < nick.length; j++) {
nick_char = nick.charAt(j);
for (k = 0; k < user_prefixes.length; k++) {
... | javascript | function (nick) {
var tmp = nick, i, j, k, nick_char;
var user_prefixes = this.get('user_prefixes');
i = 0;
nick_character_loop:
for (j = 0; j < nick.length; j++) {
nick_char = nick.charAt(j);
for (k = 0; k < user_prefixes.length; k++) {
... | [
"function",
"(",
"nick",
")",
"{",
"var",
"tmp",
"=",
"nick",
",",
"i",
",",
"j",
",",
"k",
",",
"nick_char",
";",
"var",
"user_prefixes",
"=",
"this",
".",
"get",
"(",
"'user_prefixes'",
")",
";",
"i",
"=",
"0",
";",
"nick_character_loop",
":",
"f... | Remove any recognised prefix from a nick | [
"Remove",
"any",
"recognised",
"prefix",
"from",
"a",
"nick"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/member.js#L113-L134 | train | |
prawnsalad/KiwiIRC | client/src/models/member.js | function () {
var user_prefixes = this.get('user_prefixes'),
modes = this.get('modes'),
o, max_mode;
if (modes.length > 0) {
o = _.indexOf(user_prefixes, _.find(user_prefixes, function (prefix) {
return prefix.mode === 'o';
}));
... | javascript | function () {
var user_prefixes = this.get('user_prefixes'),
modes = this.get('modes'),
o, max_mode;
if (modes.length > 0) {
o = _.indexOf(user_prefixes, _.find(user_prefixes, function (prefix) {
return prefix.mode === 'o';
}));
... | [
"function",
"(",
")",
"{",
"var",
"user_prefixes",
"=",
"this",
".",
"get",
"(",
"'user_prefixes'",
")",
",",
"modes",
"=",
"this",
".",
"get",
"(",
"'modes'",
")",
",",
"o",
",",
"max_mode",
";",
"if",
"(",
"modes",
".",
"length",
">",
"0",
")",
... | With the modes set on the user, make note if we have some sort of op status | [
"With",
"the",
"modes",
"set",
"on",
"the",
"user",
"make",
"note",
"if",
"we",
"have",
"some",
"sort",
"of",
"op",
"status"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/member.js#L167-L190 | train | |
prawnsalad/KiwiIRC | server/weblistener.js | initialiseSocket | function initialiseSocket(socket, callback) {
var request = socket.request,
address = request.meta.remote_address,
revdns;
// Key/val data stored to the socket to be read later on
// May also be synced to a redis DB to lookup clients
socket.meta = socket.request.meta;
// If a forwa... | javascript | function initialiseSocket(socket, callback) {
var request = socket.request,
address = request.meta.remote_address,
revdns;
// Key/val data stored to the socket to be read later on
// May also be synced to a redis DB to lookup clients
socket.meta = socket.request.meta;
// If a forwa... | [
"function",
"initialiseSocket",
"(",
"socket",
",",
"callback",
")",
"{",
"var",
"request",
"=",
"socket",
".",
"request",
",",
"address",
"=",
"request",
".",
"meta",
".",
"remote_address",
",",
"revdns",
";",
"// Key/val data stored to the socket to be read later ... | Get the reverse DNS entry for this connection.
Used later on for webirc, etc functionality | [
"Get",
"the",
"reverse",
"DNS",
"entry",
"for",
"this",
"connection",
".",
"Used",
"later",
"on",
"for",
"webirc",
"etc",
"functionality"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/weblistener.js#L163-L235 | train |
prawnsalad/KiwiIRC | client/src/views/application.js | function (ev) {
// If we're copying text, don't shift focus
if (ev.ctrlKey || ev.altKey || ev.metaKey) {
return;
}
// If we're typing into an input box somewhere, ignore
var elements = ['input', 'select', 'textarea', 'button', 'datalist', 'keygen'];
var do_no... | javascript | function (ev) {
// If we're copying text, don't shift focus
if (ev.ctrlKey || ev.altKey || ev.metaKey) {
return;
}
// If we're typing into an input box somewhere, ignore
var elements = ['input', 'select', 'textarea', 'button', 'datalist', 'keygen'];
var do_no... | [
"function",
"(",
"ev",
")",
"{",
"// If we're copying text, don't shift focus",
"if",
"(",
"ev",
".",
"ctrlKey",
"||",
"ev",
".",
"altKey",
"||",
"ev",
".",
"metaKey",
")",
"{",
"return",
";",
"}",
"// If we're typing into an input box somewhere, ignore",
"var",
"... | Globally shift focus to the command input box on a keypress | [
"Globally",
"shift",
"focus",
"to",
"the",
"command",
"input",
"box",
"on",
"a",
"keypress"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/application.js#L140-L157 | train | |
prawnsalad/KiwiIRC | client/assets/libs/jed.js | function ( options ) {
// Some minimal defaults
this.defaults = {
"locale_data" : {
"messages" : {
"" : {
"domain" : "messages",
"lang" : "en",
"plural_forms" : "nplurals=2; plural=(n != 1);"
}
// There are n... | javascript | function ( options ) {
// Some minimal defaults
this.defaults = {
"locale_data" : {
"messages" : {
"" : {
"domain" : "messages",
"lang" : "en",
"plural_forms" : "nplurals=2; plural=(n != 1);"
}
// There are n... | [
"function",
"(",
"options",
")",
"{",
"// Some minimal defaults\r",
"this",
".",
"defaults",
"=",
"{",
"\"locale_data\"",
":",
"{",
"\"messages\"",
":",
"{",
"\"\"",
":",
"{",
"\"domain\"",
":",
"\"messages\"",
",",
"\"lang\"",
":",
"\"en\"",
",",
"\"plural_fo... | END Miniature underscore impl Jed is a constructor function | [
"END",
"Miniature",
"underscore",
"impl",
"Jed",
"is",
"a",
"constructor",
"function"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/assets/libs/jed.js#L79-L105 | train | |
prawnsalad/KiwiIRC | client/assets/libs/jed.js | function ( domain, context, singular_key, plural_key, val ) {
// Set some defaults
plural_key = plural_key || singular_key;
// Use the global domain default if one
// isn't explicitly passed in
domain = domain || this._textdomain;
var fallback;
// Handle special ... | javascript | function ( domain, context, singular_key, plural_key, val ) {
// Set some defaults
plural_key = plural_key || singular_key;
// Use the global domain default if one
// isn't explicitly passed in
domain = domain || this._textdomain;
var fallback;
// Handle special ... | [
"function",
"(",
"domain",
",",
"context",
",",
"singular_key",
",",
"plural_key",
",",
"val",
")",
"{",
"// Set some defaults\r",
"plural_key",
"=",
"plural_key",
"||",
"singular_key",
";",
"// Use the global domain default if one\r",
"// isn't explicitly passed in\r",
"... | The most fully qualified gettext function. It has every option. Since it has every option, we can use it from every other method. This is the bread and butter. Technically there should be one more argument in this function for 'Category', but since we never use it, we might as well not waste the bytes to define it. | [
"The",
"most",
"fully",
"qualified",
"gettext",
"function",
".",
"It",
"has",
"every",
"option",
".",
"Since",
"it",
"has",
"every",
"option",
"we",
"can",
"use",
"it",
"from",
"every",
"other",
"method",
".",
"This",
"is",
"the",
"bread",
"and",
"butter... | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/assets/libs/jed.js#L216-L316 | train | |
prawnsalad/KiwiIRC | server/kiwi.js | function (list) {
var batch_size = 100,
cutoff;
if (list.length >= batch_size) {
// If we have more clients than our batch size, call ourself with the next batch
setTimeout(function () {
sendCommandBatch(list.slice(batch_size))... | javascript | function (list) {
var batch_size = 100,
cutoff;
if (list.length >= batch_size) {
// If we have more clients than our batch size, call ourself with the next batch
setTimeout(function () {
sendCommandBatch(list.slice(batch_size))... | [
"function",
"(",
"list",
")",
"{",
"var",
"batch_size",
"=",
"100",
",",
"cutoff",
";",
"if",
"(",
"list",
".",
"length",
">=",
"batch_size",
")",
"{",
"// If we have more clients than our batch size, call ourself with the next batch",
"setTimeout",
"(",
"function",
... | Sending of the command in batches | [
"Sending",
"of",
"the",
"command",
"in",
"batches"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/kiwi.js#L146-L171 | train | |
prawnsalad/KiwiIRC | server/httphandler.js | updateLocalesCache | function updateLocalesCache() {
cached_available_locales = [];
fs.readdir(global.config.public_http + '/assets/locales', function (err, files) {
if (err) {
if (err.code === 'ENOENT') {
winston.error('No locale files could be found at ' + err.path);
} else {
... | javascript | function updateLocalesCache() {
cached_available_locales = [];
fs.readdir(global.config.public_http + '/assets/locales', function (err, files) {
if (err) {
if (err.code === 'ENOENT') {
winston.error('No locale files could be found at ' + err.path);
} else {
... | [
"function",
"updateLocalesCache",
"(",
")",
"{",
"cached_available_locales",
"=",
"[",
"]",
";",
"fs",
".",
"readdir",
"(",
"global",
".",
"config",
".",
"public_http",
"+",
"'/assets/locales'",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(... | Cache the available locales we have so we don't read the same directory for each request | [
"Cache",
"the",
"available",
"locales",
"we",
"have",
"so",
"we",
"don",
"t",
"read",
"the",
"same",
"directory",
"for",
"each",
"request"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/httphandler.js#L102-L120 | train |
prawnsalad/KiwiIRC | server/httphandler.js | serveSettings | function serveSettings(request, response) {
var referrer_url,
debug = false;
// Check the referrer for a debug option
if (request.headers.referer) {
referrer_url = url.parse(request.headers.referer, true);
if (referrer_url.query && referrer_url.query.debug) {
debug = tru... | javascript | function serveSettings(request, response) {
var referrer_url,
debug = false;
// Check the referrer for a debug option
if (request.headers.referer) {
referrer_url = url.parse(request.headers.referer, true);
if (referrer_url.query && referrer_url.query.debug) {
debug = tru... | [
"function",
"serveSettings",
"(",
"request",
",",
"response",
")",
"{",
"var",
"referrer_url",
",",
"debug",
"=",
"false",
";",
"// Check the referrer for a debug option",
"if",
"(",
"request",
".",
"headers",
".",
"referer",
")",
"{",
"referrer_url",
"=",
"url"... | Handle the settings.json request | [
"Handle",
"the",
"settings",
".",
"json",
"request"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/httphandler.js#L157-L187 | train |
prawnsalad/KiwiIRC | client/src/helpers/desktopnotifications.js | function (timeout) {
if (!this.closed) {
if (this.notification) {
this._closeTimeout = this._closeTimeout || setTimeout(_.bind(this.close, this), timeout);
} else {
this.once('show', _.bind(this.closeAfter, this, timeout));
... | javascript | function (timeout) {
if (!this.closed) {
if (this.notification) {
this._closeTimeout = this._closeTimeout || setTimeout(_.bind(this.close, this), timeout);
} else {
this.once('show', _.bind(this.closeAfter, this, timeout));
... | [
"function",
"(",
"timeout",
")",
"{",
"if",
"(",
"!",
"this",
".",
"closed",
")",
"{",
"if",
"(",
"this",
".",
"notification",
")",
"{",
"this",
".",
"_closeTimeout",
"=",
"this",
".",
"_closeTimeout",
"||",
"setTimeout",
"(",
"_",
".",
"bind",
"(",
... | Close the notification after a given number of milliseconds.
@param {Number} timeout
@returns {this} | [
"Close",
"the",
"notification",
"after",
"a",
"given",
"number",
"of",
"milliseconds",
"."
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/helpers/desktopnotifications.js#L87-L96 | train | |
prawnsalad/KiwiIRC | client/src/misc/clientuicommands.js | unknownCommand | function unknownCommand (ev) {
var raw_cmd = ev.command + ' ' + ev.params.join(' ');
this.app.connections.active_connection.gateway.raw(raw_cmd);
} | javascript | function unknownCommand (ev) {
var raw_cmd = ev.command + ' ' + ev.params.join(' ');
this.app.connections.active_connection.gateway.raw(raw_cmd);
} | [
"function",
"unknownCommand",
"(",
"ev",
")",
"{",
"var",
"raw_cmd",
"=",
"ev",
".",
"command",
"+",
"' '",
"+",
"ev",
".",
"params",
".",
"join",
"(",
"' '",
")",
";",
"this",
".",
"app",
".",
"connections",
".",
"active_connection",
".",
"gateway",
... | A fallback action. Send a raw command to the server | [
"A",
"fallback",
"action",
".",
"Send",
"a",
"raw",
"command",
"to",
"the",
"server"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/misc/clientuicommands.js#L272-L275 | train |
prawnsalad/KiwiIRC | server/clientcommands.js | function(rpc_method, fn) {
rpc.on(rpc_method, _.partial(moduleEventWrap, rpc_method, fn));
} | javascript | function(rpc_method, fn) {
rpc.on(rpc_method, _.partial(moduleEventWrap, rpc_method, fn));
} | [
"function",
"(",
"rpc_method",
",",
"fn",
")",
"{",
"rpc",
".",
"on",
"(",
"rpc_method",
",",
"_",
".",
"partial",
"(",
"moduleEventWrap",
",",
"rpc_method",
",",
"fn",
")",
")",
";",
"}"
] | Quick + easier way to call the above function | [
"Quick",
"+",
"easier",
"way",
"to",
"call",
"the",
"above",
"function"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/clientcommands.js#L62-L64 | train | |
prawnsalad/KiwiIRC | server/clientcommands.js | truncateString | function truncateString(str, block_size) {
block_size = block_size || 350;
var blocks = [],
current_pos;
for (current_pos = 0; current_pos < str.length; current_pos = current_pos + block_size) {
blocks.push(str.substr(current_pos, block_size));
}
return blocks;
} | javascript | function truncateString(str, block_size) {
block_size = block_size || 350;
var blocks = [],
current_pos;
for (current_pos = 0; current_pos < str.length; current_pos = current_pos + block_size) {
blocks.push(str.substr(current_pos, block_size));
}
return blocks;
} | [
"function",
"truncateString",
"(",
"str",
",",
"block_size",
")",
"{",
"block_size",
"=",
"block_size",
"||",
"350",
";",
"var",
"blocks",
"=",
"[",
"]",
",",
"current_pos",
";",
"for",
"(",
"current_pos",
"=",
"0",
";",
"current_pos",
"<",
"str",
".",
... | Truncate a string into blocks of a set size | [
"Truncate",
"a",
"string",
"into",
"blocks",
"of",
"a",
"set",
"size"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/clientcommands.js#L88-L99 | train |
prawnsalad/KiwiIRC | server/irc/connection.js | function () {
var that = this,
connect_data;
// Build up data to be used for webirc/etc detection
connect_data = {
connection: this,
// Array of lines to be sent to the IRCd before anything else
prepend_data: []
};
// Let the webirc/etc detection modify any require... | javascript | function () {
var that = this,
connect_data;
// Build up data to be used for webirc/etc detection
connect_data = {
connection: this,
// Array of lines to be sent to the IRCd before anything else
prepend_data: []
};
// Let the webirc/etc detection modify any require... | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"connect_data",
";",
"// Build up data to be used for webirc/etc detection",
"connect_data",
"=",
"{",
"connection",
":",
"this",
",",
"// Array of lines to be sent to the IRCd before anything else",
"prepend_data",
... | Handle the socket connect event, starting the IRCd registration | [
"Handle",
"the",
"socket",
"connect",
"event",
"starting",
"the",
"IRCd",
"registration"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/irc/connection.js#L732-L766 | train | |
prawnsalad/KiwiIRC | server/irc/connection.js | findWebIrc | function findWebIrc(connect_data) {
var webirc_pass = global.config.webirc_pass,
found_webirc_pass, tmp;
// Do we have a single WEBIRC password?
if (typeof webirc_pass === 'string' && webirc_pass) {
found_webirc_pass = webirc_pass;
// Do we have a WEBIRC password for this hostname?
... | javascript | function findWebIrc(connect_data) {
var webirc_pass = global.config.webirc_pass,
found_webirc_pass, tmp;
// Do we have a single WEBIRC password?
if (typeof webirc_pass === 'string' && webirc_pass) {
found_webirc_pass = webirc_pass;
// Do we have a WEBIRC password for this hostname?
... | [
"function",
"findWebIrc",
"(",
"connect_data",
")",
"{",
"var",
"webirc_pass",
"=",
"global",
".",
"config",
".",
"webirc_pass",
",",
"found_webirc_pass",
",",
"tmp",
";",
"// Do we have a single WEBIRC password?",
"if",
"(",
"typeof",
"webirc_pass",
"===",
"'string... | Load any WEBIRC or alternative settings for this connection
Called in scope of the IrcConnection instance | [
"Load",
"any",
"WEBIRC",
"or",
"alternative",
"settings",
"for",
"this",
"connection",
"Called",
"in",
"scope",
"of",
"the",
"IrcConnection",
"instance"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/irc/connection.js#L774-L797 | train |
prawnsalad/KiwiIRC | server/irc/connection.js | socketOnData | function socketOnData(data) {
var data_pos, // Current position within the data Buffer
line_start = 0,
lines = [],
i,
max_buffer_size = 1024; // 1024 bytes is the maximum length of two RFC1459 IRC messages.
// May need tweaking when IRCv3... | javascript | function socketOnData(data) {
var data_pos, // Current position within the data Buffer
line_start = 0,
lines = [],
i,
max_buffer_size = 1024; // 1024 bytes is the maximum length of two RFC1459 IRC messages.
// May need tweaking when IRCv3... | [
"function",
"socketOnData",
"(",
"data",
")",
"{",
"var",
"data_pos",
",",
"// Current position within the data Buffer",
"line_start",
"=",
"0",
",",
"lines",
"=",
"[",
"]",
",",
"i",
",",
"max_buffer_size",
"=",
"1024",
";",
"// 1024 bytes is the maximum length of ... | Buffer any data we get from the IRCd until we have complete lines. | [
"Buffer",
"any",
"data",
"we",
"get",
"from",
"the",
"IRCd",
"until",
"we",
"have",
"complete",
"lines",
"."
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/irc/connection.js#L803-L865 | train |
prawnsalad/KiwiIRC | server/irc/connection.js | processIrcLines | function processIrcLines(irc_con, continue_processing) {
if (irc_con.reading_buffer && !continue_processing) return;
irc_con.reading_buffer = true;
var lines_per_js_tick = 4,
processed_lines = 0;
while(processed_lines < lines_per_js_tick && irc_con.read_buffer.length > 0) {
parseIrcLin... | javascript | function processIrcLines(irc_con, continue_processing) {
if (irc_con.reading_buffer && !continue_processing) return;
irc_con.reading_buffer = true;
var lines_per_js_tick = 4,
processed_lines = 0;
while(processed_lines < lines_per_js_tick && irc_con.read_buffer.length > 0) {
parseIrcLin... | [
"function",
"processIrcLines",
"(",
"irc_con",
",",
"continue_processing",
")",
"{",
"if",
"(",
"irc_con",
".",
"reading_buffer",
"&&",
"!",
"continue_processing",
")",
"return",
";",
"irc_con",
".",
"reading_buffer",
"=",
"true",
";",
"var",
"lines_per_js_tick",
... | Process the messages recieved from the IRCd that are buffered on an IrcConnection object
Will only process 4 lines per JS tick so that node can handle any other events while
handling a large buffer | [
"Process",
"the",
"messages",
"recieved",
"from",
"the",
"IRCd",
"that",
"are",
"buffered",
"on",
"an",
"IrcConnection",
"object",
"Will",
"only",
"process",
"4",
"lines",
"per",
"JS",
"tick",
"so",
"that",
"node",
"can",
"handle",
"any",
"other",
"events",
... | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/irc/connection.js#L896-L914 | train |
prawnsalad/KiwiIRC | server/proxy.js | ProxySocket | function ProxySocket(proxy_port, proxy_addr, meta, proxy_opts) {
stream.Duplex.call(this);
this.connected_fn = null;
this.proxy_addr = proxy_addr;
this.proxy_port = proxy_port;
this.proxy_opts = proxy_opts || {};
this.setMeta(meta || {});
this.state = 'disconnected';
} | javascript | function ProxySocket(proxy_port, proxy_addr, meta, proxy_opts) {
stream.Duplex.call(this);
this.connected_fn = null;
this.proxy_addr = proxy_addr;
this.proxy_port = proxy_port;
this.proxy_opts = proxy_opts || {};
this.setMeta(meta || {});
this.state = 'disconnected';
} | [
"function",
"ProxySocket",
"(",
"proxy_port",
",",
"proxy_addr",
",",
"meta",
",",
"proxy_opts",
")",
"{",
"stream",
".",
"Duplex",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"connected_fn",
"=",
"null",
";",
"this",
".",
"proxy_addr",
"=",
"proxy_... | ProxySocket
Transparent socket interface to a kiwi proxy | [
"ProxySocket",
"Transparent",
"socket",
"interface",
"to",
"a",
"kiwi",
"proxy"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/proxy.js#L273-L284 | train |
prawnsalad/KiwiIRC | server_modules/dnsbl.js | isBlacklisted | function isBlacklisted(ip, callback) {
var host_lookup = reverseIp(ip) + bl_zones[current_bl];
dns.resolve4(host_lookup, function(err, domain) {
if (err) {
// Not blacklisted
callback(false);
} else {
// It is blacklisted
callback(true);
}... | javascript | function isBlacklisted(ip, callback) {
var host_lookup = reverseIp(ip) + bl_zones[current_bl];
dns.resolve4(host_lookup, function(err, domain) {
if (err) {
// Not blacklisted
callback(false);
} else {
// It is blacklisted
callback(true);
}... | [
"function",
"isBlacklisted",
"(",
"ip",
",",
"callback",
")",
"{",
"var",
"host_lookup",
"=",
"reverseIp",
"(",
"ip",
")",
"+",
"bl_zones",
"[",
"current_bl",
"]",
";",
"dns",
".",
"resolve4",
"(",
"host_lookup",
",",
"function",
"(",
"err",
",",
"domain... | The actual checking against the DNS blacklist | [
"The",
"actual",
"checking",
"against",
"the",
"DNS",
"blacklist"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server_modules/dnsbl.js#L45-L57 | train |
prawnsalad/KiwiIRC | client/src/app.js | function() {
var network = typeof connection_id === 'undefined' ?
_kiwi.app.connections.active_connection :
_kiwi.app.connections.getByConnectionId(connection_id);
return network ?
network :
undefined... | javascript | function() {
var network = typeof connection_id === 'undefined' ?
_kiwi.app.connections.active_connection :
_kiwi.app.connections.getByConnectionId(connection_id);
return network ?
network :
undefined... | [
"function",
"(",
")",
"{",
"var",
"network",
"=",
"typeof",
"connection_id",
"===",
"'undefined'",
"?",
"_kiwi",
".",
"app",
".",
"connections",
".",
"active_connection",
":",
"_kiwi",
".",
"app",
".",
"connections",
".",
"getByConnectionId",
"(",
"connection_... | Helper to get the network object | [
"Helper",
"to",
"get",
"the",
"network",
"object"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/app.js#L105-L113 | train | |
prawnsalad/KiwiIRC | client/src/app.js | function (opts, callback) {
var locale_promise, theme_promise,
that = this;
opts = opts || {};
this.initUtils();
// Set up the settings datastore
_kiwi.global.settings = _kiwi.model.DataStore.instance('kiwi.settings');
_kiwi.global.settings.load()... | javascript | function (opts, callback) {
var locale_promise, theme_promise,
that = this;
opts = opts || {};
this.initUtils();
// Set up the settings datastore
_kiwi.global.settings = _kiwi.model.DataStore.instance('kiwi.settings');
_kiwi.global.settings.load()... | [
"function",
"(",
"opts",
",",
"callback",
")",
"{",
"var",
"locale_promise",
",",
"theme_promise",
",",
"that",
"=",
"this",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"initUtils",
"(",
")",
";",
"// Set up the settings datastore\r",
"_kiw... | Entry point to start the kiwi application | [
"Entry",
"point",
"to",
"start",
"the",
"kiwi",
"application"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/app.js#L223-L277 | train | |
prawnsalad/KiwiIRC | server/settingsgenerator.js | generateSettings | function generateSettings(debug) {
var vars = {
server_settings: {},
client_plugins: [],
translations: [],
scripts: [
[
'assets/libs/lodash.min.js'
],
['assets/libs/backbone.min.js', 'assets/libs/jed.... | javascript | function generateSettings(debug) {
var vars = {
server_settings: {},
client_plugins: [],
translations: [],
scripts: [
[
'assets/libs/lodash.min.js'
],
['assets/libs/backbone.min.js', 'assets/libs/jed.... | [
"function",
"generateSettings",
"(",
"debug",
")",
"{",
"var",
"vars",
"=",
"{",
"server_settings",
":",
"{",
"}",
",",
"client_plugins",
":",
"[",
"]",
",",
"translations",
":",
"[",
"]",
",",
"scripts",
":",
"[",
"[",
"'assets/libs/lodash.min.js'",
"]",
... | Generate a settings object for the client.
Settings include available translations, default client config, etc | [
"Generate",
"a",
"settings",
"object",
"for",
"the",
"client",
".",
"Settings",
"include",
"available",
"translations",
"default",
"client",
"config",
"etc"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/settingsgenerator.js#L53-L106 | train |
prawnsalad/KiwiIRC | client/src/views/channel.js | function(word, colourise) {
var members, member, nick, nick_re, style = '';
if (!(members = this.model.get('members')) || !(member = members.getByNick(word))) {
return;
}
nick = member.get('nick');
if (colourise !== false) {
// Use the nick from the mem... | javascript | function(word, colourise) {
var members, member, nick, nick_re, style = '';
if (!(members = this.model.get('members')) || !(member = members.getByNick(word))) {
return;
}
nick = member.get('nick');
if (colourise !== false) {
// Use the nick from the mem... | [
"function",
"(",
"word",
",",
"colourise",
")",
"{",
"var",
"members",
",",
"member",
",",
"nick",
",",
"nick_re",
",",
"style",
"=",
"''",
";",
"if",
"(",
"!",
"(",
"members",
"=",
"this",
".",
"model",
".",
"get",
"(",
"'members'",
")",
")",
"|... | Let nicks be clickable + colourise within messages | [
"Let",
"nicks",
"be",
"clickable",
"+",
"colourise",
"within",
"messages"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/channel.js#L174-L195 | train | |
prawnsalad/KiwiIRC | client/src/views/channel.js | function(word) {
var re,
parsed = false,
network = this.model.get('network');
if (!network) {
return;
}
re = new RegExp('(^|\\s)([' + _.escapeRegExp(network.get('channel_prefix')) + '][^ .,\\007]+)', 'g');
if (!word.match(re)) {
... | javascript | function(word) {
var re,
parsed = false,
network = this.model.get('network');
if (!network) {
return;
}
re = new RegExp('(^|\\s)([' + _.escapeRegExp(network.get('channel_prefix')) + '][^ .,\\007]+)', 'g');
if (!word.match(re)) {
... | [
"function",
"(",
"word",
")",
"{",
"var",
"re",
",",
"parsed",
"=",
"false",
",",
"network",
"=",
"this",
".",
"model",
".",
"get",
"(",
"'network'",
")",
";",
"if",
"(",
"!",
"network",
")",
"{",
"return",
";",
"}",
"re",
"=",
"new",
"RegExp",
... | Make channels clickable | [
"Make",
"channels",
"clickable"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/channel.js#L199-L219 | train | |
prawnsalad/KiwiIRC | client/src/views/channel.js | function(msg) {
var nick_hex, time_difference,
message_words,
sb = this.model.get('scrollback'),
network = this.model.get('network'),
nick,
regexpStr,
prev_msg = sb[sb.length-2],
hour, pm, am_pm_locale_key;
// Clone the... | javascript | function(msg) {
var nick_hex, time_difference,
message_words,
sb = this.model.get('scrollback'),
network = this.model.get('network'),
nick,
regexpStr,
prev_msg = sb[sb.length-2],
hour, pm, am_pm_locale_key;
// Clone the... | [
"function",
"(",
"msg",
")",
"{",
"var",
"nick_hex",
",",
"time_difference",
",",
"message_words",
",",
"sb",
"=",
"this",
".",
"model",
".",
"get",
"(",
"'scrollback'",
")",
",",
"network",
"=",
"this",
".",
"model",
".",
"get",
"(",
"'network'",
")",... | Takes an IRC message object and parses it for displaying | [
"Takes",
"an",
"IRC",
"message",
"object",
"and",
"parses",
"it",
"for",
"displaying"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/channel.js#L298-L402 | train | |
prawnsalad/KiwiIRC | client/src/views/channel.js | function (event) {
var $target = $(event.currentTarget),
nick,
members = this.model.get('members'),
member;
event.stopPropagation();
// Check this current element for a nick before resorting to the main message
// (eg. inline nicks has the nick on it... | javascript | function (event) {
var $target = $(event.currentTarget),
nick,
members = this.model.get('members'),
member;
event.stopPropagation();
// Check this current element for a nick before resorting to the main message
// (eg. inline nicks has the nick on it... | [
"function",
"(",
"event",
")",
"{",
"var",
"$target",
"=",
"$",
"(",
"event",
".",
"currentTarget",
")",
",",
"nick",
",",
"members",
"=",
"this",
".",
"model",
".",
"get",
"(",
"'members'",
")",
",",
"member",
";",
"event",
".",
"stopPropagation",
"... | Click on a nickname | [
"Click",
"on",
"a",
"nickname"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/channel.js#L426-L455 | train | |
prawnsalad/KiwiIRC | client/src/views/channel.js | function (event) {
var nick_class;
// Find a valid class that this element has
_.each($(event.currentTarget).parent('.msg').attr('class').split(' '), function (css_class) {
if (css_class.match(/^nick_[a-z0-9]+/i)) {
nick_class = css_class;
}
});
... | javascript | function (event) {
var nick_class;
// Find a valid class that this element has
_.each($(event.currentTarget).parent('.msg').attr('class').split(' '), function (css_class) {
if (css_class.match(/^nick_[a-z0-9]+/i)) {
nick_class = css_class;
}
});
... | [
"function",
"(",
"event",
")",
"{",
"var",
"nick_class",
";",
"// Find a valid class that this element has",
"_",
".",
"each",
"(",
"$",
"(",
"event",
".",
"currentTarget",
")",
".",
"parent",
"(",
"'.msg'",
")",
".",
"attr",
"(",
"'class'",
")",
".",
"spl... | Cursor hovers over a message | [
"Cursor",
"hovers",
"over",
"a",
"message"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/views/channel.js#L541-L555 | train | |
prawnsalad/KiwiIRC | server/stats.js | statsTimer | function statsTimer(stat_name, data_start) {
var timer_started = new Date();
var timerStop = function timerStop(data_end) {
var time = (new Date()) - timer_started;
var data = shallowMergeObjects(data_start, data_end);
global.modules.emit('stat timer', {name: stat_n... | javascript | function statsTimer(stat_name, data_start) {
var timer_started = new Date();
var timerStop = function timerStop(data_end) {
var time = (new Date()) - timer_started;
var data = shallowMergeObjects(data_start, data_end);
global.modules.emit('stat timer', {name: stat_n... | [
"function",
"statsTimer",
"(",
"stat_name",
",",
"data_start",
")",
"{",
"var",
"timer_started",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"timerStop",
"=",
"function",
"timerStop",
"(",
"data_end",
")",
"{",
"var",
"time",
"=",
"(",
"new",
"Date",
"(",
... | Send a timer value to the stats
Usage:
var timer = Stats.startTimer('stat_name', {some_data: 'value'});
// Do stuff
timer.stop({other_data: 'value'});
The object passed into .startTimer() and .stop(); are optional. If
given they will be shallow merged with .stop() overridding .startTimer() | [
"Send",
"a",
"timer",
"value",
"to",
"the",
"stats"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server/stats.js#L22-L35 | train |
prawnsalad/KiwiIRC | server_modules/control.js | SocketClient | function SocketClient (socket) {
var that = this;
this.socket = socket;
this.socket_closing = false;
this.remoteAddress = this.socket.remoteAddress;
winston.info('Control connection from %s opened', this.socket.remoteAddress);
this.bindEvents();
socket.write("\nHello, you are connected t... | javascript | function SocketClient (socket) {
var that = this;
this.socket = socket;
this.socket_closing = false;
this.remoteAddress = this.socket.remoteAddress;
winston.info('Control connection from %s opened', this.socket.remoteAddress);
this.bindEvents();
socket.write("\nHello, you are connected t... | [
"function",
"SocketClient",
"(",
"socket",
")",
"{",
"var",
"that",
"=",
"this",
";",
"this",
".",
"socket",
"=",
"socket",
";",
"this",
".",
"socket_closing",
"=",
"false",
";",
"this",
".",
"remoteAddress",
"=",
"this",
".",
"socket",
".",
"remoteAddre... | The socket client | [
"The",
"socket",
"client"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/server_modules/control.js#L19-L36 | train |
prawnsalad/KiwiIRC | client/src/models/applet.js | function (applet_object, applet_name) {
if (typeof applet_object === 'object') {
// Make sure this is a valid Applet
if (applet_object.get || applet_object.extend) {
// Try find a title for the applet
this.set('title', applet_object.get('title') || ... | javascript | function (applet_object, applet_name) {
if (typeof applet_object === 'object') {
// Make sure this is a valid Applet
if (applet_object.get || applet_object.extend) {
// Try find a title for the applet
this.set('title', applet_object.get('title') || ... | [
"function",
"(",
"applet_object",
",",
"applet_name",
")",
"{",
"if",
"(",
"typeof",
"applet_object",
"===",
"'object'",
")",
"{",
"// Make sure this is a valid Applet\r",
"if",
"(",
"applet_object",
".",
"get",
"||",
"applet_object",
".",
"extend",
")",
"{",
"/... | Load an applet within this panel | [
"Load",
"an",
"applet",
"within",
"this",
"panel"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/applet.js#L17-L48 | train | |
prawnsalad/KiwiIRC | client/src/models/applet.js | function (applet_name) {
// See if we have an instance loaded already
var applet = _.find(_kiwi.app.panels('applets'), function(panel) {
// Ignore if it's not an applet
if (!panel.isApplet()) return;
// Ignore if it doesn't have an applet loaded
... | javascript | function (applet_name) {
// See if we have an instance loaded already
var applet = _.find(_kiwi.app.panels('applets'), function(panel) {
// Ignore if it's not an applet
if (!panel.isApplet()) return;
// Ignore if it doesn't have an applet loaded
... | [
"function",
"(",
"applet_name",
")",
"{",
"// See if we have an instance loaded already\r",
"var",
"applet",
"=",
"_",
".",
"find",
"(",
"_kiwi",
".",
"app",
".",
"panels",
"(",
"'applets'",
")",
",",
"function",
"(",
"panel",
")",
"{",
"// Ignore if it's not an... | Load an applet type once only. If it already exists, return that | [
"Load",
"an",
"applet",
"type",
"once",
"only",
".",
"If",
"it",
"already",
"exists",
"return",
"that"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/applet.js#L91-L111 | train | |
prawnsalad/KiwiIRC | client/src/helpers/plugininterface.js | callListeners | function callListeners(listeners) {
var current_event_idx = -1;
// Make sure we have some data to pass to the listeners
event_data = event_data || undefined;
// If no bound listeners for this event, leave now
if (listeners.length === 0) {
emitComplete();
... | javascript | function callListeners(listeners) {
var current_event_idx = -1;
// Make sure we have some data to pass to the listeners
event_data = event_data || undefined;
// If no bound listeners for this event, leave now
if (listeners.length === 0) {
emitComplete();
... | [
"function",
"callListeners",
"(",
"listeners",
")",
"{",
"var",
"current_event_idx",
"=",
"-",
"1",
";",
"// Make sure we have some data to pass to the listeners",
"event_data",
"=",
"event_data",
"||",
"undefined",
";",
"// If no bound listeners for this event, leave now",
"... | Emit this event to an array of listeners | [
"Emit",
"this",
"event",
"to",
"an",
"array",
"of",
"listeners"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/helpers/plugininterface.js#L140-L199 | train |
prawnsalad/KiwiIRC | client/src/models/network.js | function (channels) {
var that = this,
panels = [];
// Multiple channels may come as comma-delimited
if (typeof channels === 'string') {
channels = channels.split(',');
}
$.each(channels, function (index, channel_name_key) {
... | javascript | function (channels) {
var that = this,
panels = [];
// Multiple channels may come as comma-delimited
if (typeof channels === 'string') {
channels = channels.split(',');
}
$.each(channels, function (index, channel_name_key) {
... | [
"function",
"(",
"channels",
")",
"{",
"var",
"that",
"=",
"this",
",",
"panels",
"=",
"[",
"]",
";",
"// Multiple channels may come as comma-delimited",
"if",
"(",
"typeof",
"channels",
"===",
"'string'",
")",
"{",
"channels",
"=",
"channels",
".",
"split",
... | Create panels and join the channel
This will not wait for the join event to create a panel. This
increases responsiveness in case of network lag | [
"Create",
"panels",
"and",
"join",
"the",
"channel",
"This",
"will",
"not",
"wait",
"for",
"the",
"join",
"event",
"to",
"create",
"a",
"panel",
".",
"This",
"increases",
"responsiveness",
"in",
"case",
"of",
"network",
"lag"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/network.js#L159-L197 | train | |
prawnsalad/KiwiIRC | client/src/models/network.js | function() {
var that = this;
this.panels.forEach(function(panel) {
if (!panel.isChannel())
return;
that.gateway.join(panel.get('name'), panel.get('key') || undefined);
});
} | javascript | function() {
var that = this;
this.panels.forEach(function(panel) {
if (!panel.isChannel())
return;
that.gateway.join(panel.get('name'), panel.get('key') || undefined);
});
} | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"this",
".",
"panels",
".",
"forEach",
"(",
"function",
"(",
"panel",
")",
"{",
"if",
"(",
"!",
"panel",
".",
"isChannel",
"(",
")",
")",
"return",
";",
"that",
".",
"gateway",
".",
"joi... | Join all the open channels we have open
Reconnecting to a network would typically call this. | [
"Join",
"all",
"the",
"open",
"channels",
"we",
"have",
"open",
"Reconnecting",
"to",
"a",
"network",
"would",
"typically",
"call",
"this",
"."
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/network.js#L204-L213 | train | |
prawnsalad/KiwiIRC | client/src/models/network.js | function (mask) {
var found_mask;
if (typeof mask === "object") {
mask = (mask.nick||'*')+'!'+(mask.ident||'*')+'@'+(mask.hostname||'*');
} else if (typeof mask === "string") {
mask = toUserMask(mask);
}
found_mask = this.ignore... | javascript | function (mask) {
var found_mask;
if (typeof mask === "object") {
mask = (mask.nick||'*')+'!'+(mask.ident||'*')+'@'+(mask.hostname||'*');
} else if (typeof mask === "string") {
mask = toUserMask(mask);
}
found_mask = this.ignore... | [
"function",
"(",
"mask",
")",
"{",
"var",
"found_mask",
";",
"if",
"(",
"typeof",
"mask",
"===",
"\"object\"",
")",
"{",
"mask",
"=",
"(",
"mask",
".",
"nick",
"||",
"'*'",
")",
"+",
"'!'",
"+",
"(",
"mask",
".",
"ident",
"||",
"'*'",
")",
"+",
... | Check if a user is ignored. Accepts an object with nick, ident and hostname OR a string. | [
"Check",
"if",
"a",
"user",
"is",
"ignored",
".",
"Accepts",
"an",
"object",
"with",
"nick",
"ident",
"and",
"hostname",
"OR",
"a",
"string",
"."
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/network.js#L224-L238 | train | |
prawnsalad/KiwiIRC | client/src/models/network.js | function (nick) {
var that = this,
query;
// Check if we have the panel already. If not, create it
query = that.panels.getByName(nick);
if (!query) {
query = new _kiwi.model.Query({name: nick, network: this});
that.panels.a... | javascript | function (nick) {
var that = this,
query;
// Check if we have the panel already. If not, create it
query = that.panels.getByName(nick);
if (!query) {
query = new _kiwi.model.Query({name: nick, network: this});
that.panels.a... | [
"function",
"(",
"nick",
")",
"{",
"var",
"that",
"=",
"this",
",",
"query",
";",
"// Check if we have the panel already. If not, create it",
"query",
"=",
"that",
".",
"panels",
".",
"getByName",
"(",
"nick",
")",
";",
"if",
"(",
"!",
"query",
")",
"{",
"... | Create a new query panel | [
"Create",
"a",
"new",
"query",
"panel"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/network.js#L241-L256 | train | |
prawnsalad/KiwiIRC | client/src/models/network.js | friendlyModeString | function friendlyModeString (event_modes, alt_target) {
var modes = {}, return_string;
// If no default given, use the main event info
if (!event_modes) {
event_modes = event.modes;
alt_target = event.target;
}
// Reformat the... | javascript | function friendlyModeString (event_modes, alt_target) {
var modes = {}, return_string;
// If no default given, use the main event info
if (!event_modes) {
event_modes = event.modes;
alt_target = event.target;
}
// Reformat the... | [
"function",
"friendlyModeString",
"(",
"event_modes",
",",
"alt_target",
")",
"{",
"var",
"modes",
"=",
"{",
"}",
",",
"return_string",
";",
"// If no default given, use the main event info",
"if",
"(",
"!",
"event_modes",
")",
"{",
"event_modes",
"=",
"event",
".... | Build a nicely formatted string to be displayed to a regular human | [
"Build",
"a",
"nicely",
"formatted",
"string",
"to",
"be",
"displayed",
"to",
"a",
"regular",
"human"
] | e54d8e5b98f15a903f915335f985d6dc56011fcf | https://github.com/prawnsalad/KiwiIRC/blob/e54d8e5b98f15a903f915335f985d6dc56011fcf/client/src/models/network.js#L681-L713 | train |
shannonmoeller/handlebars-layouts | index.js | layouts | function layouts(handlebars) {
var helpers = {
/**
* @method extend
* @param {String} name
* @param {?Object} customContext
* @param {Object} options
* @param {Function(Object)} options.fn
* @param {Object} options.hash
* @return {String} Rendered partial.
*/
extend: function (name, customC... | javascript | function layouts(handlebars) {
var helpers = {
/**
* @method extend
* @param {String} name
* @param {?Object} customContext
* @param {Object} options
* @param {Function(Object)} options.fn
* @param {Object} options.hash
* @return {String} Rendered partial.
*/
extend: function (name, customC... | [
"function",
"layouts",
"(",
"handlebars",
")",
"{",
"var",
"helpers",
"=",
"{",
"/**\n\t\t * @method extend\n\t\t * @param {String} name\n\t\t * @param {?Object} customContext\n\t\t * @param {Object} options\n\t\t * @param {Function(Object)} options.fn\n\t\t * @param {Object} options.hash\n\t\t ... | Generates an object of layout helpers.
@type {Function}
@param {Object} handlebars Handlebars instance.
@return {Object} Object of helpers. | [
"Generates",
"an",
"object",
"of",
"layout",
"helpers",
"."
] | 50b533b0c02b47d57a6ee4f81531c9e52213b10c | https://github.com/shannonmoeller/handlebars-layouts/blob/50b533b0c02b47d57a6ee4f81531c9e52213b10c/index.js#L93-L212 | train |
BlinkUX/sequelize-mock | src/queryinterface.js | QueryInterface | function QueryInterface (options) {
this.options = _.extend({
stopPropagation: false,
createdDefault: true,
fallbackFn: undefined,
}, options || {});
this._results = [];
this._handlers = [];
} | javascript | function QueryInterface (options) {
this.options = _.extend({
stopPropagation: false,
createdDefault: true,
fallbackFn: undefined,
}, options || {});
this._results = [];
this._handlers = [];
} | [
"function",
"QueryInterface",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"stopPropagation",
":",
"false",
",",
"createdDefault",
":",
"true",
",",
"fallbackFn",
":",
"undefined",
",",
"}",
",",
"options",
"||",
"... | The `QueryInterface` class is used to provide common mock query functionality. New
instances of this class should mostly be created internally, however the functions on
the class are exposed on objects utilize this class.
@class QueryInterface
@constructor
@param {Object} [options] Options for the query interface to u... | [
"The",
"QueryInterface",
"class",
"is",
"used",
"to",
"provide",
"common",
"mock",
"query",
"functionality",
".",
"New",
"instances",
"of",
"this",
"class",
"should",
"mostly",
"be",
"created",
"internally",
"however",
"the",
"functions",
"on",
"the",
"class",
... | 2db72e5ce3e8d630cb93ed1814000627c31e5590 | https://github.com/BlinkUX/sequelize-mock/blob/2db72e5ce3e8d630cb93ed1814000627c31e5590/src/queryinterface.js#L40-L48 | train |
BlinkUX/sequelize-mock | src/instance.js | fakeModelInstance | function fakeModelInstance (values, options) {
this.options = options || {};
/**
* As with Sequelize, we include a `dataValues` property which contains the values for the
* instance. As with Sequelize, you should use other methods to edit the values for any
* code that will also interact with Sequelize.
*
... | javascript | function fakeModelInstance (values, options) {
this.options = options || {};
/**
* As with Sequelize, we include a `dataValues` property which contains the values for the
* instance. As with Sequelize, you should use other methods to edit the values for any
* code that will also interact with Sequelize.
*
... | [
"function",
"fakeModelInstance",
"(",
"values",
",",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"/**\n\t * As with Sequelize, we include a `dataValues` property which contains the values for the\n\t * instance. As with Sequelize, you should us... | Instance Mock Object. Creation of this object should almost always be handled through the
`Model` class methods. In cases when you need to create an `Instance` directly, providing
the `defaults` parameter should be enough, as the `obj` overrides parameter is optional.
@class Instance
@constructor
@param {Object} defau... | [
"Instance",
"Mock",
"Object",
".",
"Creation",
"of",
"this",
"object",
"should",
"almost",
"always",
"be",
"handled",
"through",
"the",
"Model",
"class",
"methods",
".",
"In",
"cases",
"when",
"you",
"need",
"to",
"create",
"an",
"Instance",
"directly",
"pro... | 2db72e5ce3e8d630cb93ed1814000627c31e5590 | https://github.com/BlinkUX/sequelize-mock/blob/2db72e5ce3e8d630cb93ed1814000627c31e5590/src/instance.js#L43-L86 | train |
BlinkUX/sequelize-mock | src/sequelize.js | Sequelize | function Sequelize(database, username, password, options) {
if(typeof database == 'object') {
options = database;
} else if (typeof username == 'object') {
options = username;
} else if (typeof password == 'object') {
options = password;
}
this.queryInterface = new QueryInterface( _.pick(options || {}, ['s... | javascript | function Sequelize(database, username, password, options) {
if(typeof database == 'object') {
options = database;
} else if (typeof username == 'object') {
options = username;
} else if (typeof password == 'object') {
options = password;
}
this.queryInterface = new QueryInterface( _.pick(options || {}, ['s... | [
"function",
"Sequelize",
"(",
"database",
",",
"username",
",",
"password",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"database",
"==",
"'object'",
")",
"{",
"options",
"=",
"database",
";",
"}",
"else",
"if",
"(",
"typeof",
"username",
"==",
"'obje... | Sequelize Mock Object. This can be initialize much the same way that Sequelize itself
is initialized. Any configuration or options is ignored, so it can be used as a drop-in
replacement for Sequelize but does not have all the same functionality or features.
@class Sequelize
@constructor
@param {String} [database] Igno... | [
"Sequelize",
"Mock",
"Object",
".",
"This",
"can",
"be",
"initialize",
"much",
"the",
"same",
"way",
"that",
"Sequelize",
"itself",
"is",
"initialized",
".",
"Any",
"configuration",
"or",
"options",
"is",
"ignored",
"so",
"it",
"can",
"be",
"used",
"as",
"... | 2db72e5ce3e8d630cb93ed1814000627c31e5590 | https://github.com/BlinkUX/sequelize-mock/blob/2db72e5ce3e8d630cb93ed1814000627c31e5590/src/sequelize.js#L35-L71 | train |
catamphetamine/react-time-ago | source/ReactTimeAgo.js | convertToDate | function convertToDate(input)
{
if (input.constructor === Date) {
return input
}
if (typeof input === 'number') {
return new Date(input)
}
throw new Error(`Unsupported react-time-ago input: ${typeof input}, ${input}`)
} | javascript | function convertToDate(input)
{
if (input.constructor === Date) {
return input
}
if (typeof input === 'number') {
return new Date(input)
}
throw new Error(`Unsupported react-time-ago input: ${typeof input}, ${input}`)
} | [
"function",
"convertToDate",
"(",
"input",
")",
"{",
"if",
"(",
"input",
".",
"constructor",
"===",
"Date",
")",
"{",
"return",
"input",
"}",
"if",
"(",
"typeof",
"input",
"===",
"'number'",
")",
"{",
"return",
"new",
"Date",
"(",
"input",
")",
"}",
... | Converts argument into a `Date`. | [
"Converts",
"argument",
"into",
"a",
"Date",
"."
] | 2f7bf6d8981ec49cdb94a15d99ef0fddf410d90c | https://github.com/catamphetamine/react-time-ago/blob/2f7bf6d8981ec49cdb94a15d99ef0fddf410d90c/source/ReactTimeAgo.js#L238-L249 | train |
design-first/system-runtime | src/helper.js | getPrefix | function getPrefix() {
var validPrefix = 'abcdef';
return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));
} | javascript | function getPrefix() {
var validPrefix = 'abcdef';
return validPrefix.charAt(Math.floor(Math.random() * validPrefix.length));
} | [
"function",
"getPrefix",
"(",
")",
"{",
"var",
"validPrefix",
"=",
"'abcdef'",
";",
"return",
"validPrefix",
".",
"charAt",
"(",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"validPrefix",
".",
"length",
")",
")",
";",
"}"
] | force the uuid to start with a letter | [
"force",
"the",
"uuid",
"to",
"start",
"with",
"a",
"letter"
] | 59b168886f307bd20531b3c7b082920998e5b700 | https://github.com/design-first/system-runtime/blob/59b168886f307bd20531b3c7b082920998e5b700/src/helper.js#L120-L123 | train |
jieter/Leaflet.encoded | Polyline.encoded.js | function (num) {
var value, encoded = '';
while (num >= 0x20) {
value = (0x20 | (num & 0x1f)) + 63;
encoded += (String.fromCharCode(value));
num >>= 5;
}
value = num + 63;
encoded += (String.fromCharCode(value));... | javascript | function (num) {
var value, encoded = '';
while (num >= 0x20) {
value = (0x20 | (num & 0x1f)) + 63;
encoded += (String.fromCharCode(value));
num >>= 5;
}
value = num + 63;
encoded += (String.fromCharCode(value));... | [
"function",
"(",
"num",
")",
"{",
"var",
"value",
",",
"encoded",
"=",
"''",
";",
"while",
"(",
"num",
">=",
"0x20",
")",
"{",
"value",
"=",
"(",
"0x20",
"|",
"(",
"num",
"&",
"0x1f",
")",
")",
"+",
"63",
";",
"encoded",
"+=",
"(",
"String",
... | This function is very similar to Google's, but I added some stuff to deal with the double slash issue. | [
"This",
"function",
"is",
"very",
"similar",
"to",
"Google",
"s",
"but",
"I",
"added",
"some",
"stuff",
"to",
"deal",
"with",
"the",
"double",
"slash",
"issue",
"."
] | 68e781908783fb12236fc7d8d90d71d785f892e9 | https://github.com/jieter/Leaflet.encoded/blob/68e781908783fb12236fc7d8d90d71d785f892e9/Polyline.encoded.js#L186-L197 | train | |
errcw/gaussian | lib/gaussian.js | function(x) {
var z = Math.abs(x);
var t = 1 / (1 + z / 2);
var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 +
t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 +
t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 +
t * (-0.82215223 + t * 0.17087277))))))))... | javascript | function(x) {
var z = Math.abs(x);
var t = 1 / (1 + z / 2);
var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 +
t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 +
t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 +
t * (-0.82215223 + t * 0.17087277))))))))... | [
"function",
"(",
"x",
")",
"{",
"var",
"z",
"=",
"Math",
".",
"abs",
"(",
"x",
")",
";",
"var",
"t",
"=",
"1",
"/",
"(",
"1",
"+",
"z",
"/",
"2",
")",
";",
"var",
"r",
"=",
"t",
"*",
"Math",
".",
"exp",
"(",
"-",
"z",
"*",
"z",
"-",
... | Complementary error function From Numerical Recipes in C 2e p221 | [
"Complementary",
"error",
"function",
"From",
"Numerical",
"Recipes",
"in",
"C",
"2e",
"p221"
] | 3b3e49cd35f278429af80e310aed85de94d1eb99 | https://github.com/errcw/gaussian/blob/3b3e49cd35f278429af80e310aed85de94d1eb99/lib/gaussian.js#L7-L15 | train | |
errcw/gaussian | lib/gaussian.js | function(x) {
if (x >= 2) { return -100; }
if (x <= 0) { return 100; }
var xx = (x < 1) ? x : 2 - x;
var t = Math.sqrt(-2 * Math.log(xx / 2));
var r = -0.70711 * ((2.30753 + t * 0.27061) /
(1 + t * (0.99229 + t * 0.04481)) - t);
for (var j = 0; j < 2; j++) {
var err = erfc(r... | javascript | function(x) {
if (x >= 2) { return -100; }
if (x <= 0) { return 100; }
var xx = (x < 1) ? x : 2 - x;
var t = Math.sqrt(-2 * Math.log(xx / 2));
var r = -0.70711 * ((2.30753 + t * 0.27061) /
(1 + t * (0.99229 + t * 0.04481)) - t);
for (var j = 0; j < 2; j++) {
var err = erfc(r... | [
"function",
"(",
"x",
")",
"{",
"if",
"(",
"x",
">=",
"2",
")",
"{",
"return",
"-",
"100",
";",
"}",
"if",
"(",
"x",
"<=",
"0",
")",
"{",
"return",
"100",
";",
"}",
"var",
"xx",
"=",
"(",
"x",
"<",
"1",
")",
"?",
"x",
":",
"2",
"-",
"... | Inverse complementary error function From Numerical Recipes 3e p265 | [
"Inverse",
"complementary",
"error",
"function",
"From",
"Numerical",
"Recipes",
"3e",
"p265"
] | 3b3e49cd35f278429af80e310aed85de94d1eb99 | https://github.com/errcw/gaussian/blob/3b3e49cd35f278429af80e310aed85de94d1eb99/lib/gaussian.js#L19-L35 | train | |
errcw/gaussian | lib/gaussian.js | function(mean, variance) {
if (variance <= 0) {
throw new Error('Variance must be > 0 (but was ' + variance + ')');
}
this.mean = mean;
this.variance = variance;
this.standardDeviation = Math.sqrt(variance);
} | javascript | function(mean, variance) {
if (variance <= 0) {
throw new Error('Variance must be > 0 (but was ' + variance + ')');
}
this.mean = mean;
this.variance = variance;
this.standardDeviation = Math.sqrt(variance);
} | [
"function",
"(",
"mean",
",",
"variance",
")",
"{",
"if",
"(",
"variance",
"<=",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Variance must be > 0 (but was '",
"+",
"variance",
"+",
"')'",
")",
";",
"}",
"this",
".",
"mean",
"=",
"mean",
";",
"this",... | Models the normal distribution | [
"Models",
"the",
"normal",
"distribution"
] | 3b3e49cd35f278429af80e310aed85de94d1eb99 | https://github.com/errcw/gaussian/blob/3b3e49cd35f278429af80e310aed85de94d1eb99/lib/gaussian.js#L38-L45 | train | |
mscdex/dicer | lib/HeaderParser.js | HeaderParser | function HeaderParser(cfg) {
EventEmitter.call(this);
var self = this;
this.nread = 0;
this.maxed = false;
this.npairs = 0;
this.maxHeaderPairs = (cfg && typeof cfg.maxHeaderPairs === 'number'
? cfg.maxHeaderPairs
: MAX_HEADER_PAIRS);
this.buffer = '';
... | javascript | function HeaderParser(cfg) {
EventEmitter.call(this);
var self = this;
this.nread = 0;
this.maxed = false;
this.npairs = 0;
this.maxHeaderPairs = (cfg && typeof cfg.maxHeaderPairs === 'number'
? cfg.maxHeaderPairs
: MAX_HEADER_PAIRS);
this.buffer = '';
... | [
"function",
"HeaderParser",
"(",
"cfg",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"nread",
"=",
"0",
";",
"this",
".",
"maxed",
"=",
"false",
";",
"this",
".",
"npairs",
"=",
"0",
... | from node's http_parser | [
"from",
"node",
"s",
"http_parser"
] | 524254c4af4e8f2ed070facac8f6d91538b41eef | https://github.com/mscdex/dicer/blob/524254c4af4e8f2ed070facac8f6d91538b41eef/lib/HeaderParser.js#L12-L42 | train |
josdejong/lossless-json | lib/parse.js | getToken | function getToken() {
tokenType = TOKENTYPE.NULL;
token = '';
// skip over whitespaces: space, tab, newline, and carriage return
while (c === ' ' || c === '\t' || c === '\n' || c === '\r') {
next();
}
// check for delimiters
if (DELIMITERS[c]) {
tokenType = TOKENTYPE.DELIMITER;
token = c;
... | javascript | function getToken() {
tokenType = TOKENTYPE.NULL;
token = '';
// skip over whitespaces: space, tab, newline, and carriage return
while (c === ' ' || c === '\t' || c === '\n' || c === '\r') {
next();
}
// check for delimiters
if (DELIMITERS[c]) {
tokenType = TOKENTYPE.DELIMITER;
token = c;
... | [
"function",
"getToken",
"(",
")",
"{",
"tokenType",
"=",
"TOKENTYPE",
".",
"NULL",
";",
"token",
"=",
"''",
";",
"// skip over whitespaces: space, tab, newline, and carriage return",
"while",
"(",
"c",
"===",
"' '",
"||",
"c",
"===",
"'\\t'",
"||",
"c",
"===",
... | Get next token in the current text.
The token and token type are available as token and tokenType
@private | [
"Get",
"next",
"token",
"in",
"the",
"current",
"text",
".",
"The",
"token",
"and",
"token",
"type",
"are",
"available",
"as",
"token",
"and",
"tokenType"
] | ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd | https://github.com/josdejong/lossless-json/blob/ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd/lib/parse.js#L110-L257 | train |
josdejong/lossless-json | lib/parse.js | createSyntaxError | function createSyntaxError (message, c) {
if (c === undefined) {
c = index - token.length;
}
let error = new SyntaxError(message + ' (char ' + c + ')');
error['char'] = c;
return error;
} | javascript | function createSyntaxError (message, c) {
if (c === undefined) {
c = index - token.length;
}
let error = new SyntaxError(message + ' (char ' + c + ')');
error['char'] = c;
return error;
} | [
"function",
"createSyntaxError",
"(",
"message",
",",
"c",
")",
"{",
"if",
"(",
"c",
"===",
"undefined",
")",
"{",
"c",
"=",
"index",
"-",
"token",
".",
"length",
";",
"}",
"let",
"error",
"=",
"new",
"SyntaxError",
"(",
"message",
"+",
"' (char '",
... | Create an error
@param {string} message
@param {number} [c] Optional index (character position) where the
error happened. If not provided, the start of
the current token is taken
@return {SyntaxError} instantiated error
@private | [
"Create",
"an",
"error"
] | ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd | https://github.com/josdejong/lossless-json/blob/ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd/lib/parse.js#L296-L304 | train |
josdejong/lossless-json | lib/parse.js | parseNumber | function parseNumber () {
if (tokenType === TOKENTYPE.NUMBER) {
let number = new LosslessNumber(token);
getToken();
return number;
}
return parseSymbol();
} | javascript | function parseNumber () {
if (tokenType === TOKENTYPE.NUMBER) {
let number = new LosslessNumber(token);
getToken();
return number;
}
return parseSymbol();
} | [
"function",
"parseNumber",
"(",
")",
"{",
"if",
"(",
"tokenType",
"===",
"TOKENTYPE",
".",
"NUMBER",
")",
"{",
"let",
"number",
"=",
"new",
"LosslessNumber",
"(",
"token",
")",
";",
"getToken",
"(",
")",
";",
"return",
"number",
";",
"}",
"return",
"pa... | Parse a number. The number will be parsed as a LosslessNumber.
@return {*} | [
"Parse",
"a",
"number",
".",
"The",
"number",
"will",
"be",
"parsed",
"as",
"a",
"LosslessNumber",
"."
] | ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd | https://github.com/josdejong/lossless-json/blob/ed6c201b37b5583d2c9c7a7d0b5fc1b3f01519bd/lib/parse.js#L437-L445 | 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.