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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
gmalysa/flux-link | coverage.js | hasFullCoverage | function hasFullCoverage(cov) {
for (var name in cov) {
var file = cov[name];
if (file instanceof Array) {
if (file.coverage !== 100) {
return false;
}
}
}
return true;
} | javascript | function hasFullCoverage(cov) {
for (var name in cov) {
var file = cov[name];
if (file instanceof Array) {
if (file.coverage !== 100) {
return false;
}
}
}
return true;
} | [
"function",
"hasFullCoverage",
"(",
"cov",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"cov",
")",
"{",
"var",
"file",
"=",
"cov",
"[",
"name",
"]",
";",
"if",
"(",
"file",
"instanceof",
"Array",
")",
"{",
"if",
"(",
"file",
".",
"coverage",
"!==",
... | Test if all files have 100% coverage
@param {Object} cov
@return {Boolean} | [
"Test",
"if",
"all",
"files",
"have",
"100%",
"coverage"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/coverage.js#L259-L269 | train |
maxleiko/wsmsgbroker | lib/actions/server/send.js | send | function send(id) {
if (msg.ack) { server._rememberAck(msg.ack, ws.broker_uuid); }
var destWs = server.id2ws[id];
if (destWs) {
if (destWs.readyState === WebSocket.OPEN) {
destWs.send(JSON.stringify({
action: 'message',
message... | javascript | function send(id) {
if (msg.ack) { server._rememberAck(msg.ack, ws.broker_uuid); }
var destWs = server.id2ws[id];
if (destWs) {
if (destWs.readyState === WebSocket.OPEN) {
destWs.send(JSON.stringify({
action: 'message',
message... | [
"function",
"send",
"(",
"id",
")",
"{",
"if",
"(",
"msg",
".",
"ack",
")",
"{",
"server",
".",
"_rememberAck",
"(",
"msg",
".",
"ack",
",",
"ws",
".",
"broker_uuid",
")",
";",
"}",
"var",
"destWs",
"=",
"server",
".",
"id2ws",
"[",
"id",
"]",
... | Re-wraps incoming 'send' message into a 'message' message to the specified destination
@param id | [
"Re",
"-",
"wraps",
"incoming",
"send",
"message",
"into",
"a",
"message",
"message",
"to",
"the",
"specified",
"destination"
] | b42daba04d3e4fc33ba278244bcb81a72cdc2ce5 | https://github.com/maxleiko/wsmsgbroker/blob/b42daba04d3e4fc33ba278244bcb81a72cdc2ce5/lib/actions/server/send.js#L18-L37 | train |
shinuza/captain-core | lib/db.js | load | function load(filename) {
return function(cb) {
var file = path.join(process.cwd(), filename)
, json = require(file)
, model = exports[json.table]
, rows = json.rows;
console.log('Loading', file);
run();
function run() {
var row = rows.shift();
if(row !== undefined) {
... | javascript | function load(filename) {
return function(cb) {
var file = path.join(process.cwd(), filename)
, json = require(file)
, model = exports[json.table]
, rows = json.rows;
console.log('Loading', file);
run();
function run() {
var row = rows.shift();
if(row !== undefined) {
... | [
"function",
"load",
"(",
"filename",
")",
"{",
"return",
"function",
"(",
"cb",
")",
"{",
"var",
"file",
"=",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"filename",
")",
",",
"json",
"=",
"require",
"(",
"file",
")",
",",
"mo... | Loads `filename` in the database
@param {String} filename | [
"Loads",
"filename",
"in",
"the",
"database"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/db.js#L86-L112 | train |
shinuza/captain-core | lib/db.js | connect | function connect(uri, cb) {
pg.connect(uri, function(err, client, done) {
// Backwards compatibility with pg
if(typeof done === 'undefined') { done = noop; }
if(err) {
cb(err, null, done);
} else {
cb(null, client, done);
}
});
} | javascript | function connect(uri, cb) {
pg.connect(uri, function(err, client, done) {
// Backwards compatibility with pg
if(typeof done === 'undefined') { done = noop; }
if(err) {
cb(err, null, done);
} else {
cb(null, client, done);
}
});
} | [
"function",
"connect",
"(",
"uri",
",",
"cb",
")",
"{",
"pg",
".",
"connect",
"(",
"uri",
",",
"function",
"(",
"err",
",",
"client",
",",
"done",
")",
"{",
"// Backwards compatibility with pg",
"if",
"(",
"typeof",
"done",
"===",
"'undefined'",
")",
"{"... | Connects to database at `uri`
@param {String} uri
@param {Function} cb | [
"Connects",
"to",
"database",
"at",
"uri"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/db.js#L122-L132 | train |
shinuza/captain-core | lib/db.js | getClient | function getClient(uri, cb) {
if(typeof uri === 'function') {
cb = uri;
uri = conf.db;
}
connect(uri, function(err, client, done) {
if(err) {
cb(err, null, done);
} else {
cb(null, client, done);
}
});
} | javascript | function getClient(uri, cb) {
if(typeof uri === 'function') {
cb = uri;
uri = conf.db;
}
connect(uri, function(err, client, done) {
if(err) {
cb(err, null, done);
} else {
cb(null, client, done);
}
});
} | [
"function",
"getClient",
"(",
"uri",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"uri",
"===",
"'function'",
")",
"{",
"cb",
"=",
"uri",
";",
"uri",
"=",
"conf",
".",
"db",
";",
"}",
"connect",
"(",
"uri",
",",
"function",
"(",
"err",
",",
"client"... | Returns a pg client, you can either specify a connection uri
or let the function use `conf.db`
### Example:
```js
getClient('tcp://anon@acme.com', function(err, client, done) {});
```
```js
getClient(function(err, client, done) {});
```
@param {*} uri
@param {Function} cb | [
"Returns",
"a",
"pg",
"client",
"you",
"can",
"either",
"specify",
"a",
"connection",
"uri",
"or",
"let",
"the",
"function",
"use",
"conf",
".",
"db"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/db.js#L153-L165 | train |
jantimon/ng-directive-parser | lib/esprima-helpers.js | getFirstReturnStatement | function getFirstReturnStatement(node) {
if (!node || !node.body) {
return;
}
if (node.body.type === 'BlockStatement') {
node = node.body;
}
for (var i = 0; i < node.body.length; i++) {
if (node.body[i].type === 'ReturnStatement') {
return node.body[i];
}
}
} | javascript | function getFirstReturnStatement(node) {
if (!node || !node.body) {
return;
}
if (node.body.type === 'BlockStatement') {
node = node.body;
}
for (var i = 0; i < node.body.length; i++) {
if (node.body[i].type === 'ReturnStatement') {
return node.body[i];
}
}
} | [
"function",
"getFirstReturnStatement",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
"||",
"!",
"node",
".",
"body",
")",
"{",
"return",
";",
"}",
"if",
"(",
"node",
".",
"body",
".",
"type",
"===",
"'BlockStatement'",
")",
"{",
"node",
"=",
"node",... | Pareses a FunctionExpression or BlockStatement and returns the first ReturnStatement
@param node
@returns {*} | [
"Pareses",
"a",
"FunctionExpression",
"or",
"BlockStatement",
"and",
"returns",
"the",
"first",
"ReturnStatement"
] | e7bb3b800243be7399d8af3ab2546dd3f159beda | https://github.com/jantimon/ng-directive-parser/blob/e7bb3b800243be7399d8af3ab2546dd3f159beda/lib/esprima-helpers.js#L28-L40 | train |
hashkitty/ckwallet-core | providers/database/sql-client.js | get | function get(tableName, fieldNames, where, orderBy) {
if (orderBy && !checkOrderBy(orderBy)) {
throw new Error('Invalid arg: orderBy');
}
if (!db) {
throw new Error('Not connected');
}
let sql = `SELECT ${fieldNames.join(',')} FROM ${tableName}`;
if (where) {
sql += ` WHERE ${w... | javascript | function get(tableName, fieldNames, where, orderBy) {
if (orderBy && !checkOrderBy(orderBy)) {
throw new Error('Invalid arg: orderBy');
}
if (!db) {
throw new Error('Not connected');
}
let sql = `SELECT ${fieldNames.join(',')} FROM ${tableName}`;
if (where) {
sql += ` WHERE ${w... | [
"function",
"get",
"(",
"tableName",
",",
"fieldNames",
",",
"where",
",",
"orderBy",
")",
"{",
"if",
"(",
"orderBy",
"&&",
"!",
"checkOrderBy",
"(",
"orderBy",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid arg: orderBy'",
")",
";",
"}",
"if",
... | return single row | [
"return",
"single",
"row"
] | 968d38f0e7fc443f4009f1efce54a84ef8cd1fc9 | https://github.com/hashkitty/ckwallet-core/blob/968d38f0e7fc443f4009f1efce54a84ef8cd1fc9/providers/database/sql-client.js#L72-L95 | train |
hashkitty/ckwallet-core | providers/database/sql-client.js | all | function all(tableName, fieldNames, where, orderBy, limit = null, join = null) {
if (orderBy && !checkOrderBy(orderBy)) {
throw new Error('Invalid arg: orderBy');
}
if (!db) {
throw new Error('Not connected');
}
let sql = `SELECT ${fieldNames.join(',')} FROM ${tableName}`;
if (join)... | javascript | function all(tableName, fieldNames, where, orderBy, limit = null, join = null) {
if (orderBy && !checkOrderBy(orderBy)) {
throw new Error('Invalid arg: orderBy');
}
if (!db) {
throw new Error('Not connected');
}
let sql = `SELECT ${fieldNames.join(',')} FROM ${tableName}`;
if (join)... | [
"function",
"all",
"(",
"tableName",
",",
"fieldNames",
",",
"where",
",",
"orderBy",
",",
"limit",
"=",
"null",
",",
"join",
"=",
"null",
")",
"{",
"if",
"(",
"orderBy",
"&&",
"!",
"checkOrderBy",
"(",
"orderBy",
")",
")",
"{",
"throw",
"new",
"Erro... | return all rows | [
"return",
"all",
"rows"
] | 968d38f0e7fc443f4009f1efce54a84ef8cd1fc9 | https://github.com/hashkitty/ckwallet-core/blob/968d38f0e7fc443f4009f1efce54a84ef8cd1fc9/providers/database/sql-client.js#L98-L128 | train |
gavinhungry/rudiment | rudiment.js | function(db) {
if (!db.type) {
return defaultDbType;
}
return dbTypes.find(function(dbType) {
return dbType.name === db.type;
}) || null;
} | javascript | function(db) {
if (!db.type) {
return defaultDbType;
}
return dbTypes.find(function(dbType) {
return dbType.name === db.type;
}) || null;
} | [
"function",
"(",
"db",
")",
"{",
"if",
"(",
"!",
"db",
".",
"type",
")",
"{",
"return",
"defaultDbType",
";",
"}",
"return",
"dbTypes",
".",
"find",
"(",
"function",
"(",
"dbType",
")",
"{",
"return",
"dbType",
".",
"name",
"===",
"db",
".",
"type"... | Given a database object, get the database type
@param {Object} db - database object passed to Rudiment constructor
@return {Object|null} object from dbTypes | [
"Given",
"a",
"database",
"object",
"get",
"the",
"database",
"type"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L28-L36 | train | |
gavinhungry/rudiment | rudiment.js | function(obj, keys) {
return keys.reduce(function(memo, key) {
if (obj[key] !== undefined) {
memo[key] = obj[key];
}
return memo;
}, {});
} | javascript | function(obj, keys) {
return keys.reduce(function(memo, key) {
if (obj[key] !== undefined) {
memo[key] = obj[key];
}
return memo;
}, {});
} | [
"function",
"(",
"obj",
",",
"keys",
")",
"{",
"return",
"keys",
".",
"reduce",
"(",
"function",
"(",
"memo",
",",
"key",
")",
"{",
"if",
"(",
"obj",
"[",
"key",
"]",
"!==",
"undefined",
")",
"{",
"memo",
"[",
"key",
"]",
"=",
"obj",
"[",
"key"... | Return a copy of an object with only the picked keys
@param {Object} obj
@param {Array} keys
@return {Object} | [
"Return",
"a",
"copy",
"of",
"an",
"object",
"with",
"only",
"the",
"picked",
"keys"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L45-L53 | train | |
gavinhungry/rudiment | rudiment.js | function(doc) {
if (!this._props) {
return doc;
}
return this._props.reduce(function(obj, prop) {
if (doc.hasOwnProperty(prop)) {
obj[prop] = doc[prop];
}
return obj;
}, {});
} | javascript | function(doc) {
if (!this._props) {
return doc;
}
return this._props.reduce(function(obj, prop) {
if (doc.hasOwnProperty(prop)) {
obj[prop] = doc[prop];
}
return obj;
}, {});
} | [
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_props",
")",
"{",
"return",
"doc",
";",
"}",
"return",
"this",
".",
"_props",
".",
"reduce",
"(",
"function",
"(",
"obj",
",",
"prop",
")",
"{",
"if",
"(",
"doc",
".",
"hasOwnProper... | Remove extraneous properties from a proposed document
@param {Object} doc - a document to clean
@return {Object} a copy of the cleaned document | [
"Remove",
"extraneous",
"properties",
"from",
"a",
"proposed",
"document"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L177-L189 | train | |
gavinhungry/rudiment | rudiment.js | function(doc) {
if (!this.isValid(doc)) {
return Promise.resolve(false);
}
var props = pick(doc, this._uniq);
if (!Object.keys(props).length) {
return Promise.resolve(true);
}
return this._dbApi.isAdmissible(doc, props);
} | javascript | function(doc) {
if (!this.isValid(doc)) {
return Promise.resolve(false);
}
var props = pick(doc, this._uniq);
if (!Object.keys(props).length) {
return Promise.resolve(true);
}
return this._dbApi.isAdmissible(doc, props);
} | [
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isValid",
"(",
"doc",
")",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"false",
")",
";",
"}",
"var",
"props",
"=",
"pick",
"(",
"doc",
",",
"this",
".",
"_uniq",
")",
";",... | Check if a proposed document is admissible into the database
A document is admissible if it passes the valid predicate, and no other
document in the database is already using its unique keys.
@param {Object} doc - a document to test
@return {Promise} | [
"Check",
"if",
"a",
"proposed",
"document",
"is",
"admissible",
"into",
"the",
"database"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L215-L226 | train | |
gavinhungry/rudiment | rudiment.js | function(doc) {
var that = this;
doc = that._in_map(doc);
return this._init.then(function() {
return that.isAdmissible(doc);
}).then(function(admissible) {
if (!admissible) {
throw new Error('Document not admissible');
}
doc = that.clean(doc);
... | javascript | function(doc) {
var that = this;
doc = that._in_map(doc);
return this._init.then(function() {
return that.isAdmissible(doc);
}).then(function(admissible) {
if (!admissible) {
throw new Error('Document not admissible');
}
doc = that.clean(doc);
... | [
"function",
"(",
"doc",
")",
"{",
"var",
"that",
"=",
"this",
";",
"doc",
"=",
"that",
".",
"_in_map",
"(",
"doc",
")",
";",
"return",
"this",
".",
"_init",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"that",
".",
"isAdmissible",
"(",
... | Create and insert a new document into the database
@param {Object} doc - a document to insert
@return {Promise} | [
"Create",
"and",
"insert",
"a",
"new",
"document",
"into",
"the",
"database"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L234-L265 | train | |
gavinhungry/rudiment | rudiment.js | function(props) {
var that = this;
return this._dbApi.find(props || {}).then(function(docs) {
return docs.map(that._out_map);
});
} | javascript | function(props) {
var that = this;
return this._dbApi.find(props || {}).then(function(docs) {
return docs.map(that._out_map);
});
} | [
"function",
"(",
"props",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"_dbApi",
".",
"find",
"(",
"props",
"||",
"{",
"}",
")",
".",
"then",
"(",
"function",
"(",
"docs",
")",
"{",
"return",
"docs",
".",
"map",
"(",
"that",
... | Get all documents from the database with matching properties
@param {Object} props
@return {Promise} -> {Array} | [
"Get",
"all",
"documents",
"from",
"the",
"database",
"with",
"matching",
"properties"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L273-L279 | train | |
gavinhungry/rudiment | rudiment.js | function(id) {
var that = this;
return this._dbApi.read(id).then(function(doc) {
return that._readDoc(doc);
});
} | javascript | function(id) {
var that = this;
return this._dbApi.read(id).then(function(doc) {
return that._readDoc(doc);
});
} | [
"function",
"(",
"id",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"_dbApi",
".",
"read",
"(",
"id",
")",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"return",
"that",
".",
"_readDoc",
"(",
"doc",
")",
";",
"}",
")... | Get a document from the database by database ID
@param {String} id
@return {Promise} | [
"Get",
"a",
"document",
"from",
"the",
"database",
"by",
"database",
"ID"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L295-L301 | train | |
gavinhungry/rudiment | rudiment.js | function(key) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
var props = {};
props[this._key] = key;
return this._dbApi.find(props).then(function(docs) {
return that._readDoc(docs[0]);
});
} | javascript | function(key) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
var props = {};
props[this._key] = key;
return this._dbApi.find(props).then(function(docs) {
return that._readDoc(docs[0]);
});
} | [
"function",
"(",
"key",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"_key",
"||",
"!",
"key",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'No unique key specified'",
")",
")",
";",
"}",
"var"... | Get a document from the database by key
@param {String} key
@return {Promise} | [
"Get",
"a",
"document",
"from",
"the",
"database",
"by",
"key"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L309-L322 | train | |
gavinhungry/rudiment | rudiment.js | function(index) {
var that = this;
var props = this._propIndex(index);
if (!props) {
return Promise.reject(new Error('No auto-indexing key specified'));
}
return this._dbApi.find(props).then(function(docs) {
return that._readDoc(docs[0]);
});
} | javascript | function(index) {
var that = this;
var props = this._propIndex(index);
if (!props) {
return Promise.reject(new Error('No auto-indexing key specified'));
}
return this._dbApi.find(props).then(function(docs) {
return that._readDoc(docs[0]);
});
} | [
"function",
"(",
"index",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"props",
"=",
"this",
".",
"_propIndex",
"(",
"index",
")",
";",
"if",
"(",
"!",
"props",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'No auto-... | Get a document from the database by auto-index
@param {Number|String} index
@return {Promise} | [
"Get",
"a",
"document",
"from",
"the",
"database",
"by",
"auto",
"-",
"index"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L349-L360 | train | |
gavinhungry/rudiment | rudiment.js | function(doc, updates) {
updates = this._in_map(updates || {});
Object.keys(doc).forEach(function(prop) {
if (updates.hasOwnProperty(prop)) {
doc[prop] = updates[prop];
}
});
if (!this.isValid(doc)) {
throw new Error('Updated document is invalid');
}
... | javascript | function(doc, updates) {
updates = this._in_map(updates || {});
Object.keys(doc).forEach(function(prop) {
if (updates.hasOwnProperty(prop)) {
doc[prop] = updates[prop];
}
});
if (!this.isValid(doc)) {
throw new Error('Updated document is invalid');
}
... | [
"function",
"(",
"doc",
",",
"updates",
")",
"{",
"updates",
"=",
"this",
".",
"_in_map",
"(",
"updates",
"||",
"{",
"}",
")",
";",
"Object",
".",
"keys",
"(",
"doc",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"update... | Update an existing database document
The unique values of a document cannot be updated with this method.
Delete the document and create a new document instead.
@private
@param {Document} doc
@param {Object} updates - updates to apply to document
@return {Promise} | [
"Update",
"an",
"existing",
"database",
"document"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L383-L404 | train | |
gavinhungry/rudiment | rudiment.js | function(id, updates) {
var that = this;
return this.read(id).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | javascript | function(id, updates) {
var that = this;
return this.read(id).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | [
"function",
"(",
"id",
",",
"updates",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"read",
"(",
"id",
")",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"return",
"that",
".",
"_updateDoc",
"(",
"doc",
",",
"updates",
... | Update a document in the database by database ID
@param {String} id
@param {Object} updates - updates to apply to document
@return {Promise} | [
"Update",
"a",
"document",
"in",
"the",
"database",
"by",
"database",
"ID"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L413-L419 | train | |
gavinhungry/rudiment | rudiment.js | function(key, updates) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
return this.readByKey(key).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | javascript | function(key, updates) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
return this.readByKey(key).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | [
"function",
"(",
"key",
",",
"updates",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"_key",
"||",
"!",
"key",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'No unique key specified'",
")",
")",
... | Update a document in the database by key
@param {String} key
@param {Object} updates - updates to apply to document
@return {Promise} | [
"Update",
"a",
"document",
"in",
"the",
"database",
"by",
"key"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L428-L438 | train | |
gavinhungry/rudiment | rudiment.js | function(index, updates) {
var that = this;
return this.readByIndex(index).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | javascript | function(index, updates) {
var that = this;
return this.readByIndex(index).then(function(doc) {
return that._updateDoc(doc, updates);
});
} | [
"function",
"(",
"index",
",",
"updates",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"readByIndex",
"(",
"index",
")",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"return",
"that",
".",
"_updateDoc",
"(",
"doc",
",",
... | Update a document in the database by auto-index
@param {Number|String} index
@param {Object} updates - updates to apply to document
@return {Promise} | [
"Update",
"a",
"document",
"in",
"the",
"database",
"by",
"auto",
"-",
"index"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L447-L453 | train | |
gavinhungry/rudiment | rudiment.js | function(key) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
return this.readByKey(key).then(function(doc) {
return that.delete(doc[that._dbType.id]);
});
} | javascript | function(key) {
var that = this;
if (!this._key || !key) {
return Promise.reject(new Error('No unique key specified'));
}
return this.readByKey(key).then(function(doc) {
return that.delete(doc[that._dbType.id]);
});
} | [
"function",
"(",
"key",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"_key",
"||",
"!",
"key",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'No unique key specified'",
")",
")",
";",
"}",
"retu... | Delete a document from the database by key
@param {String} key
@return {Promise} | [
"Delete",
"a",
"document",
"from",
"the",
"database",
"by",
"key"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L475-L485 | train | |
gavinhungry/rudiment | rudiment.js | function(index) {
var that = this;
return this.readByIndex(index).then(function(doc) {
return that.delete(doc[that._dbType.id]);
});
} | javascript | function(index) {
var that = this;
return this.readByIndex(index).then(function(doc) {
return that.delete(doc[that._dbType.id]);
});
} | [
"function",
"(",
"index",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"readByIndex",
"(",
"index",
")",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"return",
"that",
".",
"delete",
"(",
"doc",
"[",
"that",
".",
"_dbTyp... | Delete a document from the database by auto-index
@param {Number|String} index
@return {Promise} | [
"Delete",
"a",
"document",
"from",
"the",
"database",
"by",
"auto",
"-",
"index"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L493-L499 | train | |
gavinhungry/rudiment | rudiment.js | function(operation, res) {
var that = this;
var method = res.req.method;
return operation.then(function(doc) {
if (method === 'POST') {
if (that._path && (that._key || that._index)) {
res.header('Location', '/' + that._path + '/' + doc[that._key || that._index]);
... | javascript | function(operation, res) {
var that = this;
var method = res.req.method;
return operation.then(function(doc) {
if (method === 'POST') {
if (that._path && (that._key || that._index)) {
res.header('Location', '/' + that._path + '/' + doc[that._key || that._index]);
... | [
"function",
"(",
"operation",
",",
"res",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"method",
"=",
"res",
".",
"req",
".",
"method",
";",
"return",
"operation",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"method",
"===",... | Middleware REST handler for CRUD operations
@param {Promise} operation
@param {ServerResponse} res | [
"Middleware",
"REST",
"handler",
"for",
"CRUD",
"operations"
] | b4e77deb794d11bcae5598736905bb630ee65329 | https://github.com/gavinhungry/rudiment/blob/b4e77deb794d11bcae5598736905bb630ee65329/rudiment.js#L507-L534 | train | |
thirdcoder/trit-getset | getset.js | get_trit | function get_trit(n,i) {
// convert entire number to balanced ternary string then slice
// would be nice to extract without converting everything, see extract_digit(), which
// works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit extraction
// is more difficult -- see https://en.wiki... | javascript | function get_trit(n,i) {
// convert entire number to balanced ternary string then slice
// would be nice to extract without converting everything, see extract_digit(), which
// works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit extraction
// is more difficult -- see https://en.wiki... | [
"function",
"get_trit",
"(",
"n",
",",
"i",
")",
"{",
"// convert entire number to balanced ternary string then slice",
"// would be nice to extract without converting everything, see extract_digit(), which",
"// works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit ex... | get trit value at ith index of n, i of 0=least significant | [
"get",
"trit",
"value",
"at",
"ith",
"index",
"of",
"n",
"i",
"of",
"0",
"=",
"least",
"significant"
] | bb80f19e943cf2ee7f8a0039f780e06100db6600 | https://github.com/thirdcoder/trit-getset/blob/bb80f19e943cf2ee7f8a0039f780e06100db6600/getset.js#L9-L16 | train |
nodys/htmly | lib/processor.js | resolveFunctionList | function resolveFunctionList (functionList, basedir) {
if (!functionList) return []
return (Array.isArray(functionList) ? functionList : [functionList])
.map(function (proc) {
if (typeof (proc) === 'string') {
proc = require(resolve.sync(proc, { basedir: basedir }))
}
return toAsync(pr... | javascript | function resolveFunctionList (functionList, basedir) {
if (!functionList) return []
return (Array.isArray(functionList) ? functionList : [functionList])
.map(function (proc) {
if (typeof (proc) === 'string') {
proc = require(resolve.sync(proc, { basedir: basedir }))
}
return toAsync(pr... | [
"function",
"resolveFunctionList",
"(",
"functionList",
",",
"basedir",
")",
"{",
"if",
"(",
"!",
"functionList",
")",
"return",
"[",
"]",
"return",
"(",
"Array",
".",
"isArray",
"(",
"functionList",
")",
"?",
"functionList",
":",
"[",
"functionList",
"]",
... | Resolve and require a list of module path that exports async function
Each path is resolved against `basedir`. `utils.toAsync()` unsure that
each function will work as async function.
@param {Array|String} functionList
Module path or array of module path
@param {String} basedir
Base path for path resolution (dirname... | [
"Resolve",
"and",
"require",
"a",
"list",
"of",
"module",
"path",
"that",
"exports",
"async",
"function"
] | 770560274167b7efd78cf56544ec72f52efb3fb8 | https://github.com/nodys/htmly/blob/770560274167b7efd78cf56544ec72f52efb3fb8/lib/processor.js#L143-L152 | train |
chrisocast/grunt-faker | tasks/faker.js | processJson | function processJson(obj) {
for (var i in obj) {
if (typeof(obj[i]) === "object") {
processJson(obj[i]); // found an obj or array keep digging
} else if (obj[i] !== null){
obj[i] = getFunctionNameAndArgs(obj[i]);// not an obj or array, check contents
}
}
return obj;
} | javascript | function processJson(obj) {
for (var i in obj) {
if (typeof(obj[i]) === "object") {
processJson(obj[i]); // found an obj or array keep digging
} else if (obj[i] !== null){
obj[i] = getFunctionNameAndArgs(obj[i]);// not an obj or array, check contents
}
}
return obj;
} | [
"function",
"processJson",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"obj",
")",
"{",
"if",
"(",
"typeof",
"(",
"obj",
"[",
"i",
"]",
")",
"===",
"\"object\"",
")",
"{",
"processJson",
"(",
"obj",
"[",
"i",
"]",
")",
";",
"// found an o... | Loop through entire json object | [
"Loop",
"through",
"entire",
"json",
"object"
] | 8fa81b0e4839ffba4089cd93e091628e39447e94 | https://github.com/chrisocast/grunt-faker/blob/8fa81b0e4839ffba4089cd93e091628e39447e94/tasks/faker.js#L17-L26 | train |
chrisocast/grunt-faker | tasks/faker.js | getFunctionNameAndArgs | function getFunctionNameAndArgs(value) {
var pattern = /^(.*)\{\{([^()]+?)(\((.+)\))?\}\}(.*)$/g,
match, func, args;
var argArray = [], surroundings = [];
var retValue;
while (match = pattern.exec(value)) {
surroundings[0] = match[1];
func = match[2];
args = match[4];
surrou... | javascript | function getFunctionNameAndArgs(value) {
var pattern = /^(.*)\{\{([^()]+?)(\((.+)\))?\}\}(.*)$/g,
match, func, args;
var argArray = [], surroundings = [];
var retValue;
while (match = pattern.exec(value)) {
surroundings[0] = match[1];
func = match[2];
args = match[4];
surrou... | [
"function",
"getFunctionNameAndArgs",
"(",
"value",
")",
"{",
"var",
"pattern",
"=",
"/",
"^(.*)\\{\\{([^()]+?)(\\((.+)\\))?\\}\\}(.*)$",
"/",
"g",
",",
"match",
",",
"func",
",",
"args",
";",
"var",
"argArray",
"=",
"[",
"]",
",",
"surroundings",
"=",
"[",
... | Get func name, extract args, and exec on their values | [
"Get",
"func",
"name",
"extract",
"args",
"and",
"exec",
"on",
"their",
"values"
] | 8fa81b0e4839ffba4089cd93e091628e39447e94 | https://github.com/chrisocast/grunt-faker/blob/8fa81b0e4839ffba4089cd93e091628e39447e94/tasks/faker.js#L29-L68 | train |
chrisocast/grunt-faker | tasks/faker.js | executeFunctionByName | function executeFunctionByName(functionName, args) {
var namespaces = functionName.split(".");
var nsLength = namespaces.length;
var context = Faker;
var parentContext = Faker;
if (namespaces[0].toLowerCase() === 'definitions'){
grunt.log.warn('The definitions module from Faker.js is not avai... | javascript | function executeFunctionByName(functionName, args) {
var namespaces = functionName.split(".");
var nsLength = namespaces.length;
var context = Faker;
var parentContext = Faker;
if (namespaces[0].toLowerCase() === 'definitions'){
grunt.log.warn('The definitions module from Faker.js is not avai... | [
"function",
"executeFunctionByName",
"(",
"functionName",
",",
"args",
")",
"{",
"var",
"namespaces",
"=",
"functionName",
".",
"split",
"(",
"\".\"",
")",
";",
"var",
"nsLength",
"=",
"namespaces",
".",
"length",
";",
"var",
"context",
"=",
"Faker",
";",
... | Execute function as string | [
"Execute",
"function",
"as",
"string"
] | 8fa81b0e4839ffba4089cd93e091628e39447e94 | https://github.com/chrisocast/grunt-faker/blob/8fa81b0e4839ffba4089cd93e091628e39447e94/tasks/faker.js#L71-L91 | train |
troygoode/node-tsa | lib/guard.js | function(){
if(errors.length) return cb(errors);
var transform = opts.transform || function(_result, _cb){
_cb(null, _result);
};
transform(result, function(err, _result){
if(err){
errors.push(formatError(err, key));
... | javascript | function(){
if(errors.length) return cb(errors);
var transform = opts.transform || function(_result, _cb){
_cb(null, _result);
};
transform(result, function(err, _result){
if(err){
errors.push(formatError(err, key));
... | [
"function",
"(",
")",
"{",
"if",
"(",
"errors",
".",
"length",
")",
"return",
"cb",
"(",
"errors",
")",
";",
"var",
"transform",
"=",
"opts",
".",
"transform",
"||",
"function",
"(",
"_result",
",",
"_cb",
")",
"{",
"_cb",
"(",
"null",
",",
"_resul... | setup function to call once all keys have been recursed | [
"setup",
"function",
"to",
"call",
"once",
"all",
"keys",
"have",
"been",
"recursed"
] | a58d40f9b77a248504b96e7704ca6a9a48e0b4ba | https://github.com/troygoode/node-tsa/blob/a58d40f9b77a248504b96e7704ca6a9a48e0b4ba/lib/guard.js#L47-L60 | train | |
kasargeant/tinter | src/js/Tinter.js | function(text, color=[255,255,255], colorBg=[0,0,0], style="reset") {
// First check for raw RGB truecolor code... if the console scheme
// supports this then no probs... but if not - we need to degrade appropriately.
if(color.constructor === Array && colorBg.constructor === Array) {
... | javascript | function(text, color=[255,255,255], colorBg=[0,0,0], style="reset") {
// First check for raw RGB truecolor code... if the console scheme
// supports this then no probs... but if not - we need to degrade appropriately.
if(color.constructor === Array && colorBg.constructor === Array) {
... | [
"function",
"(",
"text",
",",
"color",
"=",
"[",
"255",
",",
"255",
",",
"255",
"]",
",",
"colorBg",
"=",
"[",
"0",
",",
"0",
",",
"0",
"]",
",",
"style",
"=",
"\"reset\"",
")",
"{",
"// First check for raw RGB truecolor code... if the console scheme",
"//... | Marks the text string with multiple RGB colors and ANSI named style characteristics.
@param {string} text - the text string to be colorized and/or styled.
@param {Array} color - an RGB integer array representing the foreground color.
@param {Array} colorBg - an RGB integer array representing the foreground color.
@para... | [
"Marks",
"the",
"text",
"string",
"with",
"multiple",
"RGB",
"colors",
"and",
"ANSI",
"named",
"style",
"characteristics",
"."
] | a9fbce086558ec9682e104f39324b0a00c52f98c | https://github.com/kasargeant/tinter/blob/a9fbce086558ec9682e104f39324b0a00c52f98c/src/js/Tinter.js#L533-L545 | train | |
longbill/precise-number | index.js | decimalLength | function decimalLength(n) {
let ns = cleanNumber(n).toString();
let ems = ns.match(/e([\+\-]\d+)$/);
let e = 0;
if (ems && ems[1]) e = parseInt(ems[1]);
ns = ns.replace(/e[\-\+]\d+$/, '');
let parts = ns.split('.', 2);
if (parts.length === 1) return -e;
return parts[1].length - e;
} | javascript | function decimalLength(n) {
let ns = cleanNumber(n).toString();
let ems = ns.match(/e([\+\-]\d+)$/);
let e = 0;
if (ems && ems[1]) e = parseInt(ems[1]);
ns = ns.replace(/e[\-\+]\d+$/, '');
let parts = ns.split('.', 2);
if (parts.length === 1) return -e;
return parts[1].length - e;
} | [
"function",
"decimalLength",
"(",
"n",
")",
"{",
"let",
"ns",
"=",
"cleanNumber",
"(",
"n",
")",
".",
"toString",
"(",
")",
";",
"let",
"ems",
"=",
"ns",
".",
"match",
"(",
"/",
"e([\\+\\-]\\d+)$",
"/",
")",
";",
"let",
"e",
"=",
"0",
";",
"if",
... | calculate the decimal part length of a number | [
"calculate",
"the",
"decimal",
"part",
"length",
"of",
"a",
"number"
] | 690b08e745af7b6b9f82649a6e7ee06a9ca88588 | https://github.com/longbill/precise-number/blob/690b08e745af7b6b9f82649a6e7ee06a9ca88588/index.js#L167-L176 | train |
meisterplayer/js-dev | gulp/clean.js | createClean | function createClean(inPath) {
if (!inPath) {
throw new Error('Input path argument is required');
}
return function cleanDir() {
return gulp.src(inPath, { read: false }).pipe(clean());
};
} | javascript | function createClean(inPath) {
if (!inPath) {
throw new Error('Input path argument is required');
}
return function cleanDir() {
return gulp.src(inPath, { read: false }).pipe(clean());
};
} | [
"function",
"createClean",
"(",
"inPath",
")",
"{",
"if",
"(",
"!",
"inPath",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Input path argument is required'",
")",
";",
"}",
"return",
"function",
"cleanDir",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
... | Higher order function to create gulp function that cleans directories.
@param {string|string[]} inPath The globs to the files/directories that need to be removed
@return {function} Function that can be used as a gulp task | [
"Higher",
"order",
"function",
"to",
"create",
"gulp",
"function",
"that",
"cleans",
"directories",
"."
] | c2646678c49dcdaa120ba3f24824da52b0c63e31 | https://github.com/meisterplayer/js-dev/blob/c2646678c49dcdaa120ba3f24824da52b0c63e31/gulp/clean.js#L9-L17 | train |
byu-oit/sans-server-swagger | bin/exception.js | Exception | function Exception(code, message) {
const factory = Object.create(Exception.prototype);
factory.code = code;
factory.message = message;
factory.stack = factory.toString();
return factory;
} | javascript | function Exception(code, message) {
const factory = Object.create(Exception.prototype);
factory.code = code;
factory.message = message;
factory.stack = factory.toString();
return factory;
} | [
"function",
"Exception",
"(",
"code",
",",
"message",
")",
"{",
"const",
"factory",
"=",
"Object",
".",
"create",
"(",
"Exception",
".",
"prototype",
")",
";",
"factory",
".",
"code",
"=",
"code",
";",
"factory",
".",
"message",
"=",
"message",
";",
"f... | Create a swagger response instance.
@param {Number} code
@param {String} [message]
@returns {Exception}
@constructor | [
"Create",
"a",
"swagger",
"response",
"instance",
"."
] | 455e76b8d65451e606e3c7894ff08affbeb447f1 | https://github.com/byu-oit/sans-server-swagger/blob/455e76b8d65451e606e3c7894ff08affbeb447f1/bin/exception.js#L27-L33 | train |
andrey-p/arg-err | index.js | someSchemasValidate | function someSchemasValidate(propName) {
return schema[propName].some(function (possibleType) {
var tempInput = {},
tempSchema = {},
tempErrs;
tempInput[propName] = input[propName];
tempSchema[propName] = possibleType;
tempErrs = getErrs({
input: tempInput,
s... | javascript | function someSchemasValidate(propName) {
return schema[propName].some(function (possibleType) {
var tempInput = {},
tempSchema = {},
tempErrs;
tempInput[propName] = input[propName];
tempSchema[propName] = possibleType;
tempErrs = getErrs({
input: tempInput,
s... | [
"function",
"someSchemasValidate",
"(",
"propName",
")",
"{",
"return",
"schema",
"[",
"propName",
"]",
".",
"some",
"(",
"function",
"(",
"possibleType",
")",
"{",
"var",
"tempInput",
"=",
"{",
"}",
",",
"tempSchema",
"=",
"{",
"}",
",",
"tempErrs",
";"... | used for array schema types where all we need is to pass a single array element | [
"used",
"for",
"array",
"schema",
"types",
"where",
"all",
"we",
"need",
"is",
"to",
"pass",
"a",
"single",
"array",
"element"
] | b2aeb45c17f6828821c8b12ffd41ff028a8d360b | https://github.com/andrey-p/arg-err/blob/b2aeb45c17f6828821c8b12ffd41ff028a8d360b/index.js#L83-L99 | train |
intervolga/bem-utils | lib/first-exist.js | firstExist | function firstExist(fileNames) {
const head = fileNames.slice(0, 1);
if (head.length === 0) {
return new Promise((resolve, reject) => {
resolve(false);
});
}
const tail = fileNames.slice(1);
return fileExist(head[0]).then((result) => {
if (false === result) {
return firstExist(tail);
... | javascript | function firstExist(fileNames) {
const head = fileNames.slice(0, 1);
if (head.length === 0) {
return new Promise((resolve, reject) => {
resolve(false);
});
}
const tail = fileNames.slice(1);
return fileExist(head[0]).then((result) => {
if (false === result) {
return firstExist(tail);
... | [
"function",
"firstExist",
"(",
"fileNames",
")",
"{",
"const",
"head",
"=",
"fileNames",
".",
"slice",
"(",
"0",
",",
"1",
")",
";",
"if",
"(",
"head",
".",
"length",
"===",
"0",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reje... | Search for first existing file
@param {Array} fileNames
@return {Promise} | [
"Search",
"for",
"first",
"existing",
"file"
] | 3b81bb9bc408275486175326dc7f35c563a46563 | https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/first-exist.js#L9-L25 | train |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(csg) {
var newpolygons = this.polygons.concat(csg.polygons);
var result = CSG.fromPolygons(newpolygons);
result.properties = this.properties._merge(csg.properties);
result.isCanonicalized = this.isCanonicalized && csg.isCanonicalized;
result.isRetesse... | javascript | function(csg) {
var newpolygons = this.polygons.concat(csg.polygons);
var result = CSG.fromPolygons(newpolygons);
result.properties = this.properties._merge(csg.properties);
result.isCanonicalized = this.isCanonicalized && csg.isCanonicalized;
result.isRetesse... | [
"function",
"(",
"csg",
")",
"{",
"var",
"newpolygons",
"=",
"this",
".",
"polygons",
".",
"concat",
"(",
"csg",
".",
"polygons",
")",
";",
"var",
"result",
"=",
"CSG",
".",
"fromPolygons",
"(",
"newpolygons",
")",
";",
"result",
".",
"properties",
"="... | Like union, but when we know that the two solids are not intersecting Do not use if you are not completely sure that the solids do not intersect! | [
"Like",
"union",
"but",
"when",
"we",
"know",
"that",
"the",
"two",
"solids",
"are",
"not",
"intersecting",
"Do",
"not",
"use",
"if",
"you",
"are",
"not",
"completely",
"sure",
"that",
"the",
"solids",
"do",
"not",
"intersect!"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L269-L276 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(matrix4x4) {
var newpolygons = this.polygons.map(function(p) {
return p.transform(matrix4x4);
});
var result = CSG.fromPolygons(newpolygons);
result.properties = this.properties._transform(matrix4x4);
result.isRetesselated = this.isRet... | javascript | function(matrix4x4) {
var newpolygons = this.polygons.map(function(p) {
return p.transform(matrix4x4);
});
var result = CSG.fromPolygons(newpolygons);
result.properties = this.properties._transform(matrix4x4);
result.isRetesselated = this.isRet... | [
"function",
"(",
"matrix4x4",
")",
"{",
"var",
"newpolygons",
"=",
"this",
".",
"polygons",
".",
"map",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"p",
".",
"transform",
"(",
"matrix4x4",
")",
";",
"}",
")",
";",
"var",
"result",
"=",
"CSG",
".... | Affine transformation of CSG object. Returns a new CSG object | [
"Affine",
"transformation",
"of",
"CSG",
"object",
".",
"Returns",
"a",
"new",
"CSG",
"object"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L379-L387 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(normal, point, length) {
var plane = CSG.Plane.fromNormalAndPoint(normal, point);
var onb = new CSG.OrthoNormalBasis(plane);
var crosssect = this.sectionCut(onb);
var midpiece = crosssect.extrudeInOrthonormalBasis(onb, length);
var piece1 = this.cutBy... | javascript | function(normal, point, length) {
var plane = CSG.Plane.fromNormalAndPoint(normal, point);
var onb = new CSG.OrthoNormalBasis(plane);
var crosssect = this.sectionCut(onb);
var midpiece = crosssect.extrudeInOrthonormalBasis(onb, length);
var piece1 = this.cutBy... | [
"function",
"(",
"normal",
",",
"point",
",",
"length",
")",
"{",
"var",
"plane",
"=",
"CSG",
".",
"Plane",
".",
"fromNormalAndPoint",
"(",
"normal",
",",
"point",
")",
";",
"var",
"onb",
"=",
"new",
"CSG",
".",
"OrthoNormalBasis",
"(",
"plane",
")",
... | cut the solid at a plane, and stretch the cross-section found along plane normal | [
"cut",
"the",
"solid",
"at",
"a",
"plane",
"and",
"stretch",
"the",
"cross",
"-",
"section",
"found",
"along",
"plane",
"normal"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L452-L461 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(csg) {
if ((this.polygons.length === 0) || (csg.polygons.length === 0)) {
return false;
} else {
var mybounds = this.getBounds();
var otherbounds = csg.getBounds();
if (mybounds[1].x < otherbounds[0].x) return false;
... | javascript | function(csg) {
if ((this.polygons.length === 0) || (csg.polygons.length === 0)) {
return false;
} else {
var mybounds = this.getBounds();
var otherbounds = csg.getBounds();
if (mybounds[1].x < otherbounds[0].x) return false;
... | [
"function",
"(",
"csg",
")",
"{",
"if",
"(",
"(",
"this",
".",
"polygons",
".",
"length",
"===",
"0",
")",
"||",
"(",
"csg",
".",
"polygons",
".",
"length",
"===",
"0",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"var",
"mybounds",
... | returns true if there is a possibility that the two solids overlap returns false if we can be sure that they do not overlap | [
"returns",
"true",
"if",
"there",
"is",
"a",
"possibility",
"that",
"the",
"two",
"solids",
"overlap",
"returns",
"false",
"if",
"we",
"can",
"be",
"sure",
"that",
"they",
"do",
"not",
"overlap"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L748-L762 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(plane) {
if (this.polygons.length === 0) {
return new CSG();
}
// Ideally we would like to do an intersection with a polygon of inifinite size
// but this is not supported by our implementation. As a workaround, we will create
// a cub... | javascript | function(plane) {
if (this.polygons.length === 0) {
return new CSG();
}
// Ideally we would like to do an intersection with a polygon of inifinite size
// but this is not supported by our implementation. As a workaround, we will create
// a cub... | [
"function",
"(",
"plane",
")",
"{",
"if",
"(",
"this",
".",
"polygons",
".",
"length",
"===",
"0",
")",
"{",
"return",
"new",
"CSG",
"(",
")",
";",
"}",
"// Ideally we would like to do an intersection with a polygon of inifinite size",
"// but this is not supported by... | Cut the solid by a plane. Returns the solid on the back side of the plane | [
"Cut",
"the",
"solid",
"by",
"a",
"plane",
".",
"Returns",
"the",
"solid",
"on",
"the",
"back",
"side",
"of",
"the",
"plane"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L765-L800 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(shared) {
var polygons = this.polygons.map(function(p) {
return new CSG.Polygon(p.vertices, shared, p.plane);
});
var result = CSG.fromPolygons(polygons);
result.properties = this.properties; // keep original properties
result.isRetess... | javascript | function(shared) {
var polygons = this.polygons.map(function(p) {
return new CSG.Polygon(p.vertices, shared, p.plane);
});
var result = CSG.fromPolygons(polygons);
result.properties = this.properties; // keep original properties
result.isRetess... | [
"function",
"(",
"shared",
")",
"{",
"var",
"polygons",
"=",
"this",
".",
"polygons",
".",
"map",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"new",
"CSG",
".",
"Polygon",
"(",
"p",
".",
"vertices",
",",
"shared",
",",
"p",
".",
"plane",
")",
... | set the .shared property of all polygons Returns a new CSG solid, the original is unmodified! | [
"set",
"the",
".",
"shared",
"property",
"of",
"all",
"polygons",
"Returns",
"a",
"new",
"CSG",
"solid",
"the",
"original",
"is",
"unmodified!"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L816-L825 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(cuberadius) {
var csg = this.reTesselated();
var result = new CSG();
// make a list of all unique vertices
// For each vertex we also collect the list of normals of the planes touching the vertices
var vertexmap = {};
csg.polygons.map(fu... | javascript | function(cuberadius) {
var csg = this.reTesselated();
var result = new CSG();
// make a list of all unique vertices
// For each vertex we also collect the list of normals of the planes touching the vertices
var vertexmap = {};
csg.polygons.map(fu... | [
"function",
"(",
"cuberadius",
")",
"{",
"var",
"csg",
"=",
"this",
".",
"reTesselated",
"(",
")",
";",
"var",
"result",
"=",
"new",
"CSG",
"(",
")",
";",
"// make a list of all unique vertices",
"// For each vertex we also collect the list of normals of the planes touc... | For debugging Creates a new solid with a tiny cube at every vertex of the source solid | [
"For",
"debugging",
"Creates",
"a",
"new",
"solid",
"with",
"a",
"tiny",
"cube",
"at",
"every",
"vertex",
"of",
"the",
"source",
"solid"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L930-L954 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(orthobasis) {
var EPS = 1e-5;
var cags = [];
this.polygons.filter(function(p) {
// only return polys in plane, others may disturb result
return p.plane.normal.minus(orthobasis.plane.normal).lengthSquared() < EPS*EPS;
})... | javascript | function(orthobasis) {
var EPS = 1e-5;
var cags = [];
this.polygons.filter(function(p) {
// only return polys in plane, others may disturb result
return p.plane.normal.minus(orthobasis.plane.normal).lengthSquared() < EPS*EPS;
})... | [
"function",
"(",
"orthobasis",
")",
"{",
"var",
"EPS",
"=",
"1e-5",
";",
"var",
"cags",
"=",
"[",
"]",
";",
"this",
".",
"polygons",
".",
"filter",
"(",
"function",
"(",
"p",
")",
"{",
"// only return polys in plane, others may disturb result",
"return",
"p"... | project the 3D CSG onto a plane This returns a 2D CAG with the 'shadow' shape of the 3D solid when projected onto the plane represented by the orthonormal basis | [
"project",
"the",
"3D",
"CSG",
"onto",
"a",
"plane",
"This",
"returns",
"a",
"2D",
"CAG",
"with",
"the",
"shadow",
"shape",
"of",
"the",
"3D",
"solid",
"when",
"projected",
"onto",
"the",
"plane",
"represented",
"by",
"the",
"orthonormal",
"basis"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L1044-L1059 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function() {
var abs = this.abs();
if ((abs._x <= abs._y) && (abs._x <= abs._z)) {
return CSG.Vector3D.Create(1, 0, 0);
} else if ((abs._y <= abs._x) && (abs._y <= abs._z)) {
return CSG.Vector3D.Create(0, 1, 0);
} else {
ret... | javascript | function() {
var abs = this.abs();
if ((abs._x <= abs._y) && (abs._x <= abs._z)) {
return CSG.Vector3D.Create(1, 0, 0);
} else if ((abs._y <= abs._x) && (abs._y <= abs._z)) {
return CSG.Vector3D.Create(0, 1, 0);
} else {
ret... | [
"function",
"(",
")",
"{",
"var",
"abs",
"=",
"this",
".",
"abs",
"(",
")",
";",
"if",
"(",
"(",
"abs",
".",
"_x",
"<=",
"abs",
".",
"_y",
")",
"&&",
"(",
"abs",
".",
"_x",
"<=",
"abs",
".",
"_z",
")",
")",
"{",
"return",
"CSG",
".",
"Vec... | find a vector that is somewhat perpendicular to this one | [
"find",
"a",
"vector",
"that",
"is",
"somewhat",
"perpendicular",
"to",
"this",
"one"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2124-L2133 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(other, t) {
var newpos = this.pos.lerp(other.pos, t);
return new CSG.Vertex(newpos);
} | javascript | function(other, t) {
var newpos = this.pos.lerp(other.pos, t);
return new CSG.Vertex(newpos);
} | [
"function",
"(",
"other",
",",
"t",
")",
"{",
"var",
"newpos",
"=",
"this",
".",
"pos",
".",
"lerp",
"(",
"other",
".",
"pos",
",",
"t",
")",
";",
"return",
"new",
"CSG",
".",
"Vertex",
"(",
"newpos",
")",
";",
"}"
] | Create a new vertex between this vertex and `other` by linearly interpolating all properties using a parameter of `t`. Subclasses should override this to interpolate additional properties. | [
"Create",
"a",
"new",
"vertex",
"between",
"this",
"vertex",
"and",
"other",
"by",
"linearly",
"interpolating",
"all",
"properties",
"using",
"a",
"parameter",
"of",
"t",
".",
"Subclasses",
"should",
"override",
"this",
"to",
"interpolate",
"additional",
"proper... | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2181-L2184 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(features) {
var result = [];
features.forEach(function(feature) {
if (feature == 'volume') {
result.push(this.getSignedVolume());
} else if (feature == 'area') {
result.push(this.getArea());
}
... | javascript | function(features) {
var result = [];
features.forEach(function(feature) {
if (feature == 'volume') {
result.push(this.getSignedVolume());
} else if (feature == 'area') {
result.push(this.getArea());
}
... | [
"function",
"(",
"features",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"features",
".",
"forEach",
"(",
"function",
"(",
"feature",
")",
"{",
"if",
"(",
"feature",
"==",
"'volume'",
")",
"{",
"result",
".",
"push",
"(",
"this",
".",
"getSignedVo... | accepts array of features to calculate returns array of results | [
"accepts",
"array",
"of",
"features",
"to",
"calculate",
"returns",
"array",
"of",
"results"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2531-L2541 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(offsetvector) {
var newpolygons = [];
var polygon1 = this;
var direction = polygon1.plane.normal.dot(offsetvector);
if (direction > 0) {
polygon1 = polygon1.flipped();
}
newpolygons.push(polygon1);
var polygon2... | javascript | function(offsetvector) {
var newpolygons = [];
var polygon1 = this;
var direction = polygon1.plane.normal.dot(offsetvector);
if (direction > 0) {
polygon1 = polygon1.flipped();
}
newpolygons.push(polygon1);
var polygon2... | [
"function",
"(",
"offsetvector",
")",
"{",
"var",
"newpolygons",
"=",
"[",
"]",
";",
"var",
"polygon1",
"=",
"this",
";",
"var",
"direction",
"=",
"polygon1",
".",
"plane",
".",
"normal",
".",
"dot",
"(",
"offsetvector",
")",
";",
"if",
"(",
"direction... | Extrude a polygon into the direction offsetvector Returns a CSG object | [
"Extrude",
"a",
"polygon",
"into",
"the",
"direction",
"offsetvector",
"Returns",
"a",
"CSG",
"object"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2545-L2569 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(matrix4x4) {
var newvertices = this.vertices.map(function(v) {
return v.transform(matrix4x4);
});
var newplane = this.plane.transform(matrix4x4);
if (matrix4x4.isMirroring()) {
// need to reverse the vertex order
//... | javascript | function(matrix4x4) {
var newvertices = this.vertices.map(function(v) {
return v.transform(matrix4x4);
});
var newplane = this.plane.transform(matrix4x4);
if (matrix4x4.isMirroring()) {
// need to reverse the vertex order
//... | [
"function",
"(",
"matrix4x4",
")",
"{",
"var",
"newvertices",
"=",
"this",
".",
"vertices",
".",
"map",
"(",
"function",
"(",
"v",
")",
"{",
"return",
"v",
".",
"transform",
"(",
"matrix4x4",
")",
";",
"}",
")",
";",
"var",
"newplane",
"=",
"this",
... | Affine transformation of polygon. Returns a new CSG.Polygon | [
"Affine",
"transformation",
"of",
"polygon",
".",
"Returns",
"a",
"new",
"CSG",
".",
"Polygon"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2619-L2630 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(orthobasis) {
var points2d = this.vertices.map(function(vertex) {
return orthobasis.to2D(vertex.pos);
});
var result = CAG.fromPointsNoCheck(points2d);
var area = result.area();
if (Math.abs(area) < 1e-5) {
// the polyg... | javascript | function(orthobasis) {
var points2d = this.vertices.map(function(vertex) {
return orthobasis.to2D(vertex.pos);
});
var result = CAG.fromPointsNoCheck(points2d);
var area = result.area();
if (Math.abs(area) < 1e-5) {
// the polyg... | [
"function",
"(",
"orthobasis",
")",
"{",
"var",
"points2d",
"=",
"this",
".",
"vertices",
".",
"map",
"(",
"function",
"(",
"vertex",
")",
"{",
"return",
"orthobasis",
".",
"to2D",
"(",
"vertex",
".",
"pos",
")",
";",
"}",
")",
";",
"var",
"result",
... | project the 3D polygon onto a plane | [
"project",
"the",
"3D",
"polygon",
"onto",
"a",
"plane"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L2641-L2655 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function() {
if (!this.removed) {
this.removed = true;
if (_CSGDEBUG) {
if (this.isRootNode()) throw new Error("Assertion failed"); // can't remove root node
if (this.children.length) throw new Error("Assertion failed"); // we shouldn'... | javascript | function() {
if (!this.removed) {
this.removed = true;
if (_CSGDEBUG) {
if (this.isRootNode()) throw new Error("Assertion failed"); // can't remove root node
if (this.children.length) throw new Error("Assertion failed"); // we shouldn'... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"removed",
")",
"{",
"this",
".",
"removed",
"=",
"true",
";",
"if",
"(",
"_CSGDEBUG",
")",
"{",
"if",
"(",
"this",
".",
"isRootNode",
"(",
")",
")",
"throw",
"new",
"Error",
"(",
"\"Asserti... | remove a node - the siblings become toplevel nodes - the parent is removed recursively | [
"remove",
"a",
"node",
"-",
"the",
"siblings",
"become",
"toplevel",
"nodes",
"-",
"the",
"parent",
"is",
"removed",
"recursively"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L3014-L3032 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function() {
var queue = [this];
var i, node;
for (var i = 0; i < queue.length; i++) {
node = queue[i];
if(node.plane) node.plane = node.plane.flipped();
if(node.front) queue.push(node.front);
if(node.back) queue.push(no... | javascript | function() {
var queue = [this];
var i, node;
for (var i = 0; i < queue.length; i++) {
node = queue[i];
if(node.plane) node.plane = node.plane.flipped();
if(node.front) queue.push(node.front);
if(node.back) queue.push(no... | [
"function",
"(",
")",
"{",
"var",
"queue",
"=",
"[",
"this",
"]",
";",
"var",
"i",
",",
"node",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"queue",
".",
"length",
";",
"i",
"++",
")",
"{",
"node",
"=",
"queue",
"[",
"i",
"]",
"... | Convert solid space to empty space and empty space to solid space. | [
"Convert",
"solid",
"space",
"to",
"empty",
"space",
"and",
"empty",
"space",
"to",
"solid",
"space",
"."
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L3247-L3259 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function() {
var u = new CSG.Vector3D(this.elements[0], this.elements[4], this.elements[8]);
var v = new CSG.Vector3D(this.elements[1], this.elements[5], this.elements[9]);
var w = new CSG.Vector3D(this.elements[2], this.elements[6], this.elements[10]);
// for a true ort... | javascript | function() {
var u = new CSG.Vector3D(this.elements[0], this.elements[4], this.elements[8]);
var v = new CSG.Vector3D(this.elements[1], this.elements[5], this.elements[9]);
var w = new CSG.Vector3D(this.elements[2], this.elements[6], this.elements[10]);
// for a true ort... | [
"function",
"(",
")",
"{",
"var",
"u",
"=",
"new",
"CSG",
".",
"Vector3D",
"(",
"this",
".",
"elements",
"[",
"0",
"]",
",",
"this",
".",
"elements",
"[",
"4",
"]",
",",
"this",
".",
"elements",
"[",
"8",
"]",
")",
";",
"var",
"v",
"=",
"new"... | determine whether this matrix is a mirroring transformation | [
"determine",
"whether",
"this",
"matrix",
"is",
"a",
"mirroring",
"transformation"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L3545-L3555 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(distance) {
var newpoint = this.point.plus(this.axisvector.unit().times(distance));
return new CSG.Connector(newpoint, this.axisvector, this.normalvector);
} | javascript | function(distance) {
var newpoint = this.point.plus(this.axisvector.unit().times(distance));
return new CSG.Connector(newpoint, this.axisvector, this.normalvector);
} | [
"function",
"(",
"distance",
")",
"{",
"var",
"newpoint",
"=",
"this",
".",
"point",
".",
"plus",
"(",
"this",
".",
"axisvector",
".",
"unit",
"(",
")",
".",
"times",
"(",
"distance",
")",
")",
";",
"return",
"new",
"CSG",
".",
"Connector",
"(",
"n... | creates a new Connector, with the connection point moved in the direction of the axisvector | [
"creates",
"a",
"new",
"Connector",
"with",
"the",
"connection",
"point",
"moved",
"in",
"the",
"direction",
"of",
"the",
"axisvector"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L4881-L4884 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/csg.js | function(pathradius, resolution) {
var sides = [];
var numpoints = this.points.length;
var startindex = 0;
if (this.closed && (numpoints > 2)) startindex = -1;
var prevvertex;
for (var i = startindex; i < numpoints; i++) {
var point... | javascript | function(pathradius, resolution) {
var sides = [];
var numpoints = this.points.length;
var startindex = 0;
if (this.closed && (numpoints > 2)) startindex = -1;
var prevvertex;
for (var i = startindex; i < numpoints; i++) {
var point... | [
"function",
"(",
"pathradius",
",",
"resolution",
")",
"{",
"var",
"sides",
"=",
"[",
"]",
";",
"var",
"numpoints",
"=",
"this",
".",
"points",
".",
"length",
";",
"var",
"startindex",
"=",
"0",
";",
"if",
"(",
"this",
".",
"closed",
"&&",
"(",
"nu... | Expand the path to a CAG This traces the path with a circle with radius pathradius | [
"Expand",
"the",
"path",
"to",
"a",
"CAG",
"This",
"traces",
"the",
"path",
"with",
"a",
"circle",
"with",
"radius",
"pathradius"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/csg.js#L5142-L5162 | train | |
epii-io/epii-node-render | index.js | buildOnce | function buildOnce(config) {
// verify config
if (!lintConfig(config)) throw new Error('invalid config')
// set default holder
if (!config.holder) {
config.holder = { name: 'app', stub: 'epii' }
}
// prepare static dir
shell.mkdir('-p', config.$path.target.client)
shell.mkdir('-p', config.$path.ta... | javascript | function buildOnce(config) {
// verify config
if (!lintConfig(config)) throw new Error('invalid config')
// set default holder
if (!config.holder) {
config.holder = { name: 'app', stub: 'epii' }
}
// prepare static dir
shell.mkdir('-p', config.$path.target.client)
shell.mkdir('-p', config.$path.ta... | [
"function",
"buildOnce",
"(",
"config",
")",
"{",
"// verify config",
"if",
"(",
"!",
"lintConfig",
"(",
"config",
")",
")",
"throw",
"new",
"Error",
"(",
"'invalid config'",
")",
"// set default holder",
"if",
"(",
"!",
"config",
".",
"holder",
")",
"{",
... | build once, default production | [
"build",
"once",
"default",
"production"
] | e8afa57066251e173b3a6455d47218c95f30f563 | https://github.com/epii-io/epii-node-render/blob/e8afa57066251e173b3a6455d47218c95f30f563/index.js#L53-L71 | train |
epii-io/epii-node-render | index.js | watchBuild | function watchBuild(config) {
// verify config
if (!lintConfig(config)) throw new Error('invalid config')
// set development env
CONTEXT.env = 'development'
// build once immediately
buildOnce(config)
// bind watch handler
assist.tryWatch(
config.$path.source.client,
function (e, file) {
... | javascript | function watchBuild(config) {
// verify config
if (!lintConfig(config)) throw new Error('invalid config')
// set development env
CONTEXT.env = 'development'
// build once immediately
buildOnce(config)
// bind watch handler
assist.tryWatch(
config.$path.source.client,
function (e, file) {
... | [
"function",
"watchBuild",
"(",
"config",
")",
"{",
"// verify config",
"if",
"(",
"!",
"lintConfig",
"(",
"config",
")",
")",
"throw",
"new",
"Error",
"(",
"'invalid config'",
")",
"// set development env",
"CONTEXT",
".",
"env",
"=",
"'development'",
"// build ... | watch & build, development | [
"watch",
"&",
"build",
"development"
] | e8afa57066251e173b3a6455d47218c95f30f563 | https://github.com/epii-io/epii-node-render/blob/e8afa57066251e173b3a6455d47218c95f30f563/index.js#L76-L96 | train |
ozum/replace-between | index.js | replaceBetween | function replaceBetween(args) {
const getSourceContent = args.source ? fs.readFile(path.normalize(args.source), { encoding: 'utf8' }) : getStdin();
const getTargetContent = fs.readFile(path.normalize(args.target), { encoding: 'utf8' });
const commentBegin = args.comment ? commentTypes[args.comment].begin :... | javascript | function replaceBetween(args) {
const getSourceContent = args.source ? fs.readFile(path.normalize(args.source), { encoding: 'utf8' }) : getStdin();
const getTargetContent = fs.readFile(path.normalize(args.target), { encoding: 'utf8' });
const commentBegin = args.comment ? commentTypes[args.comment].begin :... | [
"function",
"replaceBetween",
"(",
"args",
")",
"{",
"const",
"getSourceContent",
"=",
"args",
".",
"source",
"?",
"fs",
".",
"readFile",
"(",
"path",
".",
"normalize",
"(",
"args",
".",
"source",
")",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
":"... | Replaces text between markers with text from a file or stdin.
@param {Object} args - Options
@param {string} args.token - Token text to look for between start and end comment. BEGIN and END words are added automatically.
@param {string} args.target - Target file to r... | [
"Replaces",
"text",
"between",
"markers",
"with",
"text",
"from",
"a",
"file",
"or",
"stdin",
"."
] | 35263dff3992286eacd8c78e3b4e50bdebc9af96 | https://github.com/ozum/replace-between/blob/35263dff3992286eacd8c78e3b4e50bdebc9af96/index.js#L23-L50 | train |
camshaft/component-github-content-api | lib/index.js | GitHubContentAPI | function GitHubContentAPI(opts) {
if (!(this instanceof GitHubContentAPI)) return new GitHubContentAPI(opts);
opts = Object.create(opts || {});
if (!opts.auth && GITHUB_USERNAME && GITHUB_PASSWORD) opts.auth = GITHUB_USERNAME + ':' + GITHUB_PASSWORD;
this._host = opts.host || 'https://api.github.com';
Git... | javascript | function GitHubContentAPI(opts) {
if (!(this instanceof GitHubContentAPI)) return new GitHubContentAPI(opts);
opts = Object.create(opts || {});
if (!opts.auth && GITHUB_USERNAME && GITHUB_PASSWORD) opts.auth = GITHUB_USERNAME + ':' + GITHUB_PASSWORD;
this._host = opts.host || 'https://api.github.com';
Git... | [
"function",
"GitHubContentAPI",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"GitHubContentAPI",
")",
")",
"return",
"new",
"GitHubContentAPI",
"(",
"opts",
")",
";",
"opts",
"=",
"Object",
".",
"create",
"(",
"opts",
"||",
"{",
"}",... | Create a GitHub content API remote
@param {Object} opts | [
"Create",
"a",
"GitHub",
"content",
"API",
"remote"
] | 4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd | https://github.com/camshaft/component-github-content-api/blob/4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd/lib/index.js#L40-L55 | train |
camshaft/component-github-content-api | lib/index.js | errorRateLimitExceeded | function errorRateLimitExceeded(res) {
var err = new Error('GitHub rate limit exceeded.');
err.res = res;
err.remote = 'github-content-api';
throw err;
} | javascript | function errorRateLimitExceeded(res) {
var err = new Error('GitHub rate limit exceeded.');
err.res = res;
err.remote = 'github-content-api';
throw err;
} | [
"function",
"errorRateLimitExceeded",
"(",
"res",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"'GitHub rate limit exceeded.'",
")",
";",
"err",
".",
"res",
"=",
"res",
";",
"err",
".",
"remote",
"=",
"'github-content-api'",
";",
"throw",
"err",
";",
... | Better error message when rate limit exceeded.
@param {Object} response
@api private | [
"Better",
"error",
"message",
"when",
"rate",
"limit",
"exceeded",
"."
] | 4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd | https://github.com/camshaft/component-github-content-api/blob/4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd/lib/index.js#L130-L135 | train |
camshaft/component-github-content-api | lib/index.js | checkRateLimitRemaining | function checkRateLimitRemaining(res) {
var remaining = parseInt(res.headers['x-ratelimit-remaining'], 10);
if (remaining <= 50) {
console.warn('github-content-api remote: only %d requests remaining.', remaining);
}
} | javascript | function checkRateLimitRemaining(res) {
var remaining = parseInt(res.headers['x-ratelimit-remaining'], 10);
if (remaining <= 50) {
console.warn('github-content-api remote: only %d requests remaining.', remaining);
}
} | [
"function",
"checkRateLimitRemaining",
"(",
"res",
")",
"{",
"var",
"remaining",
"=",
"parseInt",
"(",
"res",
".",
"headers",
"[",
"'x-ratelimit-remaining'",
"]",
",",
"10",
")",
";",
"if",
"(",
"remaining",
"<=",
"50",
")",
"{",
"console",
".",
"warn",
... | Warn when rate limit is low.
@param {Object} response
@api private | [
"Warn",
"when",
"rate",
"limit",
"is",
"low",
"."
] | 4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd | https://github.com/camshaft/component-github-content-api/blob/4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd/lib/index.js#L144-L149 | train |
camshaft/component-github-content-api | lib/index.js | errorBadCredentials | function errorBadCredentials(res) {
var err = new Error('Invalid credentials');
err.res = res;
err.remote = 'github-content-api';
throw err;
} | javascript | function errorBadCredentials(res) {
var err = new Error('Invalid credentials');
err.res = res;
err.remote = 'github-content-api';
throw err;
} | [
"function",
"errorBadCredentials",
"(",
"res",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"'Invalid credentials'",
")",
";",
"err",
".",
"res",
"=",
"res",
";",
"err",
".",
"remote",
"=",
"'github-content-api'",
";",
"throw",
"err",
";",
"}"
] | Better error message when credentials are not supplied.
@param {Object} response
@api private | [
"Better",
"error",
"message",
"when",
"credentials",
"are",
"not",
"supplied",
"."
] | 4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd | https://github.com/camshaft/component-github-content-api/blob/4b0461b8c676bb3a11d3dc882d2bc3b47101f9bd/lib/index.js#L158-L163 | train |
xpepermint/config-keys | lib/index.js | function(what) {
var mainData = what;
var localData = {};
if (typeof what == 'string') {
// main
var mainFile = path.resolve(process.cwd(), what);
delete require.cache[mainFile];
mainData = require(mainFile);
// local
var localFile = mainFile.substr(0, mainFile.lastIndexO... | javascript | function(what) {
var mainData = what;
var localData = {};
if (typeof what == 'string') {
// main
var mainFile = path.resolve(process.cwd(), what);
delete require.cache[mainFile];
mainData = require(mainFile);
// local
var localFile = mainFile.substr(0, mainFile.lastIndexO... | [
"function",
"(",
"what",
")",
"{",
"var",
"mainData",
"=",
"what",
";",
"var",
"localData",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"what",
"==",
"'string'",
")",
"{",
"// main",
"var",
"mainFile",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
... | Reads the `what` parameter and returns it's content.
@param {object|string} what
@return {object} | [
"Reads",
"the",
"what",
"parameter",
"and",
"returns",
"it",
"s",
"content",
"."
] | 8dfcfa7cd3af039b6f80e8c0f58346018b5925b4 | https://github.com/xpepermint/config-keys/blob/8dfcfa7cd3af039b6f80e8c0f58346018b5925b4/lib/index.js#L57-L77 | train | |
sinai-doron/Cynwrig | cynwrig.js | addProperty | function addProperty(prop, func){
Object.defineProperty(String.prototype, prop, {
enumerable: true,
configurable: false,
get: func
});
} | javascript | function addProperty(prop, func){
Object.defineProperty(String.prototype, prop, {
enumerable: true,
configurable: false,
get: func
});
} | [
"function",
"addProperty",
"(",
"prop",
",",
"func",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"String",
".",
"prototype",
",",
"prop",
",",
"{",
"enumerable",
":",
"true",
",",
"configurable",
":",
"false",
",",
"get",
":",
"func",
"}",
")",
";"... | add the property to be used with the String object | [
"add",
"the",
"property",
"to",
"be",
"used",
"with",
"the",
"String",
"object"
] | e8a930745e7626fdcb10f4ae4b8df32a2ed3d6dd | https://github.com/sinai-doron/Cynwrig/blob/e8a930745e7626fdcb10f4ae4b8df32a2ed3d6dd/cynwrig.js#L72-L78 | train |
SakartveloSoft/jade-dynamic-includes | lib/templates-loader.js | function() {
return function (req, res, next) {
if (!req.locals) {
req.locals = {};
}
var requestTemplates = getTemplates(res);
req.locals.templates = requestTemplates;
req.locals.knownTemplates = knownTemplates;
if (!res.l... | javascript | function() {
return function (req, res, next) {
if (!req.locals) {
req.locals = {};
}
var requestTemplates = getTemplates(res);
req.locals.templates = requestTemplates;
req.locals.knownTemplates = knownTemplates;
if (!res.l... | [
"function",
"(",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"!",
"req",
".",
"locals",
")",
"{",
"req",
".",
"locals",
"=",
"{",
"}",
";",
"}",
"var",
"requestTemplates",
"=",
"getTemplates",
"(",
"r... | Attaches the 'templates' property to 'locals' pf request and response objects. if no 'locals' found, it is created on demand.
@param req {IncomingMessage}
@param res {ServerResponse}
@param next {Function}
@returns {function} configured middleware function
@api public | [
"Attaches",
"the",
"templates",
"property",
"to",
"locals",
"pf",
"request",
"and",
"response",
"objects",
".",
"if",
"no",
"locals",
"found",
"it",
"is",
"created",
"on",
"demand",
"."
] | 139f904e879b78834b4edf4ea9899b341dcf790e | https://github.com/SakartveloSoft/jade-dynamic-includes/blob/139f904e879b78834b4edf4ea9899b341dcf790e/lib/templates-loader.js#L95-L113 | train | |
mayanklahiri/node-runtype | lib/loadIntoLibrary.js | loadIntoLibrary | function loadIntoLibrary(schemas) {
assert(_.isObject(schemas));
_.extend(library, schemas);
} | javascript | function loadIntoLibrary(schemas) {
assert(_.isObject(schemas));
_.extend(library, schemas);
} | [
"function",
"loadIntoLibrary",
"(",
"schemas",
")",
"{",
"assert",
"(",
"_",
".",
"isObject",
"(",
"schemas",
")",
")",
";",
"_",
".",
"extend",
"(",
"library",
",",
"schemas",
")",
";",
"}"
] | Load an map of type names to type definitions into the global type library.
@memberof runtype
@static
@param {object} schemas Map of type names to schemas. | [
"Load",
"an",
"map",
"of",
"type",
"names",
"to",
"type",
"definitions",
"into",
"the",
"global",
"type",
"library",
"."
] | efcf457ae797535b0e6e98bbeac461e66327c88e | https://github.com/mayanklahiri/node-runtype/blob/efcf457ae797535b0e6e98bbeac461e66327c88e/lib/loadIntoLibrary.js#L14-L17 | train |
tanepiper/nell | lib/generate.js | function(site_path, arg, cmd, done) {
var start = Date.now();
var nell_site = {
site_path: site_path
};
async.series([
function(callback) {
nell_site.config_path = path.join(site_path, 'nell.json');
fs.exists(nell_site.config_path, function(exists) {
if (!exists) {... | javascript | function(site_path, arg, cmd, done) {
var start = Date.now();
var nell_site = {
site_path: site_path
};
async.series([
function(callback) {
nell_site.config_path = path.join(site_path, 'nell.json');
fs.exists(nell_site.config_path, function(exists) {
if (!exists) {... | [
"function",
"(",
"site_path",
",",
"arg",
",",
"cmd",
",",
"done",
")",
"{",
"var",
"start",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"nell_site",
"=",
"{",
"site_path",
":",
"site_path",
"}",
";",
"async",
".",
"series",
"(",
"[",
"function"... | This function allows us to generate the complete site output.
It first needs to read all the source data, this way we have all the available
post and page data used to generate our page content, and also make available
to other sections like sidebars | [
"This",
"function",
"allows",
"us",
"to",
"generate",
"the",
"complete",
"site",
"output",
".",
"It",
"first",
"needs",
"to",
"read",
"all",
"the",
"source",
"data",
"this",
"way",
"we",
"have",
"all",
"the",
"available",
"post",
"and",
"page",
"data",
"... | ecceaf63e8d685e08081e2d5f5fb85e71b17a037 | https://github.com/tanepiper/nell/blob/ecceaf63e8d685e08081e2d5f5fb85e71b17a037/lib/generate.js#L32-L91 | train | |
Industryswarm/isnode-mod-data | lib/mongodb/bson/lib/bson/decimal128.js | function(value) {
var DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
var _rem = Long.fromNumber(0);
var i = 0;
if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
return { quotient: value, rem: _rem };
}
for (i = 0; i <= 3; i++) {
// Adjust remainder to match value of n... | javascript | function(value) {
var DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
var _rem = Long.fromNumber(0);
var i = 0;
if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
return { quotient: value, rem: _rem };
}
for (i = 0; i <= 3; i++) {
// Adjust remainder to match value of n... | [
"function",
"(",
"value",
")",
"{",
"var",
"DIVISOR",
"=",
"Long",
".",
"fromNumber",
"(",
"1000",
"*",
"1000",
"*",
"1000",
")",
";",
"var",
"_rem",
"=",
"Long",
".",
"fromNumber",
"(",
"0",
")",
";",
"var",
"i",
"=",
"0",
";",
"if",
"(",
"!",... | Divide two uint128 values | [
"Divide",
"two",
"uint128",
"values"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/bson/lib/bson/decimal128.js#L79-L98 | train | |
Industryswarm/isnode-mod-data | lib/mongodb/bson/lib/bson/decimal128.js | function(left, right) {
if (!left && !right) {
return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
}
var leftHigh = left.shiftRightUnsigned(32);
var leftLow = new Long(left.getLowBits(), 0);
var rightHigh = right.shiftRightUnsigned(32);
var rightLow = new Long(right.getLowBits(), 0);
var p... | javascript | function(left, right) {
if (!left && !right) {
return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
}
var leftHigh = left.shiftRightUnsigned(32);
var leftLow = new Long(left.getLowBits(), 0);
var rightHigh = right.shiftRightUnsigned(32);
var rightLow = new Long(right.getLowBits(), 0);
var p... | [
"function",
"(",
"left",
",",
"right",
")",
"{",
"if",
"(",
"!",
"left",
"&&",
"!",
"right",
")",
"{",
"return",
"{",
"high",
":",
"Long",
".",
"fromNumber",
"(",
"0",
")",
",",
"low",
":",
"Long",
".",
"fromNumber",
"(",
"0",
")",
"}",
";",
... | Multiply two Long values and return the 128 bit value | [
"Multiply",
"two",
"Long",
"values",
"and",
"return",
"the",
"128",
"bit",
"value"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/bson/lib/bson/decimal128.js#L101-L126 | train | |
chip-js/chip-utils | class.js | addStatics | function addStatics(statics, Subclass) {
// static method inheritance (including `extend`)
Object.keys(statics).forEach(function(key) {
var descriptor = Object.getOwnPropertyDescriptor(statics, key);
if (!descriptor.configurable) return;
Object.defineProperty(Subclass, key, descriptor);
});
} | javascript | function addStatics(statics, Subclass) {
// static method inheritance (including `extend`)
Object.keys(statics).forEach(function(key) {
var descriptor = Object.getOwnPropertyDescriptor(statics, key);
if (!descriptor.configurable) return;
Object.defineProperty(Subclass, key, descriptor);
});
} | [
"function",
"addStatics",
"(",
"statics",
",",
"Subclass",
")",
"{",
"// static method inheritance (including `extend`)",
"Object",
".",
"keys",
"(",
"statics",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"descriptor",
"=",
"Object",
".",
... | Copies static methods over for static inheritance | [
"Copies",
"static",
"methods",
"over",
"for",
"static",
"inheritance"
] | c8c2b233fbfd20e68fc84e5ea3d6a17de33a04ed | https://github.com/chip-js/chip-utils/blob/c8c2b233fbfd20e68fc84e5ea3d6a17de33a04ed/class.js#L101-L110 | train |
alessioalex/npm-dep-chain | examples/ls-tree-pkg-json.js | getTree | function getTree(root, deps) {
var tree;
tree = {};
populateItem(tree, root, deps);
return tree;
} | javascript | function getTree(root, deps) {
var tree;
tree = {};
populateItem(tree, root, deps);
return tree;
} | [
"function",
"getTree",
"(",
"root",
",",
"deps",
")",
"{",
"var",
"tree",
";",
"tree",
"=",
"{",
"}",
";",
"populateItem",
"(",
"tree",
",",
"root",
",",
"deps",
")",
";",
"return",
"tree",
";",
"}"
] | Returns the dependency tree for a NPM module | [
"Returns",
"the",
"dependency",
"tree",
"for",
"a",
"NPM",
"module"
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/examples/ls-tree-pkg-json.js#L52-L60 | train |
ruysu/gulp-core | lib/optimize.js | function(options) {
var stream = through.obj(function(file, enc, cb) {
var out = options.out;
// Convert to the main file to a vinyl file
options.out = function(text) {
cb(null, new gutil.File({
path: out,
contents: new Buffer(text)
})... | javascript | function(options) {
var stream = through.obj(function(file, enc, cb) {
var out = options.out;
// Convert to the main file to a vinyl file
options.out = function(text) {
cb(null, new gutil.File({
path: out,
contents: new Buffer(text)
})... | [
"function",
"(",
"options",
")",
"{",
"var",
"stream",
"=",
"through",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"var",
"out",
"=",
"options",
".",
"out",
";",
"// Convert to the main file to a vinyl file",
"options",
".",
... | Optimize gulp task
@param {object} options The options object passed to rjs command | [
"Optimize",
"gulp",
"task"
] | 2abb2e7b60dc5c30f2610f982672e112b5e1e436 | https://github.com/ruysu/gulp-core/blob/2abb2e7b60dc5c30f2610f982672e112b5e1e436/lib/optimize.js#L13-L32 | train | |
MiguelCastillo/log2console | src/index.js | log | function log(data) {
if (type.isError(data)) {
if (!data.handled) {
_setHandled(data);
_console.error(data);
}
}
else {
_console.log(_transform(data));
}
return data;
} | javascript | function log(data) {
if (type.isError(data)) {
if (!data.handled) {
_setHandled(data);
_console.error(data);
}
}
else {
_console.log(_transform(data));
}
return data;
} | [
"function",
"log",
"(",
"data",
")",
"{",
"if",
"(",
"type",
".",
"isError",
"(",
"data",
")",
")",
"{",
"if",
"(",
"!",
"data",
".",
"handled",
")",
"{",
"_setHandled",
"(",
"data",
")",
";",
"_console",
".",
"error",
"(",
"data",
")",
";",
"}... | Logs error to the console and makes sure it is only logged once. | [
"Logs",
"error",
"to",
"the",
"console",
"and",
"makes",
"sure",
"it",
"is",
"only",
"logged",
"once",
"."
] | ca34d19509f82ec59101b45cbbf7729ba2b64274 | https://github.com/MiguelCastillo/log2console/blob/ca34d19509f82ec59101b45cbbf7729ba2b64274/src/index.js#L38-L49 | train |
bug-buster/sesame-lib | lib/client.js | function () {
// don't do it twice
if (!tcpConnections[msg.tcpId]) return;
exports.verbose(new Date(), 'Connection closed by remote peer for: ' + addressForLog(msg.address, msg.port));
newCon.removeAllListeners();
delete tcpConnections[msg.tcpId];
send(chann... | javascript | function () {
// don't do it twice
if (!tcpConnections[msg.tcpId]) return;
exports.verbose(new Date(), 'Connection closed by remote peer for: ' + addressForLog(msg.address, msg.port));
newCon.removeAllListeners();
delete tcpConnections[msg.tcpId];
send(chann... | [
"function",
"(",
")",
"{",
"// don't do it twice",
"if",
"(",
"!",
"tcpConnections",
"[",
"msg",
".",
"tcpId",
"]",
")",
"return",
";",
"exports",
".",
"verbose",
"(",
"new",
"Date",
"(",
")",
",",
"'Connection closed by remote peer for: '",
"+",
"addressForLo... | add connected listeners for clean up | [
"add",
"connected",
"listeners",
"for",
"clean",
"up"
] | 23631f39d4dee9d742ceaf7528b67aa5204da2dc | https://github.com/bug-buster/sesame-lib/blob/23631f39d4dee9d742ceaf7528b67aa5204da2dc/lib/client.js#L85-L94 | train | |
bug-buster/sesame-lib | lib/client.js | function (error) {
send(channel, new MSG.OpenResult(msg.tcpId, Protocol.toOpenResultStatus(error), null, null));
} | javascript | function (error) {
send(channel, new MSG.OpenResult(msg.tcpId, Protocol.toOpenResultStatus(error), null, null));
} | [
"function",
"(",
"error",
")",
"{",
"send",
"(",
"channel",
",",
"new",
"MSG",
".",
"OpenResult",
"(",
"msg",
".",
"tcpId",
",",
"Protocol",
".",
"toOpenResultStatus",
"(",
"error",
")",
",",
"null",
",",
"null",
")",
")",
";",
"}"
] | Special handling case for erroneous connection | [
"Special",
"handling",
"case",
"for",
"erroneous",
"connection"
] | 23631f39d4dee9d742ceaf7528b67aa5204da2dc | https://github.com/bug-buster/sesame-lib/blob/23631f39d4dee9d742ceaf7528b67aa5204da2dc/lib/client.js#L107-L109 | train | |
leocornus/leocornus-visualdata | src/zoomable-circles-demo.js | loadData | function loadData(dataUrl, jsonEditor) {
// jQuery getJSON will read the file from a Web resources.
$.getJSON(dataUrl, function(data) {
//$.getJSON('data/simple-zoomable-circle.json', function(data) {
// set data to JSON editor.
jsonEditor.set(data);
// update the JSON source code
... | javascript | function loadData(dataUrl, jsonEditor) {
// jQuery getJSON will read the file from a Web resources.
$.getJSON(dataUrl, function(data) {
//$.getJSON('data/simple-zoomable-circle.json', function(data) {
// set data to JSON editor.
jsonEditor.set(data);
// update the JSON source code
... | [
"function",
"loadData",
"(",
"dataUrl",
",",
"jsonEditor",
")",
"{",
"// jQuery getJSON will read the file from a Web resources.",
"$",
".",
"getJSON",
"(",
"dataUrl",
",",
"function",
"(",
"data",
")",
"{",
"//$.getJSON('data/simple-zoomable-circle.json', function(data) {",
... | load data from the given url, set it to JSON editor and load
the zoomable circles. | [
"load",
"data",
"from",
"the",
"given",
"url",
"set",
"it",
"to",
"JSON",
"editor",
"and",
"load",
"the",
"zoomable",
"circles",
"."
] | 9d9714ca11c126f0250e650f3c1c4086709af3ab | https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/zoomable-circles-demo.js#L156-L175 | train |
HyeonuPark/babel-preset-escompile | generate.js | getVersion | function getVersion (plugin) {
return new Promise(function (resolve, reject) {
npm.commands.view([plugin, 'version'], function (err, data) {
if (err) return reject(err)
resolve(Object.keys(data)[0])
})
})
} | javascript | function getVersion (plugin) {
return new Promise(function (resolve, reject) {
npm.commands.view([plugin, 'version'], function (err, data) {
if (err) return reject(err)
resolve(Object.keys(data)[0])
})
})
} | [
"function",
"getVersion",
"(",
"plugin",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"npm",
".",
"commands",
".",
"view",
"(",
"[",
"plugin",
",",
"'version'",
"]",
",",
"function",
"(",
"err",
",",
... | return last published version of this package | [
"return",
"last",
"published",
"version",
"of",
"this",
"package"
] | 15f86a42e15efeee34e6a3dbd099acadf62ca4ad | https://github.com/HyeonuPark/babel-preset-escompile/blob/15f86a42e15efeee34e6a3dbd099acadf62ca4ad/generate.js#L97-L104 | train |
apentle/redux-actions-hub | index.js | defineActionProp | function defineActionProp(type) {
ActionsHub[type] = function() {
var creators = _actions[type];
if (creators.length === 1) {
// Simply forward to original action creator
return creators[0].apply(null, arguments);
} else if (creators.length > 1) {
// ThunkAction
var args = argument... | javascript | function defineActionProp(type) {
ActionsHub[type] = function() {
var creators = _actions[type];
if (creators.length === 1) {
// Simply forward to original action creator
return creators[0].apply(null, arguments);
} else if (creators.length > 1) {
// ThunkAction
var args = argument... | [
"function",
"defineActionProp",
"(",
"type",
")",
"{",
"ActionsHub",
"[",
"type",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"creators",
"=",
"_actions",
"[",
"type",
"]",
";",
"if",
"(",
"creators",
".",
"length",
"===",
"1",
")",
"{",
"// Simply for... | defineActionProp - define action property
@param {string} type action's type
@returns {undefined} | [
"defineActionProp",
"-",
"define",
"action",
"property"
] | 87634b7856d90607ff86e47c1d03f7c4747796ba | https://github.com/apentle/redux-actions-hub/blob/87634b7856d90607ff86e47c1d03f7c4747796ba/index.js#L11-L28 | train |
Concurix/module-stats | lib/wrapper.js | wrapFunctions | function wrapFunctions(name, obj, protoLevel, hooks, state, rules){
if (!(obj && (util.isObject(obj) || util.isFunction(obj)))){
return;
}
if (obj.__concurix_blacklisted || (obj.constructor && obj.constructor.__concurix_blacklisted)) {
return;
}
if (obj.__concurix_wrapped_obj__ || !Object.isExtensib... | javascript | function wrapFunctions(name, obj, protoLevel, hooks, state, rules){
if (!(obj && (util.isObject(obj) || util.isFunction(obj)))){
return;
}
if (obj.__concurix_blacklisted || (obj.constructor && obj.constructor.__concurix_blacklisted)) {
return;
}
if (obj.__concurix_wrapped_obj__ || !Object.isExtensib... | [
"function",
"wrapFunctions",
"(",
"name",
",",
"obj",
",",
"protoLevel",
",",
"hooks",
",",
"state",
",",
"rules",
")",
"{",
"if",
"(",
"!",
"(",
"obj",
"&&",
"(",
"util",
".",
"isObject",
"(",
"obj",
")",
"||",
"util",
".",
"isFunction",
"(",
"obj... | iterate through all configurable properties and hook into each function | [
"iterate",
"through",
"all",
"configurable",
"properties",
"and",
"hook",
"into",
"each",
"function"
] | 940c76ca8b44ccd6bb5b34fa1305c52a8157c2cb | https://github.com/Concurix/module-stats/blob/940c76ca8b44ccd6bb5b34fa1305c52a8157c2cb/lib/wrapper.js#L159-L221 | train |
Concurix/module-stats | lib/wrapper.js | wrapArguments | function wrapArguments(trace, clientState, hooks) {
//wrap any callbacks found in the arguments
var args = trace.args;
var handler = clientState.rules.handleArgs(trace.funInfo.name);
if (handler) {
handler(trace, clientState);
}
for (var i = args.length - 1; i >= 0; i--) {
var a = args[i];
if (u... | javascript | function wrapArguments(trace, clientState, hooks) {
//wrap any callbacks found in the arguments
var args = trace.args;
var handler = clientState.rules.handleArgs(trace.funInfo.name);
if (handler) {
handler(trace, clientState);
}
for (var i = args.length - 1; i >= 0; i--) {
var a = args[i];
if (u... | [
"function",
"wrapArguments",
"(",
"trace",
",",
"clientState",
",",
"hooks",
")",
"{",
"//wrap any callbacks found in the arguments",
"var",
"args",
"=",
"trace",
".",
"args",
";",
"var",
"handler",
"=",
"clientState",
".",
"rules",
".",
"handleArgs",
"(",
"trac... | iterate through arguments and wrap functions as callbacks | [
"iterate",
"through",
"arguments",
"and",
"wrap",
"functions",
"as",
"callbacks"
] | 940c76ca8b44ccd6bb5b34fa1305c52a8157c2cb | https://github.com/Concurix/module-stats/blob/940c76ca8b44ccd6bb5b34fa1305c52a8157c2cb/lib/wrapper.js#L224-L260 | train |
structAnkit/limireq | index.js | next | function next() {
var limireq = this;
var conn = limireq.connections.shift()
if (!conn) return
request(conn.options, function(err, res, body) {
if (typeof conn.callback === 'function')
conn.callback(err, res, body)
else
limireq.emit('data', err, res, body)
// Signal the end of processi... | javascript | function next() {
var limireq = this;
var conn = limireq.connections.shift()
if (!conn) return
request(conn.options, function(err, res, body) {
if (typeof conn.callback === 'function')
conn.callback(err, res, body)
else
limireq.emit('data', err, res, body)
// Signal the end of processi... | [
"function",
"next",
"(",
")",
"{",
"var",
"limireq",
"=",
"this",
";",
"var",
"conn",
"=",
"limireq",
".",
"connections",
".",
"shift",
"(",
")",
"if",
"(",
"!",
"conn",
")",
"return",
"request",
"(",
"conn",
".",
"options",
",",
"function",
"(",
"... | Don't expose this function to the public prototype | [
"Don",
"t",
"expose",
"this",
"function",
"to",
"the",
"public",
"prototype"
] | d6bb145e9d6974c73efa87ac5c1c4fc20e3acf41 | https://github.com/structAnkit/limireq/blob/d6bb145e9d6974c73efa87ac5c1c4fc20e3acf41/index.js#L99-L116 | train |
MarkGriffiths/xo-tidy | src/lib/engine.js | configureESFormatter | function configureESFormatter(options) {
const ESFormatConfig = {
root: true,
allowShebang: true,
indent: {value: '\t'},
whiteSpace: {
before: {
IfStatementConditionalOpening: -1
},
after: {
IfStatementConditionalClosing: -1,
FunctionReservedWord: 1
}
},
lineBreak: {after: {ClassDec... | javascript | function configureESFormatter(options) {
const ESFormatConfig = {
root: true,
allowShebang: true,
indent: {value: '\t'},
whiteSpace: {
before: {
IfStatementConditionalOpening: -1
},
after: {
IfStatementConditionalClosing: -1,
FunctionReservedWord: 1
}
},
lineBreak: {after: {ClassDec... | [
"function",
"configureESFormatter",
"(",
"options",
")",
"{",
"const",
"ESFormatConfig",
"=",
"{",
"root",
":",
"true",
",",
"allowShebang",
":",
"true",
",",
"indent",
":",
"{",
"value",
":",
"'\\t'",
"}",
",",
"whiteSpace",
":",
"{",
"before",
":",
"{"... | Create a configured ESformatter factory
@private
@param {options} options - Job options
@return {Function} - Generate an ESFormatter configuration | [
"Create",
"a",
"configured",
"ESformatter",
"factory"
] | 8f58bde3587c3cd88a777380499529282b0d386d | https://github.com/MarkGriffiths/xo-tidy/blob/8f58bde3587c3cd88a777380499529282b0d386d/src/lib/engine.js#L54-L82 | train |
MarkGriffiths/xo-tidy | src/lib/engine.js | configureESLint | function configureESLint(options) {
const ESLintConfig = {
rules: options.rules
}
ESLintConfig.extends = 'xo'
if (options.esnext) {
ESLintConfig.extends = 'xo/esnext'
}
if (!options.semicolon) {
ESLintConfig.rules.semi = [2, 'never']
}
if (options.space === false) {
ESLintConfig.rules.indent = [
2... | javascript | function configureESLint(options) {
const ESLintConfig = {
rules: options.rules
}
ESLintConfig.extends = 'xo'
if (options.esnext) {
ESLintConfig.extends = 'xo/esnext'
}
if (!options.semicolon) {
ESLintConfig.rules.semi = [2, 'never']
}
if (options.space === false) {
ESLintConfig.rules.indent = [
2... | [
"function",
"configureESLint",
"(",
"options",
")",
"{",
"const",
"ESLintConfig",
"=",
"{",
"rules",
":",
"options",
".",
"rules",
"}",
"ESLintConfig",
".",
"extends",
"=",
"'xo'",
"if",
"(",
"options",
".",
"esnext",
")",
"{",
"ESLintConfig",
".",
"extend... | Create a configured ESLint factory
@private
@param {options} options - Job options
@return {Function} - Generate an ESLint configuration | [
"Create",
"a",
"configured",
"ESLint",
"factory"
] | 8f58bde3587c3cd88a777380499529282b0d386d | https://github.com/MarkGriffiths/xo-tidy/blob/8f58bde3587c3cd88a777380499529282b0d386d/src/lib/engine.js#L90-L133 | train |
nopnop/grunt-transfo | tasks/transfo.js | function(next) {
async.map([src,dest], function(path, done) {
fs.stat(path, function(err, stat) {
done(null, stat); // Ignore error
});
},
function(err, results) {
statSrc = results[0];
statDest = results[1];
if(!st... | javascript | function(next) {
async.map([src,dest], function(path, done) {
fs.stat(path, function(err, stat) {
done(null, stat); // Ignore error
});
},
function(err, results) {
statSrc = results[0];
statDest = results[1];
if(!st... | [
"function",
"(",
"next",
")",
"{",
"async",
".",
"map",
"(",
"[",
"src",
",",
"dest",
"]",
",",
"function",
"(",
"path",
",",
"done",
")",
"{",
"fs",
".",
"stat",
"(",
"path",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"done",
"(",
"... | Get src and dest stat asynchronously | [
"Get",
"src",
"and",
"dest",
"stat",
"asynchronously"
] | cfa00f07cbf97d48b39bd958abc2f889ba3bbce5 | https://github.com/nopnop/grunt-transfo/blob/cfa00f07cbf97d48b39bd958abc2f889ba3bbce5/tasks/transfo.js#L282-L307 | train | |
nopnop/grunt-transfo | tasks/transfo.js | function(next) {
if(!statDest || !lazy || readOnly) {
return next();
}
if(statDest.mtime.getTime() >= statSrc.mtime.getTime()) {
tally.useCached++;
grunt.verbose.writeln(' Ignore %s:'+' Destination file is allready transformed (See options.lazy).'.grey,... | javascript | function(next) {
if(!statDest || !lazy || readOnly) {
return next();
}
if(statDest.mtime.getTime() >= statSrc.mtime.getTime()) {
tally.useCached++;
grunt.verbose.writeln(' Ignore %s:'+' Destination file is allready transformed (See options.lazy).'.grey,... | [
"function",
"(",
"next",
")",
"{",
"if",
"(",
"!",
"statDest",
"||",
"!",
"lazy",
"||",
"readOnly",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"if",
"(",
"statDest",
".",
"mtime",
".",
"getTime",
"(",
")",
">=",
"statSrc",
".",
"mtime",
".",... | Ignore file processing if the destination allready exist with an equal or posterior mtime | [
"Ignore",
"file",
"processing",
"if",
"the",
"destination",
"allready",
"exist",
"with",
"an",
"equal",
"or",
"posterior",
"mtime"
] | cfa00f07cbf97d48b39bd958abc2f889ba3bbce5 | https://github.com/nopnop/grunt-transfo/blob/cfa00f07cbf97d48b39bd958abc2f889ba3bbce5/tasks/transfo.js#L311-L323 | train | |
nopnop/grunt-transfo | tasks/transfo.js | addToQueueConcat | function addToQueueConcat(sources, dest, options) {
queueConcat.push({
src: sources,
dest: dest,
options: _.extend({}, defaultOptions, options || {})
});
} | javascript | function addToQueueConcat(sources, dest, options) {
queueConcat.push({
src: sources,
dest: dest,
options: _.extend({}, defaultOptions, options || {})
});
} | [
"function",
"addToQueueConcat",
"(",
"sources",
",",
"dest",
",",
"options",
")",
"{",
"queueConcat",
".",
"push",
"(",
"{",
"src",
":",
"sources",
",",
"dest",
":",
"dest",
",",
"options",
":",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"defaultOptions",... | Concat many source to dest
@param {Array} sources
Array of source path
@param {String} dest
Destination path
@param {Object} options
Transfo options object
@return {Promise} TODO | [
"Concat",
"many",
"source",
"to",
"dest"
] | cfa00f07cbf97d48b39bd958abc2f889ba3bbce5 | https://github.com/nopnop/grunt-transfo/blob/cfa00f07cbf97d48b39bd958abc2f889ba3bbce5/tasks/transfo.js#L514-L520 | train |
nopnop/grunt-transfo | tasks/transfo.js | function(next) {
Q.all(sources.map(function(src) {
return Q.nfcall(fs.stat, src)
.then(function(stat) {
statSources[src] = stat;
});
}))
.then(function() { next(); })
.fail(function(err) {next(err);});
} | javascript | function(next) {
Q.all(sources.map(function(src) {
return Q.nfcall(fs.stat, src)
.then(function(stat) {
statSources[src] = stat;
});
}))
.then(function() { next(); })
.fail(function(err) {next(err);});
} | [
"function",
"(",
"next",
")",
"{",
"Q",
".",
"all",
"(",
"sources",
".",
"map",
"(",
"function",
"(",
"src",
")",
"{",
"return",
"Q",
".",
"nfcall",
"(",
"fs",
".",
"stat",
",",
"src",
")",
".",
"then",
"(",
"function",
"(",
"stat",
")",
"{",
... | All sources stats | [
"All",
"sources",
"stats"
] | cfa00f07cbf97d48b39bd958abc2f889ba3bbce5 | https://github.com/nopnop/grunt-transfo/blob/cfa00f07cbf97d48b39bd958abc2f889ba3bbce5/tasks/transfo.js#L550-L559 | train | |
nopnop/grunt-transfo | tasks/transfo.js | function(next) {
// Here destination is allways a file.
// Only the parent folder is required
var dir = dirname(dest);
if(dirExists[dir]) {
return next();
}
grunt.verbose.writeln(' Make directory %s', dir.blue);
mkdirp(dir, function(err... | javascript | function(next) {
// Here destination is allways a file.
// Only the parent folder is required
var dir = dirname(dest);
if(dirExists[dir]) {
return next();
}
grunt.verbose.writeln(' Make directory %s', dir.blue);
mkdirp(dir, function(err... | [
"function",
"(",
"next",
")",
"{",
"// Here destination is allways a file.",
"// Only the parent folder is required",
"var",
"dir",
"=",
"dirname",
"(",
"dest",
")",
";",
"if",
"(",
"dirExists",
"[",
"dir",
"]",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
... | Make parent directory | [
"Make",
"parent",
"directory"
] | cfa00f07cbf97d48b39bd958abc2f889ba3bbce5 | https://github.com/nopnop/grunt-transfo/blob/cfa00f07cbf97d48b39bd958abc2f889ba3bbce5/tasks/transfo.js#L589-L607 | train | |
greggman/hft-game-utils | src/hft/scripts/misc/gameclock.js | function(clock) {
clock = clock || new LocalClock();
this.gameTime = 0;
this.callCount = 0;
var then = clock.getTime();
/**
* Gets the time elapsed in seconds since the last time this was
* called
* @return {number} The time elapsed in seconds since this was
* last called.... | javascript | function(clock) {
clock = clock || new LocalClock();
this.gameTime = 0;
this.callCount = 0;
var then = clock.getTime();
/**
* Gets the time elapsed in seconds since the last time this was
* called
* @return {number} The time elapsed in seconds since this was
* last called.... | [
"function",
"(",
"clock",
")",
"{",
"clock",
"=",
"clock",
"||",
"new",
"LocalClock",
"(",
")",
";",
"this",
".",
"gameTime",
"=",
"0",
";",
"this",
".",
"callCount",
"=",
"0",
";",
"var",
"then",
"=",
"clock",
".",
"getTime",
"(",
")",
";",
"/**... | A clock that returns the time elapsed since the last time it
was queried
@constructor
@alias GameClock
@param {Clock?} The clock to use for this GameClock (pass it
a SyncedClock of you want the clock to be synced or
nothing if you just want a local clock. | [
"A",
"clock",
"that",
"returns",
"the",
"time",
"elapsed",
"since",
"the",
"last",
"time",
"it",
"was",
"queried"
] | 071a0feebeed79d3597efd63e682392179cf0d30 | https://github.com/greggman/hft-game-utils/blob/071a0feebeed79d3597efd63e682392179cf0d30/src/hft/scripts/misc/gameclock.js#L51-L79 | train | |
sbruchmann/fn-stack | index.js | FNStack | function FNStack() {
var stack = slice.call(arguments, 0).filter(function iterator(val) {
return typeof val === "function";
});
this._context = null;
this.stack = stack;
return this;
} | javascript | function FNStack() {
var stack = slice.call(arguments, 0).filter(function iterator(val) {
return typeof val === "function";
});
this._context = null;
this.stack = stack;
return this;
} | [
"function",
"FNStack",
"(",
")",
"{",
"var",
"stack",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
".",
"filter",
"(",
"function",
"iterator",
"(",
"val",
")",
"{",
"return",
"typeof",
"val",
"===",
"\"function\"",
";",
"}",
")",
";",
... | Initializes a new function stack.
@constructor | [
"Initializes",
"a",
"new",
"function",
"stack",
"."
] | 2c68ad15d952ce8c348ed9995c22c9edb936ef99 | https://github.com/sbruchmann/fn-stack/blob/2c68ad15d952ce8c348ed9995c22c9edb936ef99/index.js#L15-L24 | train |
marcusklaas/grunt-inline-alt | tasks/inline.js | function(matchedWord, imgUrl) {
if (!imgUrl || !matchedWord) {
return;
}
var flag = imgUrl.indexOf(options.tag) != -1; // urls like "img/bg.png?__inline" will be transformed to base64
//grunt.log.write('urlMatcher :: matchedWord=' + matchedWord + ',imgUrl=' + ... | javascript | function(matchedWord, imgUrl) {
if (!imgUrl || !matchedWord) {
return;
}
var flag = imgUrl.indexOf(options.tag) != -1; // urls like "img/bg.png?__inline" will be transformed to base64
//grunt.log.write('urlMatcher :: matchedWord=' + matchedWord + ',imgUrl=' + ... | [
"function",
"(",
"matchedWord",
",",
"imgUrl",
")",
"{",
"if",
"(",
"!",
"imgUrl",
"||",
"!",
"matchedWord",
")",
"{",
"return",
";",
"}",
"var",
"flag",
"=",
"imgUrl",
".",
"indexOf",
"(",
"options",
".",
"tag",
")",
"!=",
"-",
"1",
";",
"// urls ... | match tokens with "url" in content | [
"match",
"tokens",
"with",
"url",
"in",
"content"
] | da7d2306183b6eb9546322cdbfd8a2c2e4230972 | https://github.com/marcusklaas/grunt-inline-alt/blob/da7d2306183b6eb9546322cdbfd8a2c2e4230972/tasks/inline.js#L190-L212 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/node.js | function( includeChildren, cloneId ) {
var $clone = this.$.cloneNode( includeChildren );
var removeIds = function( node ) {
// Reset data-cke-expando only when has been cloned (IE and only for some types of objects).
if ( node[ 'data-cke-expando' ] )
node[ 'data-cke-expando' ] = false;
if ( node.... | javascript | function( includeChildren, cloneId ) {
var $clone = this.$.cloneNode( includeChildren );
var removeIds = function( node ) {
// Reset data-cke-expando only when has been cloned (IE and only for some types of objects).
if ( node[ 'data-cke-expando' ] )
node[ 'data-cke-expando' ] = false;
if ( node.... | [
"function",
"(",
"includeChildren",
",",
"cloneId",
")",
"{",
"var",
"$clone",
"=",
"this",
".",
"$",
".",
"cloneNode",
"(",
"includeChildren",
")",
";",
"var",
"removeIds",
"=",
"function",
"(",
"node",
")",
"{",
"// Reset data-cke-expando only when has been cl... | Clones this node.
**Note**: Values set by {#setCustomData} will not be available in the clone.
@param {Boolean} [includeChildren=false] If `true` then all node's
children will be cloned recursively.
@param {Boolean} [cloneId=false] Whether ID attributes should be cloned, too.
@returns {CKEDITOR.dom.node} Clone of thi... | [
"Clones",
"this",
"node",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/node.js#L121-L145 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/node.js | function( normalized ) {
var address = [];
var $documentElement = this.getDocument().$.documentElement;
var node = this.$;
while ( node && node != $documentElement ) {
var parentNode = node.parentNode;
if ( parentNode ) {
// Get the node index. For performance, call getIndex
// directly, instead... | javascript | function( normalized ) {
var address = [];
var $documentElement = this.getDocument().$.documentElement;
var node = this.$;
while ( node && node != $documentElement ) {
var parentNode = node.parentNode;
if ( parentNode ) {
// Get the node index. For performance, call getIndex
// directly, instead... | [
"function",
"(",
"normalized",
")",
"{",
"var",
"address",
"=",
"[",
"]",
";",
"var",
"$documentElement",
"=",
"this",
".",
"getDocument",
"(",
")",
".",
"$",
".",
"documentElement",
";",
"var",
"node",
"=",
"this",
".",
"$",
";",
"while",
"(",
"node... | Retrieves a uniquely identifiable tree address for this node.
The tree address returned is an array of integers, with each integer
indicating a child index of a DOM node, starting from
`document.documentElement`.
For example, assuming `<body>` is the second child
of `<html>` (`<head>` being the first),
and we would li... | [
"Retrieves",
"a",
"uniquely",
"identifiable",
"tree",
"address",
"for",
"this",
"node",
".",
"The",
"tree",
"address",
"returned",
"is",
"an",
"array",
"of",
"integers",
"with",
"each",
"integer",
"indicating",
"a",
"child",
"index",
"of",
"a",
"DOM",
"node"... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/node.js#L234-L252 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/node.js | function( normalized ) {
// Attention: getAddress depends on this.$
// getIndex is called on a plain object: { $ : node }
var current = this.$,
index = -1,
isNormalizing;
if ( !this.$.parentNode )
return index;
do {
// Bypass blank node and adjacent text nodes.
if ( normalized && current != ... | javascript | function( normalized ) {
// Attention: getAddress depends on this.$
// getIndex is called on a plain object: { $ : node }
var current = this.$,
index = -1,
isNormalizing;
if ( !this.$.parentNode )
return index;
do {
// Bypass blank node and adjacent text nodes.
if ( normalized && current != ... | [
"function",
"(",
"normalized",
")",
"{",
"// Attention: getAddress depends on this.$",
"// getIndex is called on a plain object: { $ : node }",
"var",
"current",
"=",
"this",
".",
"$",
",",
"index",
"=",
"-",
"1",
",",
"isNormalizing",
";",
"if",
"(",
"!",
"this",
"... | Gets the index of a node in an array of its `parent.childNodes`.
Let us assume having the following `childNodes` array:
[ emptyText, element1, text, text, element2 ]
element1.getIndex(); // 1
element1.getIndex( true ); // 0
element2.getIndex(); // 4
element2.getIndex( true ); // 2
@param {Boolean} normalized When ... | [
"Gets",
"the",
"index",
"of",
"a",
"node",
"in",
"an",
"array",
"of",
"its",
"parent",
".",
"childNodes",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/node.js#L281-L303 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/node.js | function( closerFirst ) {
var node = this;
var parents = [];
do {
parents[ closerFirst ? 'push' : 'unshift' ]( node );
}
while ( ( node = node.getParent() ) );
return parents;
} | javascript | function( closerFirst ) {
var node = this;
var parents = [];
do {
parents[ closerFirst ? 'push' : 'unshift' ]( node );
}
while ( ( node = node.getParent() ) );
return parents;
} | [
"function",
"(",
"closerFirst",
")",
"{",
"var",
"node",
"=",
"this",
";",
"var",
"parents",
"=",
"[",
"]",
";",
"do",
"{",
"parents",
"[",
"closerFirst",
"?",
"'push'",
":",
"'unshift'",
"]",
"(",
"node",
")",
";",
"}",
"while",
"(",
"(",
"node",
... | Returns an array containing node parents and the node itself. By default nodes are in _descending_ order.
// Assuming that body has paragraph as the first child.
var node = editor.document.getBody().getFirst();
var parents = node.getParents();
alert( parents[ 0 ].getName() + ',' + parents[ 2 ].getName() ); // 'html,p'... | [
"Returns",
"an",
"array",
"containing",
"node",
"parents",
"and",
"the",
"node",
"itself",
".",
"By",
"default",
"nodes",
"are",
"in",
"_descending_",
"order",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/node.js#L464-L474 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/node.js | function( query, includeSelf ) {
var $ = this.$,
evaluator,
isCustomEvaluator;
if ( !includeSelf ) {
$ = $.parentNode;
}
// Custom checker provided in an argument.
if ( typeof query == 'function' ) {
isCustomEvaluator = true;
evaluator = query;
} else {
// Predefined tag name checker.
... | javascript | function( query, includeSelf ) {
var $ = this.$,
evaluator,
isCustomEvaluator;
if ( !includeSelf ) {
$ = $.parentNode;
}
// Custom checker provided in an argument.
if ( typeof query == 'function' ) {
isCustomEvaluator = true;
evaluator = query;
} else {
// Predefined tag name checker.
... | [
"function",
"(",
"query",
",",
"includeSelf",
")",
"{",
"var",
"$",
"=",
"this",
".",
"$",
",",
"evaluator",
",",
"isCustomEvaluator",
";",
"if",
"(",
"!",
"includeSelf",
")",
"{",
"$",
"=",
"$",
".",
"parentNode",
";",
"}",
"// Custom checker provided i... | Gets the closest ancestor node of this node, specified by its name or using an evaluator function.
// Suppose we have the following HTML structure:
// <div id="outer"><div id="inner"><p><b>Some text</b></p></div></div>
// If node == <b>
ascendant = node.getAscendant( 'div' ); // ascendant == <div id="inner">
ascend... | [
"Gets",
"the",
"closest",
"ancestor",
"node",
"of",
"this",
"node",
"specified",
"by",
"its",
"name",
"or",
"using",
"an",
"evaluator",
"function",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/node.js#L571-L608 | train | |
byu-oit/fully-typed | bin/function.js | TypedFunction | function TypedFunction (config) {
const fn = this;
if (config.hasOwnProperty('minArguments') && (!util.isInteger(config.minArguments) || config.minArguments < 0)) {
const message = util.propertyErrorMessage('minArguments', config.minArguments, 'Expected a non-negative integer.');
throw Error(me... | javascript | function TypedFunction (config) {
const fn = this;
if (config.hasOwnProperty('minArguments') && (!util.isInteger(config.minArguments) || config.minArguments < 0)) {
const message = util.propertyErrorMessage('minArguments', config.minArguments, 'Expected a non-negative integer.');
throw Error(me... | [
"function",
"TypedFunction",
"(",
"config",
")",
"{",
"const",
"fn",
"=",
"this",
";",
"if",
"(",
"config",
".",
"hasOwnProperty",
"(",
"'minArguments'",
")",
"&&",
"(",
"!",
"util",
".",
"isInteger",
"(",
"config",
".",
"minArguments",
")",
"||",
"confi... | Create a TypedFunction instance.
@param {object} config
@returns {TypedFunction}
@augments Typed
@constructor | [
"Create",
"a",
"TypedFunction",
"instance",
"."
] | ed6b3ed88ffc72990acffb765232eaaee261afef | https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/function.js#L29-L79 | train |
trentmillar/hash-o-matic | lib/hashomatic.js | function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
/... | javascript | function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
/... | [
"function",
"(",
"value",
",",
"replacer",
",",
"space",
")",
"{",
"// The stringify method takes a value and an optional replacer, and an optional",
"// space parameter, and returns a JSON text. The replacer can be a function",
"// that can replace values, or an array of strings that will sel... | If the JSON object does not yet have a stringify method, give it one. | [
"If",
"the",
"JSON",
"object",
"does",
"not",
"yet",
"have",
"a",
"stringify",
"method",
"give",
"it",
"one",
"."
] | 7193c3fd60e08e245f34d48fc48985298af8c6e1 | https://github.com/trentmillar/hash-o-matic/blob/7193c3fd60e08e245f34d48fc48985298af8c6e1/lib/hashomatic.js#L207-L248 | train | |
odentools/denhub-device | models/helper.js | function () {
if (packageInfo) return packageInfo;
var fs = require('fs');
packageInfo = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8'));
return packageInfo;
} | javascript | function () {
if (packageInfo) return packageInfo;
var fs = require('fs');
packageInfo = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8'));
return packageInfo;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"packageInfo",
")",
"return",
"packageInfo",
";",
"var",
"fs",
"=",
"require",
"(",
"'fs'",
")",
";",
"packageInfo",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/../package.jso... | Read the package information
@return {Object} Package information | [
"Read",
"the",
"package",
"information"
] | 50d35aca96db3a07a3272f1765a660ea893735ce | https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/models/helper.js#L14-L23 | train | |
odentools/denhub-device | models/helper.js | function (is_ignore_errors, opt_config_filename) {
var self = this;
var config_paths = [];
if (opt_config_filename) {
config_paths.push(opt_config_filename);
} else {
// root of dependence source directory
config_paths.push('./config.json');
// root of denhub-device directory
config_paths.push(... | javascript | function (is_ignore_errors, opt_config_filename) {
var self = this;
var config_paths = [];
if (opt_config_filename) {
config_paths.push(opt_config_filename);
} else {
// root of dependence source directory
config_paths.push('./config.json');
// root of denhub-device directory
config_paths.push(... | [
"function",
"(",
"is_ignore_errors",
",",
"opt_config_filename",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"config_paths",
"=",
"[",
"]",
";",
"if",
"(",
"opt_config_filename",
")",
"{",
"config_paths",
".",
"push",
"(",
"opt_config_filename",
")",
"... | Read the configuration file
@return {Object} Configuration | [
"Read",
"the",
"configuration",
"file"
] | 50d35aca96db3a07a3272f1765a660ea893735ce | https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/models/helper.js#L62-L107 | 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.