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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
jhermsmeier/node-vcf | lib/vcard.js | function( version ) {
version = version || '4.0'
var keys = Object.keys( this.data )
var data = [ [ 'version', {}, 'text', version ] ]
var prop = null
for( var i = 0; i < keys.length; i++ ) {
if( keys[i] === 'version' ) continue;
prop = this.data[ keys[i] ]
if( Array.isArray( pr... | javascript | function( version ) {
version = version || '4.0'
var keys = Object.keys( this.data )
var data = [ [ 'version', {}, 'text', version ] ]
var prop = null
for( var i = 0; i < keys.length; i++ ) {
if( keys[i] === 'version' ) continue;
prop = this.data[ keys[i] ]
if( Array.isArray( pr... | [
"function",
"(",
"version",
")",
"{",
"version",
"=",
"version",
"||",
"'4.0'",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"this",
".",
"data",
")",
"var",
"data",
"=",
"[",
"[",
"'version'",
",",
"{",
"}",
",",
"'text'",
",",
"version",
"]",
... | Format the card as jCard
@param {String} version='4.0'
@return {Array} jCard | [
"Format",
"the",
"card",
"as",
"jCard"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/vcard.js#L302-L324 | train | |
jhermsmeier/node-vcf | lib/property.js | function( type ) {
type = ( type + '' ).toLowerCase()
return Array.isArray( this.type ) ?
this.type.indexOf( type ) >= 0 :
this.type === type
} | javascript | function( type ) {
type = ( type + '' ).toLowerCase()
return Array.isArray( this.type ) ?
this.type.indexOf( type ) >= 0 :
this.type === type
} | [
"function",
"(",
"type",
")",
"{",
"type",
"=",
"(",
"type",
"+",
"''",
")",
".",
"toLowerCase",
"(",
")",
"return",
"Array",
".",
"isArray",
"(",
"this",
".",
"type",
")",
"?",
"this",
".",
"type",
".",
"indexOf",
"(",
"type",
")",
">=",
"0",
... | Check whether the property is of a given type
@param {String} type
@return {Boolean} | [
"Check",
"whether",
"the",
"property",
"is",
"of",
"a",
"given",
"type"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/property.js#L70-L75 | train | |
jhermsmeier/node-vcf | lib/property.js | function( version ) {
var propName = (this.group ? this.group + '.' : '') + capitalDashCase( this._field )
var keys = Object.keys( this )
var params = []
for( var i = 0; i < keys.length; i++ ) {
if (keys[i] === 'group') continue
params.push( capitalDashCase( keys[i] ) + '=' + this[ keys[i]... | javascript | function( version ) {
var propName = (this.group ? this.group + '.' : '') + capitalDashCase( this._field )
var keys = Object.keys( this )
var params = []
for( var i = 0; i < keys.length; i++ ) {
if (keys[i] === 'group') continue
params.push( capitalDashCase( keys[i] ) + '=' + this[ keys[i]... | [
"function",
"(",
"version",
")",
"{",
"var",
"propName",
"=",
"(",
"this",
".",
"group",
"?",
"this",
".",
"group",
"+",
"'.'",
":",
"''",
")",
"+",
"capitalDashCase",
"(",
"this",
".",
"_field",
")",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",... | Format the property as vcf with given version
@param {String} version
@return {String} | [
"Format",
"the",
"property",
"as",
"vcf",
"with",
"given",
"version"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/property.js#L99-L114 | train | |
jhermsmeier/node-vcf | lib/property.js | function() {
var params = Object.assign({},this)
if( params.value === 'text' ) {
params.value = void 0
delete params.value
}
var data = [ this._field, params, this.value || 'text' ]
switch( this._field ) {
default: data.push( this._data ); break
case 'adr':
case 'n'... | javascript | function() {
var params = Object.assign({},this)
if( params.value === 'text' ) {
params.value = void 0
delete params.value
}
var data = [ this._field, params, this.value || 'text' ]
switch( this._field ) {
default: data.push( this._data ); break
case 'adr':
case 'n'... | [
"function",
"(",
")",
"{",
"var",
"params",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"this",
")",
"if",
"(",
"params",
".",
"value",
"===",
"'text'",
")",
"{",
"params",
".",
"value",
"=",
"void",
"0",
"delete",
"params",
".",
"value",
"... | Format the property as jCard data
@return {Array} | [
"Format",
"the",
"property",
"as",
"jCard",
"data"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/property.js#L128-L148 | train | |
waterlock/waterlock | lib/utils.js | function(req, res, user) {
var jsonWebTokens = waterlock.config.jsonWebTokens || {};
var expiryUnit = (jsonWebTokens.expiry && jsonWebTokens.expiry.unit) || 'days';
var expiryLength = (jsonWebTokens.expiry && jsonWebTokens.expiry.length) || 7;
var expires = moment().add(expiryLength, expiryUnit).valueOf... | javascript | function(req, res, user) {
var jsonWebTokens = waterlock.config.jsonWebTokens || {};
var expiryUnit = (jsonWebTokens.expiry && jsonWebTokens.expiry.unit) || 'days';
var expiryLength = (jsonWebTokens.expiry && jsonWebTokens.expiry.length) || 7;
var expires = moment().add(expiryLength, expiryUnit).valueOf... | [
"function",
"(",
"req",
",",
"res",
",",
"user",
")",
"{",
"var",
"jsonWebTokens",
"=",
"waterlock",
".",
"config",
".",
"jsonWebTokens",
"||",
"{",
"}",
";",
"var",
"expiryUnit",
"=",
"(",
"jsonWebTokens",
".",
"expiry",
"&&",
"jsonWebTokens",
".",
"exp... | Creates a new JWT token
@param {Integer} req
@param {Object} res
@param {Object} user the user model
@return {Object} the created jwt token.
@api public | [
"Creates",
"a",
"new",
"JWT",
"token"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/utils.js#L73-L95 | train | |
waterlock/waterlock | lib/utils.js | function(req){
var token = null;
if (req.headers && req.headers.authorization) {
var parts = req.headers.authorization.split(' ');
if (parts.length === 2){
var scheme = parts[0];
var credentials = parts[1];
if (/^Bearer$/i.test(scheme)){
token = credentials;
... | javascript | function(req){
var token = null;
if (req.headers && req.headers.authorization) {
var parts = req.headers.authorization.split(' ');
if (parts.length === 2){
var scheme = parts[0];
var credentials = parts[1];
if (/^Bearer$/i.test(scheme)){
token = credentials;
... | [
"function",
"(",
"req",
")",
"{",
"var",
"token",
"=",
"null",
";",
"if",
"(",
"req",
".",
"headers",
"&&",
"req",
".",
"headers",
".",
"authorization",
")",
"{",
"var",
"parts",
"=",
"req",
".",
"headers",
".",
"authorization",
".",
"split",
"(",
... | Return access token from request
@param {Object} req the express request object
@return {String} token
@api public | [
"Return",
"access",
"token",
"from",
"request"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/utils.js#L104-L120 | train | |
waterlock/waterlock | lib/validator.js | function(token, cb){
try{
// decode the token
var _token = waterlock.jwt.decode(token, waterlock.config.jsonWebTokens.secret);
// set the time of the request
var _reqTime = Date.now();
// If token is expired
if(_token.exp <= _reqTime){
waterlock.logger.d... | javascript | function(token, cb){
try{
// decode the token
var _token = waterlock.jwt.decode(token, waterlock.config.jsonWebTokens.secret);
// set the time of the request
var _reqTime = Date.now();
// If token is expired
if(_token.exp <= _reqTime){
waterlock.logger.d... | [
"function",
"(",
"token",
",",
"cb",
")",
"{",
"try",
"{",
"// decode the token",
"var",
"_token",
"=",
"waterlock",
".",
"jwt",
".",
"decode",
"(",
"token",
",",
"waterlock",
".",
"config",
".",
"jsonWebTokens",
".",
"secret",
")",
";",
"// set the time o... | Validates a token
@param {String} token the token to be validated
@param {Function} cb called when error has occured or token is validated | [
"Validates",
"a",
"token"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/validator.js#L20-L51 | train | |
waterlock/waterlock | lib/validator.js | function(token, cb){
// deserialize the token iss
var _iss = token.iss.split('|');
waterlock.User.findOne(_iss[0]).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
}
cb(err, user);
});
} | javascript | function(token, cb){
// deserialize the token iss
var _iss = token.iss.split('|');
waterlock.User.findOne(_iss[0]).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
}
cb(err, user);
});
} | [
"function",
"(",
"token",
",",
"cb",
")",
"{",
"// deserialize the token iss",
"var",
"_iss",
"=",
"token",
".",
"iss",
".",
"split",
"(",
"'|'",
")",
";",
"waterlock",
".",
"User",
".",
"findOne",
"(",
"_iss",
"[",
"0",
"]",
")",
".",
"exec",
"(",
... | Find the user the give token is issued to
@param {Object} token The parsed token
@param {Function} cb Callback to be called when a user is
found or an error has occured | [
"Find",
"the",
"user",
"the",
"give",
"token",
"is",
"issued",
"to"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/validator.js#L60-L71 | train | |
waterlock/waterlock | lib/validator.js | function(req, user){
req.session.authenticated = true;
req.session.user = user;
} | javascript | function(req, user){
req.session.authenticated = true;
req.session.user = user;
} | [
"function",
"(",
"req",
",",
"user",
")",
"{",
"req",
".",
"session",
".",
"authenticated",
"=",
"true",
";",
"req",
".",
"session",
".",
"user",
"=",
"user",
";",
"}"
] | Attaches a user object to the Express req session
@param {Express request} req the Express request object
@param {Waterline DAO} user the waterline user object | [
"Attaches",
"a",
"user",
"object",
"to",
"the",
"Express",
"req",
"session"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/validator.js#L120-L123 | train | |
waterlock/waterlock | lib/validator.js | function(token, address, cb){
waterlock.Jwt.findOne({token: token}, function(err, j){
if(err){
return cb(err);
}
if(!j){
waterlock.logger.debug('access token not found');
return cb('Token not found');
}
if(j.revoked){
waterl... | javascript | function(token, address, cb){
waterlock.Jwt.findOne({token: token}, function(err, j){
if(err){
return cb(err);
}
if(!j){
waterlock.logger.debug('access token not found');
return cb('Token not found');
}
if(j.revoked){
waterl... | [
"function",
"(",
"token",
",",
"address",
",",
"cb",
")",
"{",
"waterlock",
".",
"Jwt",
".",
"findOne",
"(",
"{",
"token",
":",
"token",
"}",
",",
"function",
"(",
"err",
",",
"j",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err... | Finds the DAO instance of the give token and tracks the usage
@param {String} token the raw token
@param {Object} address the transport address
@param {Function} cb Callback to be invoked when an error has
occured or the token was tracked successfully | [
"Finds",
"the",
"DAO",
"instance",
"of",
"the",
"give",
"token",
"and",
"tracks",
"the",
"usage"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/validator.js#L133-L154 | train | |
waterlock/waterlock | lib/validator.js | function(address, token, user, cb){
this.findAndTrackJWT(token, address, function(err){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
cb(null, user);
});
} | javascript | function(address, token, user, cb){
this.findAndTrackJWT(token, address, function(err){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
cb(null, user);
});
} | [
"function",
"(",
"address",
",",
"token",
",",
"user",
",",
"cb",
")",
"{",
"this",
".",
"findAndTrackJWT",
"(",
"token",
",",
"address",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"waterlock",
".",
"logger",
".",
"debug",
"... | Tracks the tokens usage and invokes the user defined callback
@param {Object} address the transport address
@param {String} token the raw token
@param {Waterline DAO} user the waterline user object
@param {Function} cb Callback to be invoked when an error has occured
or the token has been tracked s... | [
"Tracks",
"the",
"tokens",
"usage",
"and",
"invokes",
"the",
"user",
"defined",
"callback"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/validator.js#L165-L173 | train | |
waterlock/waterlock | lib/waterlock.js | Waterlock | function Waterlock(){
events.EventEmitter.call(this);
this.sails = global.sails;
this.engine = _.bind(this.engine, this)();
this.config = _.bind(this.config, this)();
this.methods = _.bind(this.methods, this)().collect();
this.models = _.bind(this.models, this)();
this.actions = ... | javascript | function Waterlock(){
events.EventEmitter.call(this);
this.sails = global.sails;
this.engine = _.bind(this.engine, this)();
this.config = _.bind(this.config, this)();
this.methods = _.bind(this.methods, this)().collect();
this.models = _.bind(this.models, this)();
this.actions = ... | [
"function",
"Waterlock",
"(",
")",
"{",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"sails",
"=",
"global",
".",
"sails",
";",
"this",
".",
"engine",
"=",
"_",
".",
"bind",
"(",
"this",
".",
"engine",
",",
"this"... | Creates a waterlock instance | [
"Creates",
"a",
"waterlock",
"instance"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/waterlock.js#L12-L29 | train |
waterlock/waterlock | lib/engine.js | function(auth, cb){
var self = this;
// create the user
if(!auth.user){
waterlock.User.create({auth:auth.id}).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
// update the auth object
waterlock.... | javascript | function(auth, cb){
var self = this;
// create the user
if(!auth.user){
waterlock.User.create({auth:auth.id}).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
// update the auth object
waterlock.... | [
"function",
"(",
"auth",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// create the user",
"if",
"(",
"!",
"auth",
".",
"user",
")",
"{",
"waterlock",
".",
"User",
".",
"create",
"(",
"{",
"auth",
":",
"auth",
".",
"id",
"}",
")",
".",
... | This will create a user and auth object if one is not found
@param {Object} criteria should be id to find the auth by
@param {Object} attributes auth attributes
@param {Function} cb function to be called when the auth has been
found or an error has occurred
@api private | [
"This",
"will",
"create",
"a",
"user",
"and",
"auth",
"object",
"if",
"one",
"is",
"not",
"found"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/engine.js#L41-L72 | train | |
waterlock/waterlock | lib/engine.js | function(criteria, attributes, cb){
var self = this;
waterlock.Auth.findOrCreate(criteria, attributes)
.exec(function(err, newAuth){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
waterlock.Auth.findOne(newAuth.id).populate('user')
.exec(fu... | javascript | function(criteria, attributes, cb){
var self = this;
waterlock.Auth.findOrCreate(criteria, attributes)
.exec(function(err, newAuth){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
waterlock.Auth.findOne(newAuth.id).populate('user')
.exec(fu... | [
"function",
"(",
"criteria",
",",
"attributes",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"waterlock",
".",
"Auth",
".",
"findOrCreate",
"(",
"criteria",
",",
"attributes",
")",
".",
"exec",
"(",
"function",
"(",
"err",
",",
"newAuth",
")",... | Find or create the auth then pass the results to _attachAuthToUser
@param {Object} criteria should be id to find the auth by
@param {Object} attributes auth attributes
@param {Function} cb function to be called when the auth has been
found or an error has occurred
@api public | [
"Find",
"or",
"create",
"the",
"auth",
"then",
"pass",
"the",
"results",
"to",
"_attachAuthToUser"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/engine.js#L84-L103 | train | |
waterlock/waterlock | lib/engine.js | function(attributes, user, cb){
var self = this;
attributes.user = user.id;
waterlock.User.findOne(user.id).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
if(user.auth){
delete(attributes.auth);
//upda... | javascript | function(attributes, user, cb){
var self = this;
attributes.user = user.id;
waterlock.User.findOne(user.id).exec(function(err, user){
if(err){
waterlock.logger.debug(err);
return cb(err);
}
if(user.auth){
delete(attributes.auth);
//upda... | [
"function",
"(",
"attributes",
",",
"user",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"attributes",
".",
"user",
"=",
"user",
".",
"id",
";",
"waterlock",
".",
"User",
".",
"findOne",
"(",
"user",
".",
"id",
")",
".",
"exec",
"(",
"fu... | Attach given auth attributes to user
@param {Object} attributes auth attributes
@param {Object} user user instance
@param {Function} cb function to be called when the auth has been
attached or an error has occurred
@api public | [
"Attach",
"given",
"auth",
"attributes",
"to",
"user"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/engine.js#L114-L154 | train | |
waterlock/waterlock | lib/engine.js | function(auth){
// nothing to invert
if(!auth || !auth.user){
return auth;
}
var u = auth.user;
delete(auth.user);
u.auth = auth;
return u;
} | javascript | function(auth){
// nothing to invert
if(!auth || !auth.user){
return auth;
}
var u = auth.user;
delete(auth.user);
u.auth = auth;
return u;
} | [
"function",
"(",
"auth",
")",
"{",
"// nothing to invert",
"if",
"(",
"!",
"auth",
"||",
"!",
"auth",
".",
"user",
")",
"{",
"return",
"auth",
";",
"}",
"var",
"u",
"=",
"auth",
".",
"user",
";",
"delete",
"(",
"auth",
".",
"user",
")",
";",
"u",... | Inverts the auth object so we don't need to run another query
@param {Object} auth Auth object
@return {Object} User object
@api private | [
"Inverts",
"the",
"auth",
"object",
"so",
"we",
"don",
"t",
"need",
"to",
"run",
"another",
"query"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/engine.js#L163-L173 | train | |
waterlock/waterlock | lib/engine.js | function(auth, attributes){
if(!_.isEqual(auth, attributes)){
_.merge(auth, attributes);
return true;
}
return false;
} | javascript | function(auth, attributes){
if(!_.isEqual(auth, attributes)){
_.merge(auth, attributes);
return true;
}
return false;
} | [
"function",
"(",
"auth",
",",
"attributes",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isEqual",
"(",
"auth",
",",
"attributes",
")",
")",
"{",
"_",
".",
"merge",
"(",
"auth",
",",
"attributes",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
... | Decorates the auth object with values of the attributes object
where the attributes differ from the auth
@param {Object} auth waterline Auth instance
@param {Object} attributes used to update auth with
@return {Boolean} true if any values were updated | [
"Decorates",
"the",
"auth",
"object",
"with",
"values",
"of",
"the",
"attributes",
"object",
"where",
"the",
"attributes",
"differ",
"from",
"the",
"auth"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/engine.js#L183-L189 | train | |
waterlock/waterlock | lib/controllers/index.js | function(actions){
waterlock.logger.verbose('bootstraping user actions');
var template = {
jwt: require('./actions/jwt')
};
return _.merge(template, actions);
} | javascript | function(actions){
waterlock.logger.verbose('bootstraping user actions');
var template = {
jwt: require('./actions/jwt')
};
return _.merge(template, actions);
} | [
"function",
"(",
"actions",
")",
"{",
"waterlock",
".",
"logger",
".",
"verbose",
"(",
"'bootstraping user actions'",
")",
";",
"var",
"template",
"=",
"{",
"jwt",
":",
"require",
"(",
"'./actions/jwt'",
")",
"}",
";",
"return",
"_",
".",
"merge",
"(",
"... | bootstraps user defined overrides with template actions
@param {object} actions user defiend actions
@return {object} user actions merged with template | [
"bootstraps",
"user",
"defined",
"overrides",
"with",
"template",
"actions"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/controllers/index.js#L46-L53 | train | |
waterlock/waterlock | lib/cycle.js | function(req, res, user) {
waterlock.logger.debug('user registration success');
if (!user) {
waterlock.logger.debug('registerSuccess requires a valid user object');
return res.serverError();
}
var address = this._addressFromRequest(req);
var attempt = {
user: user... | javascript | function(req, res, user) {
waterlock.logger.debug('user registration success');
if (!user) {
waterlock.logger.debug('registerSuccess requires a valid user object');
return res.serverError();
}
var address = this._addressFromRequest(req);
var attempt = {
user: user... | [
"function",
"(",
"req",
",",
"res",
",",
"user",
")",
"{",
"waterlock",
".",
"logger",
".",
"debug",
"(",
"'user registration success'",
")",
";",
"if",
"(",
"!",
"user",
")",
"{",
"waterlock",
".",
"logger",
".",
"debug",
"(",
"'registerSuccess requires a... | handles successful logins
@param {Object} req express request object
@param {Object} res expresss response object
@param {Object} user the user instance
@api public | [
"handles",
"successful",
"logins"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L23-L77 | train | |
waterlock/waterlock | lib/cycle.js | function(req, res, user, error) {
waterlock.logger.debug('user register failure');
if (user) {
var address = this._addressFromRequest(req);
var attempt = {
user: user.id,
successful: false
};
_.merge(attempt, address);
waterlock.Attempt.create(... | javascript | function(req, res, user, error) {
waterlock.logger.debug('user register failure');
if (user) {
var address = this._addressFromRequest(req);
var attempt = {
user: user.id,
successful: false
};
_.merge(attempt, address);
waterlock.Attempt.create(... | [
"function",
"(",
"req",
",",
"res",
",",
"user",
",",
"error",
")",
"{",
"waterlock",
".",
"logger",
".",
"debug",
"(",
"'user register failure'",
")",
";",
"if",
"(",
"user",
")",
"{",
"var",
"address",
"=",
"this",
".",
"_addressFromRequest",
"(",
"r... | handles registration failures
@param {Object} req express request object
@param {Object} res expresss response object
@param {Object} user the user instance
@param {Object|String} error the error that caused the failure
@api public | [
"handles",
"registration",
"failures"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L88-L123 | train | |
waterlock/waterlock | lib/cycle.js | function(req, res) {
waterlock.logger.debug('user logout');
delete(req.session.user);
if (req.session.authenticated) {
this.logoutSuccess(req, res);
} else {
this.logoutFailure(req, res);
}
} | javascript | function(req, res) {
waterlock.logger.debug('user logout');
delete(req.session.user);
if (req.session.authenticated) {
this.logoutSuccess(req, res);
} else {
this.logoutFailure(req, res);
}
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"waterlock",
".",
"logger",
".",
"debug",
"(",
"'user logout'",
")",
";",
"delete",
"(",
"req",
".",
"session",
".",
"user",
")",
";",
"if",
"(",
"req",
".",
"session",
".",
"authenticated",
")",
"{",
"... | handles logout events
@param {Object} req express request object
@param {Object} res expresss response object
@api public | [
"handles",
"logout",
"events"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L242-L251 | train | |
waterlock/waterlock | lib/cycle.js | function(req, res) {
req.session.authenticated = false;
var defaultString = 'You have successfully logged out.';
// now respond or redirect
var postResponse = this._resolvePostAction(waterlock.config.postActions.logout.success,
defaultString);
if (typeof postResponse === 'strin... | javascript | function(req, res) {
req.session.authenticated = false;
var defaultString = 'You have successfully logged out.';
// now respond or redirect
var postResponse = this._resolvePostAction(waterlock.config.postActions.logout.success,
defaultString);
if (typeof postResponse === 'strin... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"session",
".",
"authenticated",
"=",
"false",
";",
"var",
"defaultString",
"=",
"'You have successfully logged out.'",
";",
"// now respond or redirect",
"var",
"postResponse",
"=",
"this",
".",
"_resolveP... | the logout 'success' event
@param {Object} req express request object
@param {Object} res express response object
@api public | [
"the",
"logout",
"success",
"event"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L260-L275 | train | |
waterlock/waterlock | lib/cycle.js | function(req, res) {
var defaultString = 'You have successfully logged out.';
// now respond or redirect
var postResponse = this._resolvePostAction(waterlock.config.postActions.logout.failure,
defaultString);
if (typeof postResponse === 'string' && this._isURI(postResponse)) {
... | javascript | function(req, res) {
var defaultString = 'You have successfully logged out.';
// now respond or redirect
var postResponse = this._resolvePostAction(waterlock.config.postActions.logout.failure,
defaultString);
if (typeof postResponse === 'string' && this._isURI(postResponse)) {
... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"defaultString",
"=",
"'You have successfully logged out.'",
";",
"// now respond or redirect",
"var",
"postResponse",
"=",
"this",
".",
"_resolvePostAction",
"(",
"waterlock",
".",
"config",
".",
"postActions",
"... | the logout 'failure' event
@param {Object} req express request object
@param {Object} res express response object
@api public | [
"the",
"logout",
"failure",
"event"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L284-L296 | train | |
waterlock/waterlock | lib/cycle.js | function(req) {
if (req.connection && req.connection.remoteAddress) {
return {
ip: req.connection.remoteAddress,
port: req.connection.remotePort
};
}
if (req.socket && req.socket.remoteAddress) {
return {
ip: req.socket.remoteAddress,
po... | javascript | function(req) {
if (req.connection && req.connection.remoteAddress) {
return {
ip: req.connection.remoteAddress,
port: req.connection.remotePort
};
}
if (req.socket && req.socket.remoteAddress) {
return {
ip: req.socket.remoteAddress,
po... | [
"function",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"connection",
"&&",
"req",
".",
"connection",
".",
"remoteAddress",
")",
"{",
"return",
"{",
"ip",
":",
"req",
".",
"connection",
".",
"remoteAddress",
",",
"port",
":",
"req",
".",
"connection",... | returns an ip address and port from the express request object, or the
sails.io socket which is attached to the req object.
@param {Object} req express request
@return {Object} the transport address object
@api private | [
"returns",
"an",
"ip",
"address",
"and",
"port",
"from",
"the",
"express",
"request",
"object",
"or",
"the",
"sails",
".",
"io",
"socket",
"which",
"is",
"attached",
"to",
"the",
"req",
"object",
"."
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L323-L342 | train | |
waterlock/waterlock | lib/cycle.js | function(obj) {
if (typeof obj.controller === 'undefined' || typeof obj.action === 'undefined') {
var error = new Error('You must define a controller and action to redirect to.').stack;
throw error;
}
return '/' + obj.controller + '/' + obj.action;
} | javascript | function(obj) {
if (typeof obj.controller === 'undefined' || typeof obj.action === 'undefined') {
var error = new Error('You must define a controller and action to redirect to.').stack;
throw error;
}
return '/' + obj.controller + '/' + obj.action;
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
".",
"controller",
"===",
"'undefined'",
"||",
"typeof",
"obj",
".",
"action",
"===",
"'undefined'",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'You must define a controller and action to ... | returns the relative path from an object, the object is
expected to look like the following
example:
{
controller: 'foo',
action: 'bar'
}
@param {Object} obj the redirect object
@return {String} the relative path
@api private | [
"returns",
"the",
"relative",
"path",
"from",
"an",
"object",
"the",
"object",
"is",
"expected",
"to",
"look",
"like",
"the",
"following"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/cycle.js#L380-L387 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(target){
for(var i = 0; i < self.waterlockPlugins.length; i++){
var arr = this.readdirSyncComplete(self.waterlockPlugins[i] + '/' + target);
this.installArray = this.installArray.concat(arr);
}
} | javascript | function(target){
for(var i = 0; i < self.waterlockPlugins.length; i++){
var arr = this.readdirSyncComplete(self.waterlockPlugins[i] + '/' + target);
this.installArray = this.installArray.concat(arr);
}
} | [
"function",
"(",
"target",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"self",
".",
"waterlockPlugins",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"readdirSyncComplete",
"(",
"self",
".",
"waterlockPlugins... | collects all targets to install from all waterlock modules
@param {String} target the resource to collect from waterlock module | [
"collects",
"all",
"targets",
"to",
"install",
"from",
"all",
"waterlock",
"modules"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L78-L83 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(path){
var fullPath = [];
try{
var files = fs.readdirSync(path);
for(var i = 0; i < files.length; i++){
fullPath.push(path + '/' + files[i]);
}
return fullPath;
}catch(e){
return [];
}
} | javascript | function(path){
var fullPath = [];
try{
var files = fs.readdirSync(path);
for(var i = 0; i < files.length; i++){
fullPath.push(path + '/' + files[i]);
}
return fullPath;
}catch(e){
return [];
}
} | [
"function",
"(",
"path",
")",
"{",
"var",
"fullPath",
"=",
"[",
"]",
";",
"try",
"{",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"path",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++... | reads contents of directory and returns an Array
of full path strings to the files
@param {String} path the directory path to search
@return {Array} array of fullpath strings of every file in directory | [
"reads",
"contents",
"of",
"directory",
"and",
"returns",
"an",
"Array",
"of",
"full",
"path",
"strings",
"to",
"the",
"files"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L103-L114 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(){
console.log('');
this.log('Usage: generate [resource]');
this.log('Resources:');
this.log(' all generates all components', false);
this.log(' models generates all models', false);
this.log(' controllers generates all contro... | javascript | function(){
console.log('');
this.log('Usage: generate [resource]');
this.log('Resources:');
this.log(' all generates all components', false);
this.log(' models generates all models', false);
this.log(' controllers generates all contro... | [
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"''",
")",
";",
"this",
".",
"log",
"(",
"'Usage: generate [resource]'",
")",
";",
"this",
".",
"log",
"(",
"'Resources:'",
")",
";",
"this",
".",
"log",
"(",
"' all generates all com... | Shows the script usage | [
"Shows",
"the",
"script",
"usage"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L127-L137 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(src, dest){
if(fs.existsSync(dest)){
this.waitForResponse(src, dest);
}else{
this.copy(src, dest);
this.triggerNext();
}
} | javascript | function(src, dest){
if(fs.existsSync(dest)){
this.waitForResponse(src, dest);
}else{
this.copy(src, dest);
this.triggerNext();
}
} | [
"function",
"(",
"src",
",",
"dest",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"dest",
")",
")",
"{",
"this",
".",
"waitForResponse",
"(",
"src",
",",
"dest",
")",
";",
"}",
"else",
"{",
"this",
".",
"copy",
"(",
"src",
",",
"dest",
")... | tries to install the source file to the destination path, if it exsits
in the destination will trigger a prompt.
@param {String} src fullpath of source file to install
@param {String} dest fullpath of destination file to install | [
"tries",
"to",
"install",
"the",
"source",
"file",
"to",
"the",
"destination",
"path",
"if",
"it",
"exsits",
"in",
"the",
"destination",
"will",
"trigger",
"a",
"prompt",
"."
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L207-L214 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(src, dest){
self.logger.info('generating '+dest);
fs.createReadStream(src).pipe(fs.createWriteStream(dest));
} | javascript | function(src, dest){
self.logger.info('generating '+dest);
fs.createReadStream(src).pipe(fs.createWriteStream(dest));
} | [
"function",
"(",
"src",
",",
"dest",
")",
"{",
"self",
".",
"logger",
".",
"info",
"(",
"'generating '",
"+",
"dest",
")",
";",
"fs",
".",
"createReadStream",
"(",
"src",
")",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"dest",
")",
")",
... | copies the source to the destination
@param {String} src the source file
@param {String} dest the destination file | [
"copies",
"the",
"source",
"to",
"the",
"destination"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L222-L225 | train | |
waterlock/waterlock | bin/waterlock-auth-methods.js | function(src, dest){
self.logger.warn('File at '+dest+' exists, overwrite?');
rl.question('(yN) ', function(answer){
switch(answer.toLowerCase()){
case 'y':
this.copy(src, dest);
this.triggerNext();
break;
case 'n':
this.t... | javascript | function(src, dest){
self.logger.warn('File at '+dest+' exists, overwrite?');
rl.question('(yN) ', function(answer){
switch(answer.toLowerCase()){
case 'y':
this.copy(src, dest);
this.triggerNext();
break;
case 'n':
this.t... | [
"function",
"(",
"src",
",",
"dest",
")",
"{",
"self",
".",
"logger",
".",
"warn",
"(",
"'File at '",
"+",
"dest",
"+",
"' exists, overwrite?'",
")",
";",
"rl",
".",
"question",
"(",
"'(yN) '",
",",
"function",
"(",
"answer",
")",
"{",
"switch",
"(",
... | prompts the user if we can overwrite the destination file
@param {String} src the source file
@param {String} dest the destination file | [
"prompts",
"the",
"user",
"if",
"we",
"can",
"overwrite",
"the",
"destination",
"file"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/bin/waterlock-auth-methods.js#L233-L250 | train | |
waterlock/waterlock | lib/methods.js | function(){
var func;
if(typeof waterlock.config.authMethod[0] === 'object'){
func = this._handleObjects;
}else if(typeof waterlock.config.authMethod === 'object'){
func = this._handleObject;
}else{
func = this._handleName;
}
return func.apply(this, [waterlo... | javascript | function(){
var func;
if(typeof waterlock.config.authMethod[0] === 'object'){
func = this._handleObjects;
}else if(typeof waterlock.config.authMethod === 'object'){
func = this._handleObject;
}else{
func = this._handleName;
}
return func.apply(this, [waterlo... | [
"function",
"(",
")",
"{",
"var",
"func",
";",
"if",
"(",
"typeof",
"waterlock",
".",
"config",
".",
"authMethod",
"[",
"0",
"]",
"===",
"'object'",
")",
"{",
"func",
"=",
"this",
".",
"_handleObjects",
";",
"}",
"else",
"if",
"(",
"typeof",
"waterlo... | try to require the authentcation method defined in user config
@return {Object} containing all required auth methods
@api private | [
"try",
"to",
"require",
"the",
"authentcation",
"method",
"defined",
"in",
"user",
"config"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/methods.js#L22-L34 | train | |
waterlock/waterlock | lib/methods.js | function(authMethods){
var _method = {};
var _methodName;
try{
_.each(authMethods, function(method){
_methodName = method.name;
method = _.merge(require('../../'+_methodName), method);
_method[method.authType] = method;
});
}catch(e){
this._... | javascript | function(authMethods){
var _method = {};
var _methodName;
try{
_.each(authMethods, function(method){
_methodName = method.name;
method = _.merge(require('../../'+_methodName), method);
_method[method.authType] = method;
});
}catch(e){
this._... | [
"function",
"(",
"authMethods",
")",
"{",
"var",
"_method",
"=",
"{",
"}",
";",
"var",
"_methodName",
";",
"try",
"{",
"_",
".",
"each",
"(",
"authMethods",
",",
"function",
"(",
"method",
")",
"{",
"_methodName",
"=",
"method",
".",
"name",
";",
"me... | requires an array of auth method objects
@param {Array} authMethods object array of auth methods
@return {Object} containing all required auth methods
@api private | [
"requires",
"an",
"array",
"of",
"auth",
"method",
"objects"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/methods.js#L43-L58 | train | |
waterlock/waterlock | lib/methods.js | function(authMethod){
var method = {};
var _methodName = authMethod.name;
try{
var _method = _.merge(require('../../'+_methodName), authMethod);
method[_method.authType] = _method;
}catch(e){
this._errorHandler(_methodName);
}
return method;
} | javascript | function(authMethod){
var method = {};
var _methodName = authMethod.name;
try{
var _method = _.merge(require('../../'+_methodName), authMethod);
method[_method.authType] = _method;
}catch(e){
this._errorHandler(_methodName);
}
return method;
} | [
"function",
"(",
"authMethod",
")",
"{",
"var",
"method",
"=",
"{",
"}",
";",
"var",
"_methodName",
"=",
"authMethod",
".",
"name",
";",
"try",
"{",
"var",
"_method",
"=",
"_",
".",
"merge",
"(",
"require",
"(",
"'../../'",
"+",
"_methodName",
")",
"... | requires a single auth method by object
@param {Object} authMethod the auth method
@return {Object} containing all required auth methods
@api private | [
"requires",
"a",
"single",
"auth",
"method",
"by",
"object"
] | 088c7f9c641f626e6ebe9de4eec68f7eddf8d094 | https://github.com/waterlock/waterlock/blob/088c7f9c641f626e6ebe9de4eec68f7eddf8d094/lib/methods.js#L67-L79 | train | |
fogus/lemonad | lib/lemonad.js | function(thing) {
if (L.existy(thing) && L.existy(thing.snapshot))
return thing.snapshot();
else
fail("snapshot not currently implemented")
//return L.snapshot(thing);
} | javascript | function(thing) {
if (L.existy(thing) && L.existy(thing.snapshot))
return thing.snapshot();
else
fail("snapshot not currently implemented")
//return L.snapshot(thing);
} | [
"function",
"(",
"thing",
")",
"{",
"if",
"(",
"L",
".",
"existy",
"(",
"thing",
")",
"&&",
"L",
".",
"existy",
"(",
"thing",
".",
"snapshot",
")",
")",
"return",
"thing",
".",
"snapshot",
"(",
")",
";",
"else",
"fail",
"(",
"\"snapshot not currently... | Delegates down to the snapshot method if an object has one or clones the object outright if not. This is not as robust as it could be. Explore the possibility of pulling in Lo-Dash's impl. | [
"Delegates",
"down",
"to",
"the",
"snapshot",
"method",
"if",
"an",
"object",
"has",
"one",
"or",
"clones",
"the",
"object",
"outright",
"if",
"not",
".",
"This",
"is",
"not",
"as",
"robust",
"as",
"it",
"could",
"be",
".",
"Explore",
"the",
"possibility... | 49d32baa003d22cb22c577acab75865eab9e3dcb | https://github.com/fogus/lemonad/blob/49d32baa003d22cb22c577acab75865eab9e3dcb/lib/lemonad.js#L87-L93 | train | |
fogus/lemonad | lib/lemonad.js | function(index) {
return function(array) {
if ((index < 0) || (index > array.length - 1)) L.fail("L.nth failure: attempting to index outside the bounds of the given array.");
return array[index];
};
} | javascript | function(index) {
return function(array) {
if ((index < 0) || (index > array.length - 1)) L.fail("L.nth failure: attempting to index outside the bounds of the given array.");
return array[index];
};
} | [
"function",
"(",
"index",
")",
"{",
"return",
"function",
"(",
"array",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">",
"array",
".",
"length",
"-",
"1",
")",
")",
"L",
".",
"fail",
"(",
"\"L.nth failure: attempting to inde... | A function to get at an index into an array | [
"A",
"function",
"to",
"get",
"at",
"an",
"index",
"into",
"an",
"array"
] | 49d32baa003d22cb22c577acab75865eab9e3dcb | https://github.com/fogus/lemonad/blob/49d32baa003d22cb22c577acab75865eab9e3dcb/lib/lemonad.js#L387-L392 | train | |
fogus/lemonad | lib/lemonad.js | notify | function notify(oldVal, newVal) {
var count = 0;
for (var key in watchers) {
var watcher = watchers[key];
watcher.call(this, key, oldVal, newVal);
count++;
}
return count;
} | javascript | function notify(oldVal, newVal) {
var count = 0;
for (var key in watchers) {
var watcher = watchers[key];
watcher.call(this, key, oldVal, newVal);
count++;
}
return count;
} | [
"function",
"notify",
"(",
"oldVal",
",",
"newVal",
")",
"{",
"var",
"count",
"=",
"0",
";",
"for",
"(",
"var",
"key",
"in",
"watchers",
")",
"{",
"var",
"watcher",
"=",
"watchers",
"[",
"key",
"]",
";",
"watcher",
".",
"call",
"(",
"this",
",",
... | The use of named function exprs is a temporary hack to make these methods play nicely with `invoker`. This is a non-portable technique. | [
"The",
"use",
"of",
"named",
"function",
"exprs",
"is",
"a",
"temporary",
"hack",
"to",
"make",
"these",
"methods",
"play",
"nicely",
"with",
"invoker",
".",
"This",
"is",
"a",
"non",
"-",
"portable",
"technique",
"."
] | 49d32baa003d22cb22c577acab75865eab9e3dcb | https://github.com/fogus/lemonad/blob/49d32baa003d22cb22c577acab75865eab9e3dcb/lib/lemonad.js#L880-L889 | train |
jmreyes/passport-google-id-token | lib/passport-google-id-token/strategy.js | getGoogleCerts | function getGoogleCerts(kid, callback) {
request({uri: 'https://www.googleapis.com/oauth2/v1/certs'}, function(err, res, body) {
if (err || !res || res.statusCode != 200) {
err = err || new Error('error while retrieving Google certs');
callback(err);
} else {
try {
var keys = JSON.pa... | javascript | function getGoogleCerts(kid, callback) {
request({uri: 'https://www.googleapis.com/oauth2/v1/certs'}, function(err, res, body) {
if (err || !res || res.statusCode != 200) {
err = err || new Error('error while retrieving Google certs');
callback(err);
} else {
try {
var keys = JSON.pa... | [
"function",
"getGoogleCerts",
"(",
"kid",
",",
"callback",
")",
"{",
"request",
"(",
"{",
"uri",
":",
"'https://www.googleapis.com/oauth2/v1/certs'",
"}",
",",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
"||",
"!",
"res",
... | Return the Google certificate that will be used for signature validation.
A custom function can be used instead when passed as an option in the Strategy
constructor. It can be interesting e.g. if caching is needed.
@param {String} kid The key id specified in the token
@param {Function} callback
@api protected | [
"Return",
"the",
"Google",
"certificate",
"that",
"will",
"be",
"used",
"for",
"signature",
"validation",
"."
] | 83cff7801407e6b14fe8097dc2b512c04edba5f8 | https://github.com/jmreyes/passport-google-id-token/blob/83cff7801407e6b14fe8097dc2b512c04edba5f8/lib/passport-google-id-token/strategy.js#L70-L85 | train |
fogus/lemonad | examples/nationjs/shape.js | getArtists | function getArtists(library) {
var ret = [];
for (var i = 0; i < library.length; i++) {
ret.push(cell('artist', i, library));
}
return ret;
} | javascript | function getArtists(library) {
var ret = [];
for (var i = 0; i < library.length; i++) {
ret.push(cell('artist', i, library));
}
return ret;
} | [
"function",
"getArtists",
"(",
"library",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"library",
".",
"length",
";",
"i",
"++",
")",
"{",
"ret",
".",
"push",
"(",
"cell",
"(",
"'artist'",
",",
... | => "Om" | [
"=",
">",
"Om"
] | 49d32baa003d22cb22c577acab75865eab9e3dcb | https://github.com/fogus/lemonad/blob/49d32baa003d22cb22c577acab75865eab9e3dcb/examples/nationjs/shape.js#L29-L37 | train |
fabito/botkit-storage-datastore | src/index.js | get | function get(datastore, kind, namespace) {
return function(id, cb) {
var keyParam = [kind, id];
if (namespace) {
keyParam = {
namespace: namespace,
path: keyParam
};
}
var key = datastore.key(keyParam);
datastore.get(ke... | javascript | function get(datastore, kind, namespace) {
return function(id, cb) {
var keyParam = [kind, id];
if (namespace) {
keyParam = {
namespace: namespace,
path: keyParam
};
}
var key = datastore.key(keyParam);
datastore.get(ke... | [
"function",
"get",
"(",
"datastore",
",",
"kind",
",",
"namespace",
")",
"{",
"return",
"function",
"(",
"id",
",",
"cb",
")",
"{",
"var",
"keyParam",
"=",
"[",
"kind",
",",
"id",
"]",
";",
"if",
"(",
"namespace",
")",
"{",
"keyParam",
"=",
"{",
... | Given a datastore reference and a kind, will return a function that will get a single entity by key
@param {Object} datastore A reference to the datastore Object
@param {String} kind The entity kind
@returns {Function} The get function | [
"Given",
"a",
"datastore",
"reference",
"and",
"a",
"kind",
"will",
"return",
"a",
"function",
"that",
"will",
"get",
"a",
"single",
"entity",
"by",
"key"
] | e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3 | https://github.com/fabito/botkit-storage-datastore/blob/e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3/src/index.js#L49-L67 | train |
fabito/botkit-storage-datastore | src/index.js | save | function save(datastore, kind, namespace) {
return function(data, cb) {
var keyParam = [kind, data.id];
if (namespace) {
keyParam = {
namespace: namespace,
path: keyParam
};
}
var key = datastore.key(keyParam);
datastore... | javascript | function save(datastore, kind, namespace) {
return function(data, cb) {
var keyParam = [kind, data.id];
if (namespace) {
keyParam = {
namespace: namespace,
path: keyParam
};
}
var key = datastore.key(keyParam);
datastore... | [
"function",
"save",
"(",
"datastore",
",",
"kind",
",",
"namespace",
")",
"{",
"return",
"function",
"(",
"data",
",",
"cb",
")",
"{",
"var",
"keyParam",
"=",
"[",
"kind",
",",
"data",
".",
"id",
"]",
";",
"if",
"(",
"namespace",
")",
"{",
"keyPara... | Given a datastore reference and a kind, will return a function that will save an entity.
The object must have an id property
@param {Object} datastore A reference to the datastore Object
@param {String} kind The entity kind
@returns {Function} The save function | [
"Given",
"a",
"datastore",
"reference",
"and",
"a",
"kind",
"will",
"return",
"a",
"function",
"that",
"will",
"save",
"an",
"entity",
".",
"The",
"object",
"must",
"have",
"an",
"id",
"property"
] | e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3 | https://github.com/fabito/botkit-storage-datastore/blob/e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3/src/index.js#L98-L110 | train |
fabito/botkit-storage-datastore | src/index.js | all | function all(datastore, kind, namespace) {
return function(cb) {
var query = null;
if (namespace) {
query = datastore.createQuery(namespace, kind);
} else {
query = datastore.createQuery(kind);
}
datastore.runQuery(query, function(err, entities) {
... | javascript | function all(datastore, kind, namespace) {
return function(cb) {
var query = null;
if (namespace) {
query = datastore.createQuery(namespace, kind);
} else {
query = datastore.createQuery(kind);
}
datastore.runQuery(query, function(err, entities) {
... | [
"function",
"all",
"(",
"datastore",
",",
"kind",
",",
"namespace",
")",
"{",
"return",
"function",
"(",
"cb",
")",
"{",
"var",
"query",
"=",
"null",
";",
"if",
"(",
"namespace",
")",
"{",
"query",
"=",
"datastore",
".",
"createQuery",
"(",
"namespace"... | Given a datastore reference and a kind, will return a function that will return all stored entities.
@param {Object} datastore A reference to the datastore Object
@param {String} kind The entity kind
@returns {Function} The all function | [
"Given",
"a",
"datastore",
"reference",
"and",
"a",
"kind",
"will",
"return",
"a",
"function",
"that",
"will",
"return",
"all",
"stored",
"entities",
"."
] | e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3 | https://github.com/fabito/botkit-storage-datastore/blob/e2becb4135bdf599fe01e4d4cf09cc0b7026ecb3/src/index.js#L119-L140 | train |
aotaduy/eslint-plugin-spellcheck | rules/spell-checker.js | hasToSkipWord | function hasToSkipWord(word) {
if(word.length < options.minLength) return false;
if(lodash.find(options.skipWordIfMatch, function (aPattern) {
return word.match(aPattern);
})){
return false;
}
return true;
} | javascript | function hasToSkipWord(word) {
if(word.length < options.minLength) return false;
if(lodash.find(options.skipWordIfMatch, function (aPattern) {
return word.match(aPattern);
})){
return false;
}
return true;
} | [
"function",
"hasToSkipWord",
"(",
"word",
")",
"{",
"if",
"(",
"word",
".",
"length",
"<",
"options",
".",
"minLength",
")",
"return",
"false",
";",
"if",
"(",
"lodash",
".",
"find",
"(",
"options",
".",
"skipWordIfMatch",
",",
"function",
"(",
"aPattern... | returns false if the word has to be skipped
@param {string} word
@return {Boolean} false if skip; true if not | [
"returns",
"false",
"if",
"the",
"word",
"has",
"to",
"be",
"skipped"
] | 66882d0d1424b76c63e57c6ff6aad24b54ede7fc | https://github.com/aotaduy/eslint-plugin-spellcheck/blob/66882d0d1424b76c63e57c6ff6aad24b54ede7fc/rules/spell-checker.js#L214-L222 | train |
tarunc/gulp-jsbeautifier | index.js | mergeOptions | function mergeOptions(pluginOptions) {
const defaultOptions = {
config: null,
debug: false,
css: {
file_types: ['.css', '.less', '.sass', '.scss'],
},
html: {
file_types: ['.html'],
},
js: {
file_types: ['.js', '.json'],
},
};
// Load 'file options'
const explo... | javascript | function mergeOptions(pluginOptions) {
const defaultOptions = {
config: null,
debug: false,
css: {
file_types: ['.css', '.less', '.sass', '.scss'],
},
html: {
file_types: ['.html'],
},
js: {
file_types: ['.js', '.json'],
},
};
// Load 'file options'
const explo... | [
"function",
"mergeOptions",
"(",
"pluginOptions",
")",
"{",
"const",
"defaultOptions",
"=",
"{",
"config",
":",
"null",
",",
"debug",
":",
"false",
",",
"css",
":",
"{",
"file_types",
":",
"[",
"'.css'",
",",
"'.less'",
",",
"'.sass'",
",",
"'.scss'",
"]... | Merge options from different sources
@param {Object} pluginOptions The gulp-jsbeautifier options
@return {Object} The options | [
"Merge",
"options",
"from",
"different",
"sources"
] | 9e537eb625d4a9103851f3a2ecdc212280c9012b | https://github.com/tarunc/gulp-jsbeautifier/blob/9e537eb625d4a9103851f3a2ecdc212280c9012b/index.js#L17-L70 | train |
tarunc/gulp-jsbeautifier | index.js | helper | function helper(pluginOptions, doValidation) {
const options = mergeOptions(pluginOptions);
return through.obj((file, encoding, callback) => {
let oldContent;
let newContent;
let type = null;
if (file.isNull()) {
callback(null, file);
return;
}
if (file.isStream()) {
cal... | javascript | function helper(pluginOptions, doValidation) {
const options = mergeOptions(pluginOptions);
return through.obj((file, encoding, callback) => {
let oldContent;
let newContent;
let type = null;
if (file.isNull()) {
callback(null, file);
return;
}
if (file.isStream()) {
cal... | [
"function",
"helper",
"(",
"pluginOptions",
",",
"doValidation",
")",
"{",
"const",
"options",
"=",
"mergeOptions",
"(",
"pluginOptions",
")",
";",
"return",
"through",
".",
"obj",
"(",
"(",
"file",
",",
"encoding",
",",
"callback",
")",
"=>",
"{",
"let",
... | Beautify files or perform validation
@param {Object} pluginOptions The gulp-jsbeautifier parameter options
@param {boolean} doValidation Specifies whether perform validation only
@return {Object} The object stream | [
"Beautify",
"files",
"or",
"perform",
"validation"
] | 9e537eb625d4a9103851f3a2ecdc212280c9012b | https://github.com/tarunc/gulp-jsbeautifier/blob/9e537eb625d4a9103851f3a2ecdc212280c9012b/index.js#L78-L129 | train |
Zenika/immutadot | packages/immutadot/src/core/flow.js | flow | function flow(...args) {
const fns = flatten(args)
.filter(fn => isFunction(fn))
.map(fn => fn.applier === undefined ? (
([obj, appliedPaths]) => [fn(obj), appliedPaths]
) : (
([obj, appliedPaths]) => [
fn.applier(obj, appliedPaths),
[...appliedPaths, fn.applier.path],
]
... | javascript | function flow(...args) {
const fns = flatten(args)
.filter(fn => isFunction(fn))
.map(fn => fn.applier === undefined ? (
([obj, appliedPaths]) => [fn(obj), appliedPaths]
) : (
([obj, appliedPaths]) => [
fn.applier(obj, appliedPaths),
[...appliedPaths, fn.applier.path],
]
... | [
"function",
"flow",
"(",
"...",
"args",
")",
"{",
"const",
"fns",
"=",
"flatten",
"(",
"args",
")",
".",
"filter",
"(",
"fn",
"=>",
"isFunction",
"(",
"fn",
")",
")",
".",
"map",
"(",
"fn",
"=>",
"fn",
".",
"applier",
"===",
"undefined",
"?",
"("... | A function successively calling a list of functions.
@callback flowFunction
@memberof core
@param {*} arg The starting value
@returns {*} The resulting value
@since 1.0.0
Creates a function that will successively call all functions contained in <code>args</code>.<br/>
Each function is called with the result of the pr... | [
"A",
"function",
"successively",
"calling",
"a",
"list",
"of",
"functions",
"."
] | d6eaf9f8da4a7c0abdc71f1b01ec340130d7a970 | https://github.com/Zenika/immutadot/blob/d6eaf9f8da4a7c0abdc71f1b01ec340130d7a970/packages/immutadot/src/core/flow.js#L22-L40 | train |
ueno-llc/styleguide | packages/eslint-plugin-internal/decorator-line-break.js | checkDecorator | function checkDecorator(decorator, value, node) {
const decoratorLine = decorator.loc.start.line;
const decoratorColumn = decorator.loc.end.column;
const valueLine = value.loc.start.line;
if (config === 'always') {
if (decoratorLine === valueLine) {
context.report({
... | javascript | function checkDecorator(decorator, value, node) {
const decoratorLine = decorator.loc.start.line;
const decoratorColumn = decorator.loc.end.column;
const valueLine = value.loc.start.line;
if (config === 'always') {
if (decoratorLine === valueLine) {
context.report({
... | [
"function",
"checkDecorator",
"(",
"decorator",
",",
"value",
",",
"node",
")",
"{",
"const",
"decoratorLine",
"=",
"decorator",
".",
"loc",
".",
"start",
".",
"line",
";",
"const",
"decoratorColumn",
"=",
"decorator",
".",
"loc",
".",
"end",
".",
"column"... | Checks the given decorator node to check if a line break is needed.
@param {ASTNode} The decorator statement.
@param {ASTNode} The value statement.
@param {ASTNode} node The AST node of a BlockStatement.
@returns {void} undefined. | [
"Checks",
"the",
"given",
"decorator",
"node",
"to",
"check",
"if",
"a",
"line",
"break",
"is",
"needed",
"."
] | 708ce6d728b9189b2bcd71fb8b267c9b9eb33246 | https://github.com/ueno-llc/styleguide/blob/708ce6d728b9189b2bcd71fb8b267c9b9eb33246/packages/eslint-plugin-internal/decorator-line-break.js#L42-L64 | train |
ueno-llc/styleguide | packages/eslint-plugin-internal/padded-blocks.js | getFirstBlockToken | function getFirstBlockToken(token) {
let prev;
let first = token;
do {
prev = first;
first = sourceCode.getTokenAfter(first, { includeComments: true });
} while (isComment(first) && first.loc.start.line === prev.loc.end.line);
return first;
} | javascript | function getFirstBlockToken(token) {
let prev;
let first = token;
do {
prev = first;
first = sourceCode.getTokenAfter(first, { includeComments: true });
} while (isComment(first) && first.loc.start.line === prev.loc.end.line);
return first;
} | [
"function",
"getFirstBlockToken",
"(",
"token",
")",
"{",
"let",
"prev",
";",
"let",
"first",
"=",
"token",
";",
"do",
"{",
"prev",
"=",
"first",
";",
"first",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"first",
",",
"{",
"includeComments",
":",
"true... | Checks if the given token has a blank line after it.
@param {Token} token The token to check.
@returns {boolean} Whether or not the token is followed by a blank line. | [
"Checks",
"if",
"the",
"given",
"token",
"has",
"a",
"blank",
"line",
"after",
"it",
"."
] | 708ce6d728b9189b2bcd71fb8b267c9b9eb33246 | https://github.com/ueno-llc/styleguide/blob/708ce6d728b9189b2bcd71fb8b267c9b9eb33246/packages/eslint-plugin-internal/padded-blocks.js#L115-L125 | train |
ueno-llc/styleguide | packages/eslint-plugin-internal/padded-blocks.js | getLastBlockToken | function getLastBlockToken(token) {
let last = token;
let next;
do {
next = last;
last = sourceCode.getTokenBefore(last, { includeComments: true });
} while (isComment(last) && last.loc.end.line === next.loc.start.line);
return last;
} | javascript | function getLastBlockToken(token) {
let last = token;
let next;
do {
next = last;
last = sourceCode.getTokenBefore(last, { includeComments: true });
} while (isComment(last) && last.loc.end.line === next.loc.start.line);
return last;
} | [
"function",
"getLastBlockToken",
"(",
"token",
")",
"{",
"let",
"last",
"=",
"token",
";",
"let",
"next",
";",
"do",
"{",
"next",
"=",
"last",
";",
"last",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"last",
",",
"{",
"includeComments",
":",
"true",
... | Checks if the given token is preceeded by a blank line.
@param {Token} token The token to check
@returns {boolean} Whether or not the token is preceeded by a blank line | [
"Checks",
"if",
"the",
"given",
"token",
"is",
"preceeded",
"by",
"a",
"blank",
"line",
"."
] | 708ce6d728b9189b2bcd71fb8b267c9b9eb33246 | https://github.com/ueno-llc/styleguide/blob/708ce6d728b9189b2bcd71fb8b267c9b9eb33246/packages/eslint-plugin-internal/padded-blocks.js#L132-L142 | train |
ueno-llc/styleguide | packages/eslint-plugin-internal/padded-blocks.js | requirePaddingFor | function requirePaddingFor(node) {
switch (node.type) {
case 'BlockStatement':
return options.blocks;
case 'SwitchStatement':
return options.switches;
case 'ClassBody':
return options.classes;
/* istanbul ignore next */
default:
th... | javascript | function requirePaddingFor(node) {
switch (node.type) {
case 'BlockStatement':
return options.blocks;
case 'SwitchStatement':
return options.switches;
case 'ClassBody':
return options.classes;
/* istanbul ignore next */
default:
th... | [
"function",
"requirePaddingFor",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'BlockStatement'",
":",
"return",
"options",
".",
"blocks",
";",
"case",
"'SwitchStatement'",
":",
"return",
"options",
".",
"switches",
";",
"case... | Checks if a node should be padded, according to the rule config.
@param {ASTNode} node The AST node to check.
@returns {boolean} True if the node should be padded, false otherwise. | [
"Checks",
"if",
"a",
"node",
"should",
"be",
"padded",
"according",
"to",
"the",
"rule",
"config",
"."
] | 708ce6d728b9189b2bcd71fb8b267c9b9eb33246 | https://github.com/ueno-llc/styleguide/blob/708ce6d728b9189b2bcd71fb8b267c9b9eb33246/packages/eslint-plugin-internal/padded-blocks.js#L149-L164 | train |
ueno-llc/styleguide | packages/eslint-plugin-internal/padded-blocks.js | checkPadding | function checkPadding(node, type) {
const openBrace = getOpenBrace(node);
const firstBlockToken = getFirstBlockToken(openBrace);
const tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true });
const closeBrace = sourceCode.getLastToken(node);
const lastBlock... | javascript | function checkPadding(node, type) {
const openBrace = getOpenBrace(node);
const firstBlockToken = getFirstBlockToken(openBrace);
const tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true });
const closeBrace = sourceCode.getLastToken(node);
const lastBlock... | [
"function",
"checkPadding",
"(",
"node",
",",
"type",
")",
"{",
"const",
"openBrace",
"=",
"getOpenBrace",
"(",
"node",
")",
";",
"const",
"firstBlockToken",
"=",
"getFirstBlockToken",
"(",
"openBrace",
")",
";",
"const",
"tokenBeforeFirst",
"=",
"sourceCode",
... | Checks the given BlockStatement node to be padded if the block is not empty.
@param {ASTNode} node The AST node of a BlockStatement.
@returns {void} undefined. | [
"Checks",
"the",
"given",
"BlockStatement",
"node",
"to",
"be",
"padded",
"if",
"the",
"block",
"is",
"not",
"empty",
"."
] | 708ce6d728b9189b2bcd71fb8b267c9b9eb33246 | https://github.com/ueno-llc/styleguide/blob/708ce6d728b9189b2bcd71fb8b267c9b9eb33246/packages/eslint-plugin-internal/padded-blocks.js#L171-L228 | train |
zenozeng/p5.js-svg | src/p5.RendererSVG.js | function(element) {
if (element === elt) {
var wrapper = svgCanvas.getElement();
wrapper.parentNode.removeChild(wrapper);
}
} | javascript | function(element) {
if (element === elt) {
var wrapper = svgCanvas.getElement();
wrapper.parentNode.removeChild(wrapper);
}
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
"===",
"elt",
")",
"{",
"var",
"wrapper",
"=",
"svgCanvas",
".",
"getElement",
"(",
")",
";",
"wrapper",
".",
"parentNode",
".",
"removeChild",
"(",
"wrapper",
")",
";",
"}",
"}"
] | fake parentNode.removeChild so that noCanvas will work | [
"fake",
"parentNode",
".",
"removeChild",
"so",
"that",
"noCanvas",
"will",
"work"
] | 67edbdbf1a19d4925afe8f30f724e1a0bc4e93bf | https://github.com/zenozeng/p5.js-svg/blob/67edbdbf1a19d4925afe8f30f724e1a0bc4e93bf/src/p5.RendererSVG.js#L26-L31 | train | |
IonicaBizau/node-cli-graph | lib/index.js | CliGraph | function CliGraph(options) {
// Initialize variables
var self = this
, settings = self.options = Ul.deepMerge(options, CliGraph.defaults)
, i = 0
, character = null
, str = ""
;
self.graph = [];
settings.width *= settings.aRatio;
// Set the center of the graph
se... | javascript | function CliGraph(options) {
// Initialize variables
var self = this
, settings = self.options = Ul.deepMerge(options, CliGraph.defaults)
, i = 0
, character = null
, str = ""
;
self.graph = [];
settings.width *= settings.aRatio;
// Set the center of the graph
se... | [
"function",
"CliGraph",
"(",
"options",
")",
"{",
"// Initialize variables",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"options",
"=",
"Ul",
".",
"deepMerge",
"(",
"options",
",",
"CliGraph",
".",
"defaults",
")",
",",
"i",
"=",
"0",... | CliGraph
Creates a new CliGraph instance.
Example:
```js
var g = new CliGraph();
```
@name CliGraph
@function
@param {Object} options An object containing the following fields:
- `height` (Number): The graph height (default: `40`).
- `width` (Number): The graph width (default: `60`).
- `aRatio` (Number): The horizo... | [
"CliGraph",
"Creates",
"a",
"new",
"CliGraph",
"instance",
"."
] | f0b4ac85be0cdd9063834c3eaad39eef78288e2d | https://github.com/IonicaBizau/node-cli-graph/blob/f0b4ac85be0cdd9063834c3eaad39eef78288e2d/lib/index.js#L35-L89 | train |
InCar/ali-mns | index.js | Subscription | function Subscription(name, topic) {
this._pattern = "%s://%s.mns.%s.aliyuncs.com/topics/%s/subscriptions/%s";
this._name = name;
this._topic = topic;
// make url
this._urlAttr = this.makeAttrURL();
// create the OpenStack object
this._... | javascript | function Subscription(name, topic) {
this._pattern = "%s://%s.mns.%s.aliyuncs.com/topics/%s/subscriptions/%s";
this._name = name;
this._topic = topic;
// make url
this._urlAttr = this.makeAttrURL();
// create the OpenStack object
this._... | [
"function",
"Subscription",
"(",
"name",
",",
"topic",
")",
"{",
"this",
".",
"_pattern",
"=",
"\"%s://%s.mns.%s.aliyuncs.com/topics/%s/subscriptions/%s\"",
";",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_topic",
"=",
"topic",
";",
"// make url",
"th... | The constructor. name & topic is required. | [
"The",
"constructor",
".",
"name",
"&",
"topic",
"is",
"required",
"."
] | 4a2834281f2b4d862bcbfc0b55a050a19cf57c4b | https://github.com/InCar/ali-mns/blob/4a2834281f2b4d862bcbfc0b55a050a19cf57c4b/index.js#L1180-L1188 | train |
mvhenderson/pandoc-filter-node | index.js | filter | function filter(data, action, format) {
return walk(data, action, format, data.meta || data[0].unMeta);
} | javascript | function filter(data, action, format) {
return walk(data, action, format, data.meta || data[0].unMeta);
} | [
"function",
"filter",
"(",
"data",
",",
"action",
",",
"format",
")",
"{",
"return",
"walk",
"(",
"data",
",",
"action",
",",
"format",
",",
"data",
".",
"meta",
"||",
"data",
"[",
"0",
"]",
".",
"unMeta",
")",
";",
"}"
] | Filter the given object | [
"Filter",
"the",
"given",
"object"
] | d37259e8b0af8f73764ac2ca00007a9447ffe0dd | https://github.com/mvhenderson/pandoc-filter-node/blob/d37259e8b0af8f73764ac2ca00007a9447ffe0dd/index.js#L35-L37 | train |
mvhenderson/pandoc-filter-node | index.js | walk | function walk(x, action, format, meta) {
if (Array.isArray(x)) {
var array = [];
x.forEach(function (item) {
if (item === Object(item) && item.t) {
var res = action(item.t, item.c || [], format, meta)
if (!res) {
array.push(walk(item, action, format, meta));
}
e... | javascript | function walk(x, action, format, meta) {
if (Array.isArray(x)) {
var array = [];
x.forEach(function (item) {
if (item === Object(item) && item.t) {
var res = action(item.t, item.c || [], format, meta)
if (!res) {
array.push(walk(item, action, format, meta));
}
e... | [
"function",
"walk",
"(",
"x",
",",
"action",
",",
"format",
",",
"meta",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"x",
")",
")",
"{",
"var",
"array",
"=",
"[",
"]",
";",
"x",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"... | Walk a tree, applying an action to every object.
@param {Object} x The object to traverse
@param {Function} action Callback to apply to each item
@param {String} format Output format
@param {Object} meta Pandoc metadata
@return {Object} The modified tree | [
"Walk",
"a",
"tree",
"applying",
"an",
"action",
"to",
"every",
"object",
"."
] | d37259e8b0af8f73764ac2ca00007a9447ffe0dd | https://github.com/mvhenderson/pandoc-filter-node/blob/d37259e8b0af8f73764ac2ca00007a9447ffe0dd/index.js#L47-L79 | train |
mvhenderson/pandoc-filter-node | index.js | stringify | function stringify(x) {
if (x === Object(x) && x.t === 'MetaString') return x.c;
var result = [];
var go = function (key, val) {
if (key === 'Str') result.push(val);
else if (key === 'Code') result.push(val[1]);
else if (key === 'Math') result.push(val[1]);
else if (key === 'LineBreak') result.pus... | javascript | function stringify(x) {
if (x === Object(x) && x.t === 'MetaString') return x.c;
var result = [];
var go = function (key, val) {
if (key === 'Str') result.push(val);
else if (key === 'Code') result.push(val[1]);
else if (key === 'Math') result.push(val[1]);
else if (key === 'LineBreak') result.pus... | [
"function",
"stringify",
"(",
"x",
")",
"{",
"if",
"(",
"x",
"===",
"Object",
"(",
"x",
")",
"&&",
"x",
".",
"t",
"===",
"'MetaString'",
")",
"return",
"x",
".",
"c",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"go",
"=",
"function",
"(",
... | Walks the tree x and returns concatenated string content, leaving out all
formatting.
@param {Object} x The object to walk
@return {String} JSON string | [
"Walks",
"the",
"tree",
"x",
"and",
"returns",
"concatenated",
"string",
"content",
"leaving",
"out",
"all",
"formatting",
"."
] | d37259e8b0af8f73764ac2ca00007a9447ffe0dd | https://github.com/mvhenderson/pandoc-filter-node/blob/d37259e8b0af8f73764ac2ca00007a9447ffe0dd/index.js#L87-L100 | train |
mvhenderson/pandoc-filter-node | index.js | attributes | function attributes(attrs) {
attrs = attrs || {};
var ident = attrs.id || '';
var classes = attrs.classes || [];
var keyvals = [];
Object.keys(attrs).forEach(function (k) {
if (k !== 'classes' && k !== 'id') keyvals.push([k,attrs[k]]);
});
return [ident, classes, keyvals];
} | javascript | function attributes(attrs) {
attrs = attrs || {};
var ident = attrs.id || '';
var classes = attrs.classes || [];
var keyvals = [];
Object.keys(attrs).forEach(function (k) {
if (k !== 'classes' && k !== 'id') keyvals.push([k,attrs[k]]);
});
return [ident, classes, keyvals];
} | [
"function",
"attributes",
"(",
"attrs",
")",
"{",
"attrs",
"=",
"attrs",
"||",
"{",
"}",
";",
"var",
"ident",
"=",
"attrs",
".",
"id",
"||",
"''",
";",
"var",
"classes",
"=",
"attrs",
".",
"classes",
"||",
"[",
"]",
";",
"var",
"keyvals",
"=",
"[... | Returns an attribute list, constructed from the dictionary attrs.
@param {Object} attrs Attribute dictionary
@return {Array} Attribute list | [
"Returns",
"an",
"attribute",
"list",
"constructed",
"from",
"the",
"dictionary",
"attrs",
"."
] | d37259e8b0af8f73764ac2ca00007a9447ffe0dd | https://github.com/mvhenderson/pandoc-filter-node/blob/d37259e8b0af8f73764ac2ca00007a9447ffe0dd/index.js#L107-L116 | train |
mvhenderson/pandoc-filter-node | index.js | elt | function elt(eltType, numargs) {
return function () {
var args = Array.prototype.slice.call(arguments);
var len = args.length;
if (len !== numargs)
throw eltType + ' expects ' + numargs + ' arguments, but given ' + len;
return {'t':eltType,'c':(len === 1 ? args[0] : args)};
};
} | javascript | function elt(eltType, numargs) {
return function () {
var args = Array.prototype.slice.call(arguments);
var len = args.length;
if (len !== numargs)
throw eltType + ' expects ' + numargs + ' arguments, but given ' + len;
return {'t':eltType,'c':(len === 1 ? args[0] : args)};
};
} | [
"function",
"elt",
"(",
"eltType",
",",
"numargs",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"len",
"=",
"args",
".",
"length",
";",
"... | Utility for creating constructor functions | [
"Utility",
"for",
"creating",
"constructor",
"functions"
] | d37259e8b0af8f73764ac2ca00007a9447ffe0dd | https://github.com/mvhenderson/pandoc-filter-node/blob/d37259e8b0af8f73764ac2ca00007a9447ffe0dd/index.js#L119-L127 | train |
gratifyguy/botkit-mock | lib/SlackBotWorker/api.js | postForm | function postForm(url, formData, cb, multipart) {
cb = cb || noop;
botkit.debug('** API CALL: ' + url);
if (Array.isArray(api.logByKey[url])) {
api.logByKey[url].push(formData);
} else {
api.logByKey[url] = [formData];
}
storage.process(url, formData, cb);
} | javascript | function postForm(url, formData, cb, multipart) {
cb = cb || noop;
botkit.debug('** API CALL: ' + url);
if (Array.isArray(api.logByKey[url])) {
api.logByKey[url].push(formData);
} else {
api.logByKey[url] = [formData];
}
storage.process(url, formData, cb);
} | [
"function",
"postForm",
"(",
"url",
",",
"formData",
",",
"cb",
",",
"multipart",
")",
"{",
"cb",
"=",
"cb",
"||",
"noop",
";",
"botkit",
".",
"debug",
"(",
"'** API CALL: '",
"+",
"url",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"api",
".... | Makes a POST request as a form to the given url with the options as data
@param {string} url The URL to POST to
@param {Object} formData The data to POST as a form
@param {function=} cb An optional NodeJS style callback when the POST completes or errors out. | [
"Makes",
"a",
"POST",
"request",
"as",
"a",
"form",
"to",
"the",
"given",
"url",
"with",
"the",
"options",
"as",
"data"
] | 9b862b5bd4f8742432b8e47384351bd9ea3a9ed2 | https://github.com/gratifyguy/botkit-mock/blob/9b862b5bd4f8742432b8e47384351bd9ea3a9ed2/lib/SlackBotWorker/api.js#L229-L241 | train |
gratifyguy/botkit-mock | examples/botkit-starter-slack/skills/sample_taskbot.js | generateTaskList | function generateTaskList (user) {
var text = '';
for (var t = 0; t < user.tasks.length; t++) {
text = text + '> `' + (t + 1) + '`) ' + user.tasks[t] + '\n';
}
return text;
} | javascript | function generateTaskList (user) {
var text = '';
for (var t = 0; t < user.tasks.length; t++) {
text = text + '> `' + (t + 1) + '`) ' + user.tasks[t] + '\n';
}
return text;
} | [
"function",
"generateTaskList",
"(",
"user",
")",
"{",
"var",
"text",
"=",
"''",
";",
"for",
"(",
"var",
"t",
"=",
"0",
";",
"t",
"<",
"user",
".",
"tasks",
".",
"length",
";",
"t",
"++",
")",
"{",
"text",
"=",
"text",
"+",
"'> `'",
"+",
"(",
... | simple function to generate the text of the task list so that it can be used in various places | [
"simple",
"function",
"to",
"generate",
"the",
"text",
"of",
"the",
"task",
"list",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"various",
"places"
] | 9b862b5bd4f8742432b8e47384351bd9ea3a9ed2 | https://github.com/gratifyguy/botkit-mock/blob/9b862b5bd4f8742432b8e47384351bd9ea3a9ed2/examples/botkit-starter-slack/skills/sample_taskbot.js#L122-L132 | train |
josephfrazier/prettier_d | src/common/util.js | skipNewline | function skipNewline(text, index, opts) {
const backwards = opts && opts.backwards;
if (index === false) {
return false;
}
const atIndex = text.charAt(index);
if (backwards) {
if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
return index - 2;
}
if (
atIndex === "\n" ||
... | javascript | function skipNewline(text, index, opts) {
const backwards = opts && opts.backwards;
if (index === false) {
return false;
}
const atIndex = text.charAt(index);
if (backwards) {
if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
return index - 2;
}
if (
atIndex === "\n" ||
... | [
"function",
"skipNewline",
"(",
"text",
",",
"index",
",",
"opts",
")",
"{",
"const",
"backwards",
"=",
"opts",
"&&",
"opts",
".",
"backwards",
";",
"if",
"(",
"index",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"const",
"atIndex",
"=",
"... | This one doesn't use the above helper function because it wants to test \r\n in order and `skip` doesn't support ordering and we only want to skip one newline. It's simple to implement. | [
"This",
"one",
"doesn",
"t",
"use",
"the",
"above",
"helper",
"function",
"because",
"it",
"wants",
"to",
"test",
"\\",
"r",
"\\",
"n",
"in",
"order",
"and",
"skip",
"doesn",
"t",
"support",
"ordering",
"and",
"we",
"only",
"want",
"to",
"skip",
"one",... | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/common/util.js#L111-L145 | train |
josephfrazier/prettier_d | src/main/options.js | normalize | function normalize(options, opts) {
opts = opts || {};
const rawOptions = Object.assign({}, options);
const supportOptions = getSupportInfo(null, {
plugins: options.plugins,
showUnreleased: true,
showDeprecated: true
}).options;
const defaults = supportOptions.reduce(
(reduced, optionInfo) =... | javascript | function normalize(options, opts) {
opts = opts || {};
const rawOptions = Object.assign({}, options);
const supportOptions = getSupportInfo(null, {
plugins: options.plugins,
showUnreleased: true,
showDeprecated: true
}).options;
const defaults = supportOptions.reduce(
(reduced, optionInfo) =... | [
"function",
"normalize",
"(",
"options",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"const",
"rawOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"const",
"supportOptions",
"=",
"getSupportInfo",
"(... | Copy options and fill in default values. | [
"Copy",
"options",
"and",
"fill",
"in",
"default",
"values",
"."
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/main/options.js#L20-L101 | train |
josephfrazier/prettier_d | src/language-js/printer-estree.js | hasNgSideEffect | function hasNgSideEffect(path) {
return hasNode(path.getValue(), node => {
switch (node.type) {
case undefined:
return false;
case "CallExpression":
case "OptionalCallExpression":
case "AssignmentExpression":
return true;
}
});
} | javascript | function hasNgSideEffect(path) {
return hasNode(path.getValue(), node => {
switch (node.type) {
case undefined:
return false;
case "CallExpression":
case "OptionalCallExpression":
case "AssignmentExpression":
return true;
}
});
} | [
"function",
"hasNgSideEffect",
"(",
"path",
")",
"{",
"return",
"hasNode",
"(",
"path",
".",
"getValue",
"(",
")",
",",
"node",
"=>",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"undefined",
":",
"return",
"false",
";",
"case",
"\"CallEx... | identify if an angular expression seems to have side effects | [
"identify",
"if",
"an",
"angular",
"expression",
"seems",
"to",
"have",
"side",
"effects"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/printer-estree.js#L3603-L3614 | train |
josephfrazier/prettier_d | src/language-js/printer-estree.js | isMeaningfulJSXText | function isMeaningfulJSXText(node) {
return (
isLiteral(node) &&
(containsNonJsxWhitespaceRegex.test(rawText(node)) ||
!/\n/.test(rawText(node)))
);
} | javascript | function isMeaningfulJSXText(node) {
return (
isLiteral(node) &&
(containsNonJsxWhitespaceRegex.test(rawText(node)) ||
!/\n/.test(rawText(node)))
);
} | [
"function",
"isMeaningfulJSXText",
"(",
"node",
")",
"{",
"return",
"(",
"isLiteral",
"(",
"node",
")",
"&&",
"(",
"containsNonJsxWhitespaceRegex",
".",
"test",
"(",
"rawText",
"(",
"node",
")",
")",
"||",
"!",
"/",
"\\n",
"/",
".",
"test",
"(",
"rawText... | Meaningful if it contains non-whitespace characters, or it contains whitespace without a new line. | [
"Meaningful",
"if",
"it",
"contains",
"non",
"-",
"whitespace",
"characters",
"or",
"it",
"contains",
"whitespace",
"without",
"a",
"new",
"line",
"."
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/printer-estree.js#L5059-L5065 | train |
josephfrazier/prettier_d | src/language-markdown/utils.js | splitText | function splitText(text, options) {
const KIND_NON_CJK = "non-cjk";
const KIND_CJ_LETTER = "cj-letter";
const KIND_K_LETTER = "k-letter";
const KIND_CJK_PUNCTUATION = "cjk-punctuation";
const nodes = [];
(options.proseWrap === "preserve"
? text
: text.replace(new RegExp(`(${cjkPattern})\n(${cjkPat... | javascript | function splitText(text, options) {
const KIND_NON_CJK = "non-cjk";
const KIND_CJ_LETTER = "cj-letter";
const KIND_K_LETTER = "k-letter";
const KIND_CJK_PUNCTUATION = "cjk-punctuation";
const nodes = [];
(options.proseWrap === "preserve"
? text
: text.replace(new RegExp(`(${cjkPattern})\n(${cjkPat... | [
"function",
"splitText",
"(",
"text",
",",
"options",
")",
"{",
"const",
"KIND_NON_CJK",
"=",
"\"non-cjk\"",
";",
"const",
"KIND_CJ_LETTER",
"=",
"\"cj-letter\"",
";",
"const",
"KIND_K_LETTER",
"=",
"\"k-letter\"",
";",
"const",
"KIND_CJK_PUNCTUATION",
"=",
"\"cjk... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | [
"split",
"text",
"into",
"whitespaces",
"and",
"words"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-markdown/utils.js#L43-L152 | train |
josephfrazier/prettier_d | src/language-html/preprocess.js | extractWhitespaces | function extractWhitespaces(ast /*, options*/) {
const TYPE_WHITESPACE = "whitespace";
return ast.map(node => {
if (!node.children) {
return node;
}
if (
node.children.length === 0 ||
(node.children.length === 1 &&
node.children[0].type === "text" &&
node.children[0].v... | javascript | function extractWhitespaces(ast /*, options*/) {
const TYPE_WHITESPACE = "whitespace";
return ast.map(node => {
if (!node.children) {
return node;
}
if (
node.children.length === 0 ||
(node.children.length === 1 &&
node.children[0].type === "text" &&
node.children[0].v... | [
"function",
"extractWhitespaces",
"(",
"ast",
"/*, options*/",
")",
"{",
"const",
"TYPE_WHITESPACE",
"=",
"\"whitespace\"",
";",
"return",
"ast",
".",
"map",
"(",
"node",
"=>",
"{",
"if",
"(",
"!",
"node",
".",
"children",
")",
"{",
"return",
"node",
";",
... | - add `hasLeadingSpaces` field
- add `hasTrailingSpaces` field
- add `hasDanglingSpaces` field for parent nodes
- add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
- remove insensitive whitespaces | [
"-",
"add",
"hasLeadingSpaces",
"field",
"-",
"add",
"hasTrailingSpaces",
"field",
"-",
"add",
"hasDanglingSpaces",
"field",
"for",
"parent",
"nodes",
"-",
"add",
"isWhitespaceSensitive",
"isIndentationSensitive",
"field",
"for",
"text",
"nodes",
"-",
"remove",
"ins... | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-html/preprocess.js#L308-L390 | train |
josephfrazier/prettier_d | src/language-html/preprocess.js | addIsSpaceSensitive | function addIsSpaceSensitive(ast /*, options */) {
return ast.map(node => {
if (!node.children) {
return node;
}
if (node.children.length === 0) {
return node.clone({
isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode(node)
});
}
return node.clone({
children: ... | javascript | function addIsSpaceSensitive(ast /*, options */) {
return ast.map(node => {
if (!node.children) {
return node;
}
if (node.children.length === 0) {
return node.clone({
isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode(node)
});
}
return node.clone({
children: ... | [
"function",
"addIsSpaceSensitive",
"(",
"ast",
"/*, options */",
")",
"{",
"return",
"ast",
".",
"map",
"(",
"node",
"=>",
"{",
"if",
"(",
"!",
"node",
".",
"children",
")",
"{",
"return",
"node",
";",
"}",
"if",
"(",
"node",
".",
"children",
".",
"l... | - add `isLeadingSpaceSensitive` field
- add `isTrailingSpaceSensitive` field
- add `isDanglingSpaceSensitive` field for parent nodes | [
"-",
"add",
"isLeadingSpaceSensitive",
"field",
"-",
"add",
"isTrailingSpaceSensitive",
"field",
"-",
"add",
"isDanglingSpaceSensitive",
"field",
"for",
"parent",
"nodes"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-html/preprocess.js#L433-L469 | train |
josephfrazier/prettier_d | src/language-html/utils.js | forceBreakContent | function forceBreakContent(node) {
return (
forceBreakChildren(node) ||
(node.type === "element" &&
node.children.length !== 0 &&
(["body", "template", "script", "style"].indexOf(node.name) !== -1 ||
node.children.some(child => hasNonTextChild(child)))) ||
(node.firstChild &&
nod... | javascript | function forceBreakContent(node) {
return (
forceBreakChildren(node) ||
(node.type === "element" &&
node.children.length !== 0 &&
(["body", "template", "script", "style"].indexOf(node.name) !== -1 ||
node.children.some(child => hasNonTextChild(child)))) ||
(node.firstChild &&
nod... | [
"function",
"forceBreakContent",
"(",
"node",
")",
"{",
"return",
"(",
"forceBreakChildren",
"(",
"node",
")",
"||",
"(",
"node",
".",
"type",
"===",
"\"element\"",
"&&",
"node",
".",
"children",
".",
"length",
"!==",
"0",
"&&",
"(",
"[",
"\"body\"",
","... | firstChild leadingSpaces and lastChild trailingSpaces | [
"firstChild",
"leadingSpaces",
"and",
"lastChild",
"trailingSpaces"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-html/utils.js#L270-L283 | train |
josephfrazier/prettier_d | src/language-html/utils.js | forceBreakChildren | function forceBreakChildren(node) {
return (
node.type === "element" &&
node.children.length !== 0 &&
(["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 ||
(node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell"))
);
} | javascript | function forceBreakChildren(node) {
return (
node.type === "element" &&
node.children.length !== 0 &&
(["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 ||
(node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell"))
);
} | [
"function",
"forceBreakChildren",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"element\"",
"&&",
"node",
".",
"children",
".",
"length",
"!==",
"0",
"&&",
"(",
"[",
"\"html\"",
",",
"\"head\"",
",",
"\"ul\"",
",",
"\"ol\"",
",",
... | spaces between children | [
"spaces",
"between",
"children"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-html/utils.js#L286-L293 | train |
josephfrazier/prettier_d | src/language-js/embed.js | replacePlaceholders | function replacePlaceholders(quasisDoc, expressionDocs) {
if (!expressionDocs || !expressionDocs.length) {
return quasisDoc;
}
const expressions = expressionDocs.slice();
let replaceCounter = 0;
const newDoc = mapDoc(quasisDoc, doc => {
if (!doc || !doc.parts || !doc.parts.length) {
return doc;... | javascript | function replacePlaceholders(quasisDoc, expressionDocs) {
if (!expressionDocs || !expressionDocs.length) {
return quasisDoc;
}
const expressions = expressionDocs.slice();
let replaceCounter = 0;
const newDoc = mapDoc(quasisDoc, doc => {
if (!doc || !doc.parts || !doc.parts.length) {
return doc;... | [
"function",
"replacePlaceholders",
"(",
"quasisDoc",
",",
"expressionDocs",
")",
"{",
"if",
"(",
"!",
"expressionDocs",
"||",
"!",
"expressionDocs",
".",
"length",
")",
"{",
"return",
"quasisDoc",
";",
"}",
"const",
"expressions",
"=",
"expressionDocs",
".",
"... | Search all the placeholders in the quasisDoc tree and replace them with the expression docs one by one returns a new doc with all the placeholders replaced, or null if it couldn't replace any expression | [
"Search",
"all",
"the",
"placeholders",
"in",
"the",
"quasisDoc",
"tree",
"and",
"replace",
"them",
"with",
"the",
"expression",
"docs",
"one",
"by",
"one",
"returns",
"a",
"new",
"doc",
"with",
"all",
"the",
"placeholders",
"replaced",
"or",
"null",
"if",
... | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/embed.js#L251-L307 | train |
josephfrazier/prettier_d | src/language-js/embed.js | isStyledComponents | function isStyledComponents(path) {
const parent = path.getParentNode();
if (!parent || parent.type !== "TaggedTemplateExpression") {
return false;
}
const tag = parent.tag;
switch (tag.type) {
case "MemberExpression":
return (
// styled.foo``
isStyledIdentifier(tag.object) ||... | javascript | function isStyledComponents(path) {
const parent = path.getParentNode();
if (!parent || parent.type !== "TaggedTemplateExpression") {
return false;
}
const tag = parent.tag;
switch (tag.type) {
case "MemberExpression":
return (
// styled.foo``
isStyledIdentifier(tag.object) ||... | [
"function",
"isStyledComponents",
"(",
"path",
")",
"{",
"const",
"parent",
"=",
"path",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"!",
"parent",
"||",
"parent",
".",
"type",
"!==",
"\"TaggedTemplateExpression\"",
")",
"{",
"return",
"false",
";",
"}... | styled-components template literals | [
"styled",
"-",
"components",
"template",
"literals"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/embed.js#L413-L453 | train |
josephfrazier/prettier_d | src/language-js/embed.js | isCssProp | function isCssProp(path) {
const parent = path.getParentNode();
const parentParent = path.getParentNode(1);
return (
parentParent &&
parent.type === "JSXExpressionContainer" &&
parentParent.type === "JSXAttribute" &&
parentParent.name.type === "JSXIdentifier" &&
parentParent.name.name === "css... | javascript | function isCssProp(path) {
const parent = path.getParentNode();
const parentParent = path.getParentNode(1);
return (
parentParent &&
parent.type === "JSXExpressionContainer" &&
parentParent.type === "JSXAttribute" &&
parentParent.name.type === "JSXIdentifier" &&
parentParent.name.name === "css... | [
"function",
"isCssProp",
"(",
"path",
")",
"{",
"const",
"parent",
"=",
"path",
".",
"getParentNode",
"(",
")",
";",
"const",
"parentParent",
"=",
"path",
".",
"getParentNode",
"(",
"1",
")",
";",
"return",
"(",
"parentParent",
"&&",
"parent",
".",
"type... | JSX element with CSS prop | [
"JSX",
"element",
"with",
"CSS",
"prop"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/embed.js#L458-L468 | train |
josephfrazier/prettier_d | src/language-js/embed.js | isHtml | function isHtml(path) {
const node = path.getValue();
return (
hasLanguageComment(node, "HTML") ||
isPathMatch(path, [
node => node.type === "TemplateLiteral",
(node, name) =>
node.type === "TaggedTemplateExpression" &&
node.tag.type === "Identifier" &&
node.tag.name === ... | javascript | function isHtml(path) {
const node = path.getValue();
return (
hasLanguageComment(node, "HTML") ||
isPathMatch(path, [
node => node.type === "TemplateLiteral",
(node, name) =>
node.type === "TaggedTemplateExpression" &&
node.tag.type === "Identifier" &&
node.tag.name === ... | [
"function",
"isHtml",
"(",
"path",
")",
"{",
"const",
"node",
"=",
"path",
".",
"getValue",
"(",
")",
";",
"return",
"(",
"hasLanguageComment",
"(",
"node",
",",
"\"HTML\"",
")",
"||",
"isPathMatch",
"(",
"path",
",",
"[",
"node",
"=>",
"node",
".",
... | - html`...`
- HTML comment block | [
"-",
"html",
"...",
"-",
"HTML",
"comment",
"block"
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/src/language-js/embed.js#L551-L564 | train |
josephfrazier/prettier_d | scripts/release/steps/post-publish-steps.js | checkSchema | async function checkSchema() {
const schema = await execa.stdout("node", ["scripts/generate-schema.js"]);
const remoteSchema = await logPromise(
"Checking current schema in SchemaStore",
fetch(RAW_URL)
.then(r => r.text())
.then(t => t.trim())
);
if (schema === remoteSchema) {
return;
... | javascript | async function checkSchema() {
const schema = await execa.stdout("node", ["scripts/generate-schema.js"]);
const remoteSchema = await logPromise(
"Checking current schema in SchemaStore",
fetch(RAW_URL)
.then(r => r.text())
.then(t => t.trim())
);
if (schema === remoteSchema) {
return;
... | [
"async",
"function",
"checkSchema",
"(",
")",
"{",
"const",
"schema",
"=",
"await",
"execa",
".",
"stdout",
"(",
"\"node\"",
",",
"[",
"\"scripts/generate-schema.js\"",
"]",
")",
";",
"const",
"remoteSchema",
"=",
"await",
"logPromise",
"(",
"\"Checking current ... | Any optional or manual step can be warned in this script. | [
"Any",
"optional",
"or",
"manual",
"step",
"can",
"be",
"warned",
"in",
"this",
"script",
"."
] | f45912afe811b53cc865b2e6c147218fd40f4ed9 | https://github.com/josephfrazier/prettier_d/blob/f45912afe811b53cc865b2e6c147218fd40f4ed9/scripts/release/steps/post-publish-steps.js#L16-L36 | train |
nodejitsu/haibu | lib/haibu/common/npm.js | installAll | function installAll(deps) {
npm.commands.install(dir, deps, function (err) {
if (err) {
return callback(err);
}
haibu.emit('npm:install:success', 'info', meta);
callback(null, deps);
});
} | javascript | function installAll(deps) {
npm.commands.install(dir, deps, function (err) {
if (err) {
return callback(err);
}
haibu.emit('npm:install:success', 'info', meta);
callback(null, deps);
});
} | [
"function",
"installAll",
"(",
"deps",
")",
"{",
"npm",
".",
"commands",
".",
"install",
"(",
"dir",
",",
"deps",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"haibu",
".",
"e... | Install all dependencies into the target directory | [
"Install",
"all",
"dependencies",
"into",
"the",
"target",
"directory"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/common/npm.js#L118-L127 | train |
nodejitsu/haibu | lib/haibu/common/npm.js | loadAndInstall | function loadAndInstall() {
meta = { packages: target };
exports.load(function (err) {
if (err) {
return callback(err);
}
installAll(target);
});
} | javascript | function loadAndInstall() {
meta = { packages: target };
exports.load(function (err) {
if (err) {
return callback(err);
}
installAll(target);
});
} | [
"function",
"loadAndInstall",
"(",
")",
"{",
"meta",
"=",
"{",
"packages",
":",
"target",
"}",
";",
"exports",
".",
"load",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"install... | Load npm and install the raw list of dependencies | [
"Load",
"npm",
"and",
"install",
"the",
"raw",
"list",
"of",
"dependencies"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/common/npm.js#L155-L164 | train |
nodejitsu/haibu | lib/haibu/drone/drone.js | onError | function onError(err) {
err.usage = 'tar -cvz . | curl -sSNT- HOST/deploy/USER/APP';
err.blame = {
type: 'system',
message: 'Unable to unpack tarball'
};
return callback(err);
} | javascript | function onError(err) {
err.usage = 'tar -cvz . | curl -sSNT- HOST/deploy/USER/APP';
err.blame = {
type: 'system',
message: 'Unable to unpack tarball'
};
return callback(err);
} | [
"function",
"onError",
"(",
"err",
")",
"{",
"err",
".",
"usage",
"=",
"'tar -cvz . | curl -sSNT- HOST/deploy/USER/APP'",
";",
"err",
".",
"blame",
"=",
"{",
"type",
":",
"'system'",
",",
"message",
":",
"'Unable to unpack tarball'",
"}",
";",
"return",
"callbac... | Handle error caused by `zlib.Gunzip` or `tar.Extract` failure | [
"Handle",
"error",
"caused",
"by",
"zlib",
".",
"Gunzip",
"or",
"tar",
".",
"Extract",
"failure"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/drone/drone.js#L85-L92 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onStdout | function onStdout (data) {
data = data.toString();
haibu.emit('drone:stdout', 'info', data, meta);
if (!responded) {
stdout = stdout.concat(data.split('\n').filter(function (line) { return line.length > 0 }));
}
} | javascript | function onStdout (data) {
data = data.toString();
haibu.emit('drone:stdout', 'info', data, meta);
if (!responded) {
stdout = stdout.concat(data.split('\n').filter(function (line) { return line.length > 0 }));
}
} | [
"function",
"onStdout",
"(",
"data",
")",
"{",
"data",
"=",
"data",
".",
"toString",
"(",
")",
";",
"haibu",
".",
"emit",
"(",
"'drone:stdout'",
",",
"'info'",
",",
"data",
",",
"meta",
")",
";",
"if",
"(",
"!",
"responded",
")",
"{",
"stdout",
"="... | Log data from `drone.stdout` to haibu | [
"Log",
"data",
"from",
"drone",
".",
"stdout",
"to",
"haibu"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L261-L268 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onStderr | function onStderr (data) {
data = data.toString();
haibu.emit('drone:stderr', 'error', data, meta);
if (!responded) {
stderr = stderr.concat(data.split('\n').filter(function (line) { return line.length > 0 }));
}
} | javascript | function onStderr (data) {
data = data.toString();
haibu.emit('drone:stderr', 'error', data, meta);
if (!responded) {
stderr = stderr.concat(data.split('\n').filter(function (line) { return line.length > 0 }));
}
} | [
"function",
"onStderr",
"(",
"data",
")",
"{",
"data",
"=",
"data",
".",
"toString",
"(",
")",
";",
"haibu",
".",
"emit",
"(",
"'drone:stderr'",
",",
"'error'",
",",
"data",
",",
"meta",
")",
";",
"if",
"(",
"!",
"responded",
")",
"{",
"stderr",
"=... | Log data from `drone.stderr` to haibu | [
"Log",
"data",
"from",
"drone",
".",
"stderr",
"to",
"haibu"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L273-L280 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onCarapacePort | function onCarapacePort (info) {
if (!responded && info && info.event === 'port') {
responded = true;
result.socket = {
host: self.host,
port: info.data.port
};
drone.minUptime = 0;
haibu.emit('drone:port', 'info', {
pkg: app,
... | javascript | function onCarapacePort (info) {
if (!responded && info && info.event === 'port') {
responded = true;
result.socket = {
host: self.host,
port: info.data.port
};
drone.minUptime = 0;
haibu.emit('drone:port', 'info', {
pkg: app,
... | [
"function",
"onCarapacePort",
"(",
"info",
")",
"{",
"if",
"(",
"!",
"responded",
"&&",
"info",
"&&",
"info",
".",
"event",
"===",
"'port'",
")",
"{",
"responded",
"=",
"true",
";",
"result",
".",
"socket",
"=",
"{",
"host",
":",
"self",
".",
"host",... | When the carapace provides the port that the drone has bound to then respond to the callback | [
"When",
"the",
"carapace",
"provides",
"the",
"port",
"that",
"the",
"drone",
"has",
"bound",
"to",
"then",
"respond",
"to",
"the",
"callback"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L307-L331 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onChildStart | function onChildStart (monitor, data) {
result = {
monitor: monitor,
process: monitor.child,
data: data,
pid: monitor.childData.pid,
pkg: app
};
haibu.emit(['drone', 'start'], 'info', {
process: data,
pkg: result.pkg
});
} | javascript | function onChildStart (monitor, data) {
result = {
monitor: monitor,
process: monitor.child,
data: data,
pid: monitor.childData.pid,
pkg: app
};
haibu.emit(['drone', 'start'], 'info', {
process: data,
pkg: result.pkg
});
} | [
"function",
"onChildStart",
"(",
"monitor",
",",
"data",
")",
"{",
"result",
"=",
"{",
"monitor",
":",
"monitor",
",",
"process",
":",
"monitor",
".",
"child",
",",
"data",
":",
"data",
",",
"pid",
":",
"monitor",
".",
"childData",
".",
"pid",
",",
"... | When the drone starts, update the result for monitoring software | [
"When",
"the",
"drone",
"starts",
"update",
"the",
"result",
"for",
"monitoring",
"software"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L336-L349 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onChildRestart | function onChildRestart (monitor, data) {
haibu.emit(['drone', 'stop'], 'info', {
process: result.data,
pkg: result.pkg
});
haibu.emit(['drone', 'start'], 'info', {
process: data,
pkg: result.pkg
});
} | javascript | function onChildRestart (monitor, data) {
haibu.emit(['drone', 'stop'], 'info', {
process: result.data,
pkg: result.pkg
});
haibu.emit(['drone', 'start'], 'info', {
process: data,
pkg: result.pkg
});
} | [
"function",
"onChildRestart",
"(",
"monitor",
",",
"data",
")",
"{",
"haibu",
".",
"emit",
"(",
"[",
"'drone'",
",",
"'stop'",
"]",
",",
"'info'",
",",
"{",
"process",
":",
"result",
".",
"data",
",",
"pkg",
":",
"result",
".",
"pkg",
"}",
")",
";"... | When the drone stops, update the result for monitoring software | [
"When",
"the",
"drone",
"stops",
"update",
"the",
"result",
"for",
"monitoring",
"software"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L354-L364 | train |
nodejitsu/haibu | lib/haibu/core/spawner.js | onExit | function onExit () {
if (!responded) {
errState = true;
responded = true;
error = new Error('Error spawning drone');
error.blame = {
type: 'user',
message: 'Script prematurely exited'
}
error.stdout = stdout.join('\n');
error.stderr = std... | javascript | function onExit () {
if (!responded) {
errState = true;
responded = true;
error = new Error('Error spawning drone');
error.blame = {
type: 'user',
message: 'Script prematurely exited'
}
error.stdout = stdout.join('\n');
error.stderr = std... | [
"function",
"onExit",
"(",
")",
"{",
"if",
"(",
"!",
"responded",
")",
"{",
"errState",
"=",
"true",
";",
"responded",
"=",
"true",
";",
"error",
"=",
"new",
"Error",
"(",
"'Error spawning drone'",
")",
";",
"error",
".",
"blame",
"=",
"{",
"type",
"... | If the drone exits prematurely then respond with an error containing the data we receieved from `stderr` | [
"If",
"the",
"drone",
"exits",
"prematurely",
"then",
"respond",
"with",
"an",
"error",
"containing",
"the",
"data",
"we",
"receieved",
"from",
"stderr"
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/core/spawner.js#L370-L390 | train |
nodejitsu/haibu | lib/haibu/drone/index.js | startDrones | function startDrones (pkg, done) {
if (pkg.drones == 0) {
return done();
}
var started = 0;
async.whilst(function () {
return started < pkg.drones;
}, function (next) {
started++;
server.drone.start(pkg, next);
}, done);
} | javascript | function startDrones (pkg, done) {
if (pkg.drones == 0) {
return done();
}
var started = 0;
async.whilst(function () {
return started < pkg.drones;
}, function (next) {
started++;
server.drone.start(pkg, next);
}, done);
} | [
"function",
"startDrones",
"(",
"pkg",
",",
"done",
")",
"{",
"if",
"(",
"pkg",
".",
"drones",
"==",
"0",
")",
"{",
"return",
"done",
"(",
")",
";",
"}",
"var",
"started",
"=",
"0",
";",
"async",
".",
"whilst",
"(",
"function",
"(",
")",
"{",
"... | Helper function which starts multiple drones a given application. | [
"Helper",
"function",
"which",
"starts",
"multiple",
"drones",
"a",
"given",
"application",
"."
] | 7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4 | https://github.com/nodejitsu/haibu/blob/7f59fbc852db2e2f3fed1bd7b3c4b2a461864cc4/lib/haibu/drone/index.js#L37-L50 | train |
3rd-Eden/diagnostics | adapters/asyncstorage.js | asyncstorage | async function asyncstorage(namespace) {
var debug, diagnostics;
try {
debug = await storage.getItem('debug');
diagnostics = await storage.getItem('diagnostics');
} catch (e) {
/* Nope, nothing. */
}
return enabled(namespace, debug || diagnostics || '');
} | javascript | async function asyncstorage(namespace) {
var debug, diagnostics;
try {
debug = await storage.getItem('debug');
diagnostics = await storage.getItem('diagnostics');
} catch (e) {
/* Nope, nothing. */
}
return enabled(namespace, debug || diagnostics || '');
} | [
"async",
"function",
"asyncstorage",
"(",
"namespace",
")",
"{",
"var",
"debug",
",",
"diagnostics",
";",
"try",
"{",
"debug",
"=",
"await",
"storage",
".",
"getItem",
"(",
"'debug'",
")",
";",
"diagnostics",
"=",
"await",
"storage",
".",
"getItem",
"(",
... | AsyncStorage Adapter for React-Native
@param {String} namespace The namespace we should trigger on.
@return {Boolean} Indication if the namespace is allowed to log.
@public | [
"AsyncStorage",
"Adapter",
"for",
"React",
"-",
"Native"
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/adapters/asyncstorage.js#L16-L27 | train |
3rd-Eden/diagnostics | diagnostics.js | use | function use(adapter) {
if (~adapters.indexOf(adapter)) return false;
adapters.push(adapter);
return true;
} | javascript | function use(adapter) {
if (~adapters.indexOf(adapter)) return false;
adapters.push(adapter);
return true;
} | [
"function",
"use",
"(",
"adapter",
")",
"{",
"if",
"(",
"~",
"adapters",
".",
"indexOf",
"(",
"adapter",
")",
")",
"return",
"false",
";",
"adapters",
".",
"push",
"(",
"adapter",
")",
";",
"return",
"true",
";",
"}"
] | Register a new adapter that will used to find environments.
@param {Function} adapter A function that will return the possible env.
@returns {Boolean} Indication of a successful add.
@public | [
"Register",
"a",
"new",
"adapter",
"that",
"will",
"used",
"to",
"find",
"environments",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L31-L36 | train |
3rd-Eden/diagnostics | diagnostics.js | enabled | function enabled(namespace) {
var async = [];
for (var i = 0; i < adapters.length; i++) {
if (adapters[i].async) {
async.push(adapters[i]);
continue;
}
if (adapters[i](namespace)) return true;
}
if (!async.length) return false;
//
// Now that we know that we Async functions, we k... | javascript | function enabled(namespace) {
var async = [];
for (var i = 0; i < adapters.length; i++) {
if (adapters[i].async) {
async.push(adapters[i]);
continue;
}
if (adapters[i](namespace)) return true;
}
if (!async.length) return false;
//
// Now that we know that we Async functions, we k... | [
"function",
"enabled",
"(",
"namespace",
")",
"{",
"var",
"async",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"adapters",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"adapters",
"[",
"i",
"]",
".",
"async",
"... | Check if the namespace is allowed by any of our adapters.
@param {String} namespace The namespace that needs to be enabled
@returns {Boolean|Promise} Indication if the namespace is enabled by our adapters.
@public | [
"Check",
"if",
"the",
"namespace",
"is",
"allowed",
"by",
"any",
"of",
"our",
"adapters",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L55-L84 | train |
3rd-Eden/diagnostics | diagnostics.js | modify | function modify(fn) {
if (~modifiers.indexOf(fn)) return false;
modifiers.push(fn);
return true;
} | javascript | function modify(fn) {
if (~modifiers.indexOf(fn)) return false;
modifiers.push(fn);
return true;
} | [
"function",
"modify",
"(",
"fn",
")",
"{",
"if",
"(",
"~",
"modifiers",
".",
"indexOf",
"(",
"fn",
")",
")",
"return",
"false",
";",
"modifiers",
".",
"push",
"(",
"fn",
")",
";",
"return",
"true",
";",
"}"
] | Add a new message modifier to the debugger.
@param {Function} fn Modification function.
@returns {Boolean} Indication of a successful add.
@public | [
"Add",
"a",
"new",
"message",
"modifier",
"to",
"the",
"debugger",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L93-L98 | train |
3rd-Eden/diagnostics | diagnostics.js | process | function process(message) {
for (var i = 0; i < modifiers.length; i++) {
message = modifiers[i].apply(modifiers[i], arguments);
}
return message;
} | javascript | function process(message) {
for (var i = 0; i < modifiers.length; i++) {
message = modifiers[i].apply(modifiers[i], arguments);
}
return message;
} | [
"function",
"process",
"(",
"message",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"modifiers",
".",
"length",
";",
"i",
"++",
")",
"{",
"message",
"=",
"modifiers",
"[",
"i",
"]",
".",
"apply",
"(",
"modifiers",
"[",
"i",
"]",
"... | Process the message with the modifiers.
@param {Mixed} message The message to be transformed by modifers.
@returns {String} Transformed message.
@public | [
"Process",
"the",
"message",
"with",
"the",
"modifiers",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L118-L124 | train |
3rd-Eden/diagnostics | diagnostics.js | introduce | function introduce(fn, options) {
var has = Object.prototype.hasOwnProperty;
for (var key in options) {
if (has.call(options, key)) {
fn[key] = options[key];
}
}
return fn;
} | javascript | function introduce(fn, options) {
var has = Object.prototype.hasOwnProperty;
for (var key in options) {
if (has.call(options, key)) {
fn[key] = options[key];
}
}
return fn;
} | [
"function",
"introduce",
"(",
"fn",
",",
"options",
")",
"{",
"var",
"has",
"=",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
";",
"for",
"(",
"var",
"key",
"in",
"options",
")",
"{",
"if",
"(",
"has",
".",
"call",
"(",
"options",
",",
"key",
... | Introduce options to the logger function.
@param {Function} fn Calback function.
@param {Object} options Properties to introduce on fn.
@returns {Function} The passed function
@public | [
"Introduce",
"options",
"to",
"the",
"logger",
"function",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L134-L144 | train |
3rd-Eden/diagnostics | diagnostics.js | nope | function nope(options) {
options.enabled = false;
options.modify = modify;
options.set = set;
options.use = use;
return introduce(function diagnopes() {
return false;
}, options);
} | javascript | function nope(options) {
options.enabled = false;
options.modify = modify;
options.set = set;
options.use = use;
return introduce(function diagnopes() {
return false;
}, options);
} | [
"function",
"nope",
"(",
"options",
")",
"{",
"options",
".",
"enabled",
"=",
"false",
";",
"options",
".",
"modify",
"=",
"modify",
";",
"options",
".",
"set",
"=",
"set",
";",
"options",
".",
"use",
"=",
"use",
";",
"return",
"introduce",
"(",
"fun... | Nope, we're not allowed to write messages.
@returns {Boolean} false
@public | [
"Nope",
"we",
"re",
"not",
"allowed",
"to",
"write",
"messages",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L152-L161 | train |
3rd-Eden/diagnostics | diagnostics.js | yep | function yep(options) {
/**
* The function that receives the actual debug information.
*
* @returns {Boolean} indication that we're logging.
* @public
*/
function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
write.call(write, options, process(args, options));
retu... | javascript | function yep(options) {
/**
* The function that receives the actual debug information.
*
* @returns {Boolean} indication that we're logging.
* @public
*/
function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
write.call(write, options, process(args, options));
retu... | [
"function",
"yep",
"(",
"options",
")",
"{",
"/**\n * The function that receives the actual debug information.\n *\n * @returns {Boolean} indication that we're logging.\n * @public\n */",
"function",
"diagnostics",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototy... | Yep, we're allowed to write debug messages.
@param {Object} options The options for the process.
@returns {Function} The function that does the logging.
@public | [
"Yep",
"we",
"re",
"allowed",
"to",
"write",
"debug",
"messages",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L170-L190 | train |
3rd-Eden/diagnostics | diagnostics.js | diagnostics | function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
write.call(write, options, process(args, options));
return true;
} | javascript | function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
write.call(write, options, process(args, options));
return true;
} | [
"function",
"diagnostics",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"write",
".",
"call",
"(",
"write",
",",
"options",
",",
"process",
"(",
"args",
",",
"options",... | The function that receives the actual debug information.
@returns {Boolean} indication that we're logging.
@public | [
"The",
"function",
"that",
"receives",
"the",
"actual",
"debug",
"information",
"."
] | a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1 | https://github.com/3rd-Eden/diagnostics/blob/a37d632b2e7049d3ea79fbe2eb7d1165cbba6fb1/diagnostics.js#L177-L182 | train |
canjs/can-legacy-view-helpers | src/view.js | function(fn) {
return function() {
var realArgs = [];
var fnArgs = arguments;
each(fnArgs, function(val, i) {
if (i <= fnArgs.length) {
while (val && val.isComputed) {
val = val();
}
realArgs.push(val);
}
});
return fn.apply(this, realArgs);
};
} | javascript | function(fn) {
return function() {
var realArgs = [];
var fnArgs = arguments;
each(fnArgs, function(val, i) {
if (i <= fnArgs.length) {
while (val && val.isComputed) {
val = val();
}
realArgs.push(val);
}
});
return fn.apply(this, realArgs);
};
} | [
"function",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"realArgs",
"=",
"[",
"]",
";",
"var",
"fnArgs",
"=",
"arguments",
";",
"each",
"(",
"fnArgs",
",",
"function",
"(",
"val",
",",
"i",
")",
"{",
"if",
"(",
"i",
"<=",
"... | Returns a function that automatically converts all computes passed to it | [
"Returns",
"a",
"function",
"that",
"automatically",
"converts",
"all",
"computes",
"passed",
"to",
"it"
] | 42886b363251b693d835d869816fcedb0c74b114 | https://github.com/canjs/can-legacy-view-helpers/blob/42886b363251b693d835d869816fcedb0c74b114/src/view.js#L751-L765 | train | |
canjs/can-legacy-view-helpers | src/render.js | function () {
var old = view.lists,
data;
view.lists = function (list, renderer) {
data = {
list: list,
renderer: renderer
};
return Math.random();
};
// sets back to the old data
return function () {
view.lists = old;
return data;
};
} | javascript | function () {
var old = view.lists,
data;
view.lists = function (list, renderer) {
data = {
list: list,
renderer: renderer
};
return Math.random();
};
// sets back to the old data
return function () {
view.lists = old;
return data;
};
} | [
"function",
"(",
")",
"{",
"var",
"old",
"=",
"view",
".",
"lists",
",",
"data",
";",
"view",
".",
"lists",
"=",
"function",
"(",
"list",
",",
"renderer",
")",
"{",
"data",
"=",
"{",
"list",
":",
"list",
",",
"renderer",
":",
"renderer",
"}",
";"... | called in text to make a temporary can.view.lists function that can be called with the list to iterate over and the template used to produce the content within the list | [
"called",
"in",
"text",
"to",
"make",
"a",
"temporary",
"can",
".",
"view",
".",
"lists",
"function",
"that",
"can",
"be",
"called",
"with",
"the",
"list",
"to",
"iterate",
"over",
"and",
"the",
"template",
"used",
"to",
"produce",
"the",
"content",
"wit... | 42886b363251b693d835d869816fcedb0c74b114 | https://github.com/canjs/can-legacy-view-helpers/blob/42886b363251b693d835d869816fcedb0c74b114/src/render.js#L77-L94 | train | |
medea/medea | hint_file_parser.js | function(dirname, keydir, dataFile, cb1) {
var fileId = Number(path.basename(dataFile, '.medea.data'));
var file = new DataFileParser({ filename: dataFile });
file.on('error', cb1);
file.on('entry', function(entry) {
var key = entry.key.toString();
if (key.length === 0) {
return;
}
if (!... | javascript | function(dirname, keydir, dataFile, cb1) {
var fileId = Number(path.basename(dataFile, '.medea.data'));
var file = new DataFileParser({ filename: dataFile });
file.on('error', cb1);
file.on('entry', function(entry) {
var key = entry.key.toString();
if (key.length === 0) {
return;
}
if (!... | [
"function",
"(",
"dirname",
",",
"keydir",
",",
"dataFile",
",",
"cb1",
")",
"{",
"var",
"fileId",
"=",
"Number",
"(",
"path",
".",
"basename",
"(",
"dataFile",
",",
"'.medea.data'",
")",
")",
";",
"var",
"file",
"=",
"new",
"DataFileParser",
"(",
"{",... | parse data file for keys when hint file is missing | [
"parse",
"data",
"file",
"for",
"keys",
"when",
"hint",
"file",
"is",
"missing"
] | 3438fbcf7ce3c89b9ec52b4523a164db43e261a2 | https://github.com/medea/medea/blob/3438fbcf7ce3c89b9ec52b4523a164db43e261a2/hint_file_parser.js#L20-L43 | train | |
AlexGalays/kaiju | src/lib/message.js | PartiallyAppliedMessage | function PartiallyAppliedMessage(underlyingMessage, payload) {
function message(...otherPayloads) {
return underlyingMessage.apply(null, [payload, ...otherPayloads])
}
message.type = 'partiallyAppliedMessage'
message._id = underlyingMessage._id
message._name = underlyingMessage._name
message._isMessa... | javascript | function PartiallyAppliedMessage(underlyingMessage, payload) {
function message(...otherPayloads) {
return underlyingMessage.apply(null, [payload, ...otherPayloads])
}
message.type = 'partiallyAppliedMessage'
message._id = underlyingMessage._id
message._name = underlyingMessage._name
message._isMessa... | [
"function",
"PartiallyAppliedMessage",
"(",
"underlyingMessage",
",",
"payload",
")",
"{",
"function",
"message",
"(",
"...",
"otherPayloads",
")",
"{",
"return",
"underlyingMessage",
".",
"apply",
"(",
"null",
",",
"[",
"payload",
",",
"...",
"otherPayloads",
"... | Creates a new Message type that is partially applied with a payload | [
"Creates",
"a",
"new",
"Message",
"type",
"that",
"is",
"partially",
"applied",
"with",
"a",
"payload"
] | 54d6118f4ebdf0725a907c87be7f262405e16e48 | https://github.com/AlexGalays/kaiju/blob/54d6118f4ebdf0725a907c87be7f262405e16e48/src/lib/message.js#L35-L53 | train |
AlexGalays/kaiju | src/lib/component.js | postpatch | function postpatch(oldVnode, vnode) {
const oldData = oldVnode.data
const newData = vnode.data
// Server side rendering: Reconcilating with a server-rendered node will have skipped calling insert()
if (!oldData.component) {
insert(vnode)
}
// oldData wouldn't have a component reference set if it came ... | javascript | function postpatch(oldVnode, vnode) {
const oldData = oldVnode.data
const newData = vnode.data
// Server side rendering: Reconcilating with a server-rendered node will have skipped calling insert()
if (!oldData.component) {
insert(vnode)
}
// oldData wouldn't have a component reference set if it came ... | [
"function",
"postpatch",
"(",
"oldVnode",
",",
"vnode",
")",
"{",
"const",
"oldData",
"=",
"oldVnode",
".",
"data",
"const",
"newData",
"=",
"vnode",
".",
"data",
"// Server side rendering: Reconcilating with a server-rendered node will have skipped calling insert()",
"if",... | Called on every parent re-render, this is where the props passed by the component's parent may have changed. | [
"Called",
"on",
"every",
"parent",
"re",
"-",
"render",
"this",
"is",
"where",
"the",
"props",
"passed",
"by",
"the",
"component",
"s",
"parent",
"may",
"have",
"changed",
"."
] | 54d6118f4ebdf0725a907c87be7f262405e16e48 | https://github.com/AlexGalays/kaiju/blob/54d6118f4ebdf0725a907c87be7f262405e16e48/src/lib/component.js#L105-L134 | train |
jonschlinkert/github-base | lib/utils.js | createHeaders | function createHeaders(options) {
const opts = Object.assign({}, options);
const headers = Object.assign({}, defaultHeaders, lowercaseKeys(opts.headers || {}));
if (!opts.bearer && !opts.token && !opts.username && !opts.password) {
return headers;
}
if (opts.token) {
headers['authorization'] = 'toke... | javascript | function createHeaders(options) {
const opts = Object.assign({}, options);
const headers = Object.assign({}, defaultHeaders, lowercaseKeys(opts.headers || {}));
if (!opts.bearer && !opts.token && !opts.username && !opts.password) {
return headers;
}
if (opts.token) {
headers['authorization'] = 'toke... | [
"function",
"createHeaders",
"(",
"options",
")",
"{",
"const",
"opts",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"const",
"headers",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultHeaders",
",",
"lowercaseKeys",
... | Create auth string - token, Bearer or Basic Auth | [
"Create",
"auth",
"string",
"-",
"token",
"Bearer",
"or",
"Basic",
"Auth"
] | 2fd664e3f9a3ad24758401bf98743d553875d2cf | https://github.com/jonschlinkert/github-base/blob/2fd664e3f9a3ad24758401bf98743d553875d2cf/lib/utils.js#L113-L134 | 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.