_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11900 | getMetaData | train | function getMetaData (data) {
if (typeof data !== 'string') {
throw new MeowError ('data is not a string');
}
data = data || '';
data = data.split('\n');
if (('' + data[0]).trim() !== '<!--') {
throw new MeowError ("Incorrect format : Missing '<!--' in the beginning of the file");
... | javascript | {
"resource": ""
} |
q11901 | generateSlug | train | function generateSlug (title) {
if (typeof title !== 'string') {
throw new MeowError ('title is not a string');
}
title = title || ''; | javascript | {
"resource": ""
} |
q11902 | sortPostsByPublishedDate | train | function sortPostsByPublishedDate (pPosts) {
if (! (pPosts instanceof Array) ) {
throw new MeowError ("pPosts is not an array");
}
pPosts.sort(function (pFirst, pSecond) {
pFirst = pFirst || {};
pSecond = pSecond || {};
var pFirstPublishedDate = pFirst['published-date'],
... | javascript | {
"resource": ""
} |
q11903 | getFilePathRelativeToAppRoot | train | function getFilePathRelativeToAppRoot (pPath) {
// go to meow-blog directory
var projectBaseDirectory = path.resolve(__dirname, '..');
if (projectBaseDirectory.indexOf('node_modules') !== -1) | javascript | {
"resource": ""
} |
q11904 | set | train | function set(app, prop, val) {
var data = app.cache.data.project;
if (typeof val !== 'undefined') {
data[prop] = val;
| javascript | {
"resource": ""
} |
q11905 | assertPublisherOptions | train | function assertPublisherOptions(options) {
mod_assert.object(options, 'options');
mod_assert.object(options.log, 'options.log');
mod_assert.object(options.moray, 'options.moray');
mod_assert.string(options.moray.bucketName, 'options.moray.bucketName');
mod_assert.optionalObject(options.backoff, 'opt... | javascript | {
"resource": ""
} |
q11906 | _bucketInit | train | function _bucketInit() {
morayClient.getBucket(self.morayBucket.name, function _gb(err) {
if (isBucketNotFoundError(err)) {
var name = self.morayBucket.name;
var config = self.morayBucket.config;
morayClient.createBucket(name, confi... | javascript | {
"resource": ""
} |
q11907 | removePendingReq | train | function removePendingReq() {
var idx = indexOf($http.pendingRequests, config);
if (idx !== -1) {
$http.pendingRequests.splice(idx, 1);
| javascript | {
"resource": ""
} |
q11908 | parse_domain | train | function parse_domain (line) {
debug.assert(line).is('string');
// -S-G-J ==> "tili-lii.fi 2017-06-02"
// +S-G-J ==> "tili-lii.fi 2017-06-02 lock"
// +S+G-J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef"
// -S+G-J ==> "tili-lii.fi 2017-06-02 @creator true 0 undef"
// -S-G+J ==> "tili-lii.fi 2017-0... | javascript | {
"resource": ""
} |
q11909 | processData | train | function processData(err, data) {
if (enc) { file.text = data.toString(enc); } else { file.buffer = data; }
| javascript | {
"resource": ""
} |
q11910 | handleReject | train | function handleReject(carousel) {
$element.css({ 'height': carousel.getOuterHeight() + 'px' });
| javascript | {
"resource": ""
} |
q11911 | create | train | function create(stylesObject) {
const stylesToClasses = {};
const styleNames = Object.keys(stylesObject);
const sharedState = globalCache.get(GLOBAL_CACHE_KEY) || {};
const { namespace = '' } = sharedState;
styleNames.forEach((styleName) => {
| javascript | {
"resource": ""
} |
q11912 | resolve | train | function resolve(stylesArray) {
const flattenedStyles = flat(stylesArray, Infinity);
const { classNames, hasInlineStyles, inlineStyles } = separateStyles(flattenedStyles);
| javascript | {
"resource": ""
} |
q11913 | train | function(file, done){
process.nextTick(function () {
terra.render(file, function(error, body){
if(error){
done(error);
}else{
if(body){
var dest = path.resolve(outputPath, ssr.helpers.outputPath(file));
fs.mkdirp(path.dirname(dest), f... | javascript | {
"resource": ""
} | |
q11914 | search | train | function search(db, origin, destination, departure, options, callback) {
_log("====== STARTING SEARCH ======");
_log("ORIGIN: " + origin.name);
_log("DESTINATION: " + destination.name);
_log("DATE/TIME: " + departure.toString());
_log("OPTIONS: " + JSON.stringify(options, null, 2));
// List of Results
l... | javascript | {
"resource": ""
} |
q11915 | _cleanDepartures | train | function _cleanDepartures(results) {
// List of Departures to Keep
let departures = [];
// Get unique departures
let departureTimes = [];
for ( let i = 0; i < results.length; i++ ) {
if ( departureTimes.indexOf(results[i].origin.departure.toTimestamp()) === -1 ) {
departureTimes.push(... | javascript | {
"resource": ""
} |
q11916 | _cleanArrivals | train | function _cleanArrivals(results) {
// List of Arrivals to Keep
let arrivals = [];
// Get unique arrivals
let arrivalTimes = [];
for ( let i = 0; i < results.length; i++ ) {
if ( arrivalTimes.indexOf(results[i].destination.arrival.toTimestamp()) === -1 ) {
arrivalTimes.push(results[i].... | javascript | {
"resource": ""
} |
q11917 | _processTrips | train | function _processTrips(db, options, origin, destination, enter, trips, segments, callback) {
// Display function logs
_info();
// Results to Return
let RESULTS = [];
// Set up counters
let done = 0;
let count = trips.length;
// Finish when there are no trips to process
if ( trips.length === 0 ) ... | javascript | {
"resource": ""
} |
q11918 | _info | train | function _info() {
if ( LOG ) {
let p = "";
for ( let i = 0; i < segments.length * 2; i++ ) {
p = p + " ";
}
let tripIds = [];
for ( let i = 0; i < trips.length; i++ ) {
tripIds.push(trips[i].id);
}
_log(p + "Trips From " + enter.name + | javascript | {
"resource": ""
} |
q11919 | _info | train | function _info(stops) {
if ( LOG ) {
let p = "";
for ( let i = 0; i < segments.length * 2; i++ ) {
p = p + " ";
}
_log(p + "...Trip " + trip.id);
_log(p + " Stop: " + enter.name + " @ " + trip.getStopTime(enter).departure.getTimeReadable());
_log(p + " Segments: " + ... | javascript | {
"resource": ""
} |
q11920 | _getTransferStops | train | function _getTransferStops(db, origin, destination, stop, trip, callback) {
// List of Transfer Stops
let rtn = [];
// Get Next Stops from this Stop
LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {
// Database Query Error
if ( err ) {
return callbac... | javascript | {
"resource": ""
} |
q11921 | _getTripsFromStop | train | function _getTripsFromStop(db, origin, destination, stop, tripSearchDates, excludeTrips, callback) {
// Get all possible following stops
LineGraphTable.getNextStops(db, origin.id, destination.id, stop.id, function(err, nextStops) {
// Database Query Error
if ( err ) {
return callback(err);
}
... | javascript | {
"resource": ""
} |
q11922 | _getTripSearchDates | train | function _getTripSearchDates(db, datetime, preMins, postMins, callback) {
// Get pre and post dates
let preDateTime = datetime.clone().deltaMins(-1*preMins);
let postDateTime = datetime.clone().deltaMins(postMins);
// List of TripSearchDates to return
let rtn = [];
// Counters
let done = 0;
let count... | javascript | {
"resource": ""
} |
q11923 | train | function (db, options, cb) {
this.db = db;
this.cb = cb;
this.updateQueryMaker = options.update;
this.insertQueryMaker = options.insert;
this.maxUpdateAttemptsCount = options.maxUpdateAttemptsCount || 2;
this.transform = options.transform;
this.insertFirst = | javascript | {
"resource": ""
} | |
q11924 | clientConnects | train | function clientConnects(p) {
var pList;
var nPlayers;
var waitTime;
var widgetConfig;
node.remoteSetup('page', p.id, {
clearBody: true,
title: { title: 'Welcome!', addToBody: true }
});
node.remoteSetup('widgets', p.id, {
dest... | javascript | {
"resource": ""
} |
q11925 | getServicesEffective | train | function getServicesEffective(db, date, callback) {
// Check Cache for Effective Services
let cacheKey = db.id + "-" + date;
let cache = cache_servicesEffectiveByDate.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Get the Default Services
getServicesDefault(db, date, funct... | javascript | {
"resource": ""
} |
q11926 | train | function(db, date, callback) {
// Check cache for services
let cacheKey = db.id + "-" + date;
let cache = cache_servicesDefaultByDate.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Array of default services to return
let rtn = [];
// Get day of week
let dt = DateTime.... | javascript | {
"resource": ""
} | |
q11927 | train | function(db, date, callback) {
// Check cache for service exceptions
let cacheKey = db.id + "-" + date;
let cache = cache_serviceExceptionsByDate.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Array of Service Exceptions to return
let rtn = [];
// Get service exceptions... | javascript | {
"resource": ""
} | |
q11928 | getTransform | train | function getTransform(options) {
if (typeof options === 'string' || options instanceof String) {
return options
}
if (typeof options === 'object' && options.engine) {
| javascript | {
"resource": ""
} |
q11929 | constructTransformer | train | function constructTransformer(options) {
const transform = getTransform(options)
if (transform && typeof transform === 'object') {
| javascript | {
"resource": ""
} |
q11930 | makeInterfaceValidator | train | function makeInterfaceValidator(interfacePropArrays) {
var props = flatten(interfacePropArrays);
return function(base) {
var missingProps = props.reduce(function(missing, prop) {
return prop in base ? missing : missing.concat(prop);
}, | javascript | {
"resource": ""
} |
q11931 | getLinks | train | function getLinks(db, callback) {
// Check cache for links
let cacheKey = db.id + "-" + 'links';
let cache = cache_links.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Build select statement
let select = "SELECT link_category_title, link_title, link_description, link_url F... | javascript | {
"resource": ""
} |
q11932 | train | function () {
/**
* Get a valid file path for a template file from a set of directories
* @param {Object} opts Configurable options (see periodicjs.core.protocols for more details)
* @param {string} [opts.extname] Periodic extension that may contain view file
* @param {string} opts.viewname Name of... | javascript | {
"resource": ""
} | |
q11933 | respondInKind | train | function respondInKind (opts = {}, callback) {
let { req, res, responseData, err } = opts;
opts.callback = (typeof opts.callback === 'function') ? opts.callback : callback;
if ((path.extname(req.originalUrl) === '.html' || req.is('html') || req.is('text/html') || path.extname(req.originalUrl) === '.htm') ||... | javascript | {
"resource": ""
} |
q11934 | train | function () {
/**
* Renders a view from template and sends data to client
* @param {Object} opts Configurable options (see periodicjs.core.responder for more details)
* @param {string} opts.extname Periodic extension which may have template in view folder
* @param {string} opts.viewname Name of tem... | javascript | {
"resource": ""
} | |
q11935 | train | function () {
/**
* Renders an error view from a template and sends data to client
* @param {Object} opts Configurable options (see periodicjs.core.responder for more details)
* @param {string|Object} opts.err Error details for response
* @param {Object} opts.req Express request object
* @param {Obj... | javascript | {
"resource": ""
} | |
q11936 | train | function () {
/**
* Returns inflected values from a string ie. application => applications, Application, etc.
* @param {Object} options Configurable options
* @param {string} options.model_name String that should be inflected
* @return {Object} Object containing inflected values indexed by type o... | javascript | {
"resource": ""
} | |
q11937 | train | function(url, data, type) {
assert(Login.app, "You must set Login.app = my-app-name-as-registered-with-you-again");
data.app = Login.app;
data.withCredentials = true; // let the server know this is a with-credentials call
data.caller = ""+document.location; // provide some extra info
// add in local cookie au... | javascript | {
"resource": ""
} | |
q11938 | getTripsFromStop | train | function getTripsFromStop(db, stop, tripSearchDates, nextStops, callback) {
// List of Trips to Return
let rtn = [];
// Counters
let done = 0;
let count = tripSearchDates.length;
// Parse each TripSearchDate separately
for ( let i = 0; i < tripSearchDates.length; i++ ) {
_getTripsFromStop(db, stop,... | javascript | {
"resource": ""
} |
q11939 | _addTrip | train | function _addTrip(trip) {
// Make sure trip isn't already in list
let found = false;
for ( let i = 0; i < rtn.length; i++ ) {
if ( rtn[i].id === trip.id ) {
found = true;
}
}
// Process new trip
if ( !found ) {
// Make sure the trip stops at any of the next stops, af... | javascript | {
"resource": ""
} |
q11940 | _getTripsFromStop | train | function _getTripsFromStop(db, stop, tripSearchDate, callback) {
// List of trips to return
let rtn = [];
// Set counters
let done = 0;
let count = 0;
// Build Service ID String
let serviceIdString = "'" + tripSearchDate.serviceIds.join("', '") + "'";
// Get Trip IDs
let select = "SELECT gtfs_stop... | javascript | {
"resource": ""
} |
q11941 | getHoliday | train | function getHoliday(db, date, callback) {
// Check cache for Holiday
let cacheKey = db.id + "-" + date;
let cache = cache_holidayByDate.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Build the select statement
let select = "SELECT date, holiday_name, peak, service_info " +... | javascript | {
"resource": ""
} |
q11942 | isHoliday | train | function isHoliday(db, date, callback) {
// Check cache for is holiday
let cacheKey = db.id + "-" + date;
let cache = cache_isHolidayByDate.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Get matching holiday
let select = "SELECT date, holiday_name, peak, service_info " +
... | javascript | {
"resource": ""
} |
q11943 | train | function(src, noEscape) {
var attrLen, newKey;
if (helper.isArray(src)) {
var attrLen = src.length;
for (var i = 0; i < attrLen; i++) {
src[i] = helper.pasteurize(src[i], noEscape);
}
} else if (this.isString(src)) {
src = helper.scrub(src, noEscape);
} else if (helper.is... | javascript | {
"resource": ""
} | |
q11944 | train | function(host, whitelist, next) {
var blacklist = this.options.blacklist;
helper.resolveHost(host, function(err, aRecords, resolvedHost) {
var inBlacklist = false;
if (!err) {
if (whitelist) {
if (_.intersection(aRecords, whitelist).length ) {
next(err, [], aRecords);
... | javascript | {
"resource": ""
} | |
q11945 | train | function(id, period, callback) {
var self = this;
if (this.$resource.cron) {
if (!this.crons[id]) {
self._logger.call(self, 'POD:Registering Cron:' + self.getName() + ':' + id);
self.crons[id] = new | javascript | {
"resource": ""
} | |
q11946 | train | function(message, channel, level) {
if (helper.isObject(message)) {
this._logger.call(this,
channel.action
+ ':'
+ (channel.owner_id ? channel.owner_id : 'system'),
level);
if (message.message) {
message = message;
}
this._logger.call(this, | javascript | {
"resource": ""
} | |
q11947 | train | function(owner_id, next) {
var self = this,
podName = this.getName(),
filter = {
owner_id : owner_id,
type : this.getAuthType(),
oauth_provider : this.getName()
};
this._dao.find('account_auth', filter, function(err, result) {
var model, authStruct;
if (result) {
... | javascript | {
"resource": ""
} | |
q11948 | train | function(channel, next) {
var filter = {
channel_id : channel.id
| javascript | {
"resource": ""
} | |
q11949 | train | function(action, channel, accountInfo, auth, next) {
var self = this, config = this.getConfig();
if (!next && 'function' === typeof auth) {
next = auth;
} else {
if (self.isOAuth()) {
if (!auth.oauth) {
auth.oauth = {};
}
_.each(config.oauth, function(value, ke... | javascript | {
"resource": ""
} | |
q11950 | train | function(action, method, sysImports, options, channel, req, res) {
var self = this;
if (this.actions[action] && (this.actions[action].rpc || 'invoke' === method)) {
if ('invoke' === method) {
var imports = (req.method === 'GET' ? req.query : req.body);
// @todo add files support
... | javascript | {
"resource": ""
} | |
q11951 | train | function(accountInfo) {
var self = this,
rpcs = this.getRPCs(),
schema = {
'name' : this.getName(),
'title' : this.getTitle(),
'description' : this.getDescription(),
'icon' : this.getIcon(accountInfo),
'auth' : this.getAuth(),
'rpcs' : this.getRPCs(),
... | javascript | {
"resource": ""
} | |
q11952 | train | function(channel, next) {
var filter = {
channel_id : channel.id,
owner_id : channel.owner_id
};
this._dao.findFilter('channel_pod_tracking', filter, function(err, result) {
| javascript | {
"resource": ""
} | |
q11953 | train | function(channel, next) {
var filter = {
channel_id : channel.id,
owner_id : channel.owner_id
},
self = this,
props = {
last_poll : helper.nowUTCSeconds()
}
this._dao.updateColumn(
'channel_pod_tracking',
filter,
props,
| javascript | {
"resource": ""
} | |
q11954 | getStopByName | train | function getStopByName(db, name, callback) {
// Check cache for Stop
let cacheKey = db.id + "-" + name;
let cache = cache_stopByName.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Different queries to lookup stop by name
let queries = [
"SELECT stop_id FROM gtfs_stops ... | javascript | {
"resource": ""
} |
q11955 | _queryForStopByName | train | function _queryForStopByName(db, query, callback) {
// Perform the search query
db.get(query, function(err, result) {
// No stop found, return undefined
| javascript | {
"resource": ""
} |
q11956 | getStopByStatusId | train | function getStopByStatusId(db, statusId, callback) {
// Make sure statusId is not -1
if ( statusId === "-1" ) {
return callback(
new Error('Stop does not have a valid Status ID')
);
}
// Check cache for stop
let cacheKey = db.id + "-" + statusId;
let cache = cache_stopByStatusId.get(cacheKey... | javascript | {
"resource": ""
} |
q11957 | _parseStopsByLocation | train | function _parseStopsByLocation(stops, lat, lon, count, distance, callback) {
// Calc distance to/from each stop
for ( let i = 0; i < stops.length; i++ ) {
stops[i].setDistance(lat, lon);
}
// Sort by distance
stops.sort(Stop.sortByDistance);
// Filter the stops to return
let rtn = [];
// Retur... | javascript | {
"resource": ""
} |
q11958 | clearCache | train | function clearCache() {
cache_stopById.clear();
cache_stopByName.clear();
cache_stopByStatusId.clear();
| javascript | {
"resource": ""
} |
q11959 | distance | train | function distance(lat1, lon1, lat2, lon2) {
let R = 6371; // Radius of the earth in km
let dLat = _deg2rad(lat2-lat1); // deg2rad below
let dLon = _deg2rad(lon2-lon1);
let a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(_deg2rad(lat1)) * Math.cos(_deg2rad(lat2)) *
Math.sin(dLon/2) * | javascript | {
"resource": ""
} |
q11960 | getPaths | train | function getPaths(db, originId, destinationId, callback) {
// Get Graph
buildGraph(db, function(err, graph) {
if ( err ) {
return callback(err);
}
// Paths to return
let rtn = [];
// Search the Graph
for ( let it = graph.paths(originId, destinationId), kv; !(kv = it.next()).done;) {... | javascript | {
"resource": ""
} |
q11961 | buildGraph | train | function buildGraph(db, callback) {
// Check cache for graph
let cacheKey = db.id + "-graph";
let cache = cache_graph.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Build Graph
let graph = new Graph();
// Add the Vertices
_addGraphVertices(db, graph, function(err, gra... | javascript | {
"resource": ""
} |
q11962 | _addGraphVertices | train | function _addGraphVertices(db, graph, callback) {
// Get all Stops
StopsTable.getStops(db, function(err, stops) {
// Database Query Error
if ( err ) {
return callback(err);
}
// Add each Stop as a Vertex
for ( let i = 0; | javascript | {
"resource": ""
} |
q11963 | _addGraphEdges | train | function _addGraphEdges(db, graph, callback) {
// Counters
let done = 0;
let count = graph.vertexCount();
// Loop through each Vertex in the Graph
for ( let [stopId, stop] of graph ) {
// Get the Edges for the Vertex
_getStopEdges(db, stopId, function(err, edges) {
// Database Query Error
... | javascript | {
"resource": ""
} |
q11964 | createZoneSocket | train | function createZoneSocket(options, callback) {
if (!options) throw new TypeError('options required');
if (!(options instanceof Object)) {
throw new TypeError('options must be an Object');
}
if (!options.zone) throw new TypeError('options.zone required');
if (!opti... | javascript | {
"resource": ""
} |
q11965 | getStopTimeByTripStop | train | function getStopTimeByTripStop(db, tripId, stopId, date, callback) {
// Cache Cache for StopTimes
let cacheKey = db.id + "-" + tripId + "-" + stopId + "-" + date;
let cache = cache_stoptimesByTripStop.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Build the select statement
... | javascript | {
"resource": ""
} |
q11966 | getTripByShortName | train | function getTripByShortName(db, shortName, date, callback) {
// Check Cache for Trip
let cacheKey = db.id + "-" + shortName + "-" + date;
let cache = cache_tripsByShortName.get(cacheKey);
if ( cache !== null ) {
return callback(null, cache);
}
// Get effective service ids
_buildEffectiveServiceIDStr... | javascript | {
"resource": ""
} |
q11967 | getTripByDeparture | train | function getTripByDeparture(db, originId, destinationId, departure, callback) {
// Check cache for trip
let cacheKey = db.id + "-" + originId + "-" + destinationId + "-" + departure.getTimeSeconds() + "-" + departure.getDateInt();
let cache = cache_tripsByDeparture.get(cacheKey);
if ( cache !== null ) {
re... | javascript | {
"resource": ""
} |
q11968 | _getTripByDeparture | train | function _getTripByDeparture(db, originId, destinationId, departure, callback) {
// Get Effective Services for departure date
_buildEffectiveServiceIDString(db, departure.getDateInt(), function(err, serviceIdString) {
if ( err ) {
return callback(err);
}
// Find a matching trip
_getMatchingT... | javascript | {
"resource": ""
} |
q11969 | _buildEffectiveServiceIDString | train | function _buildEffectiveServiceIDString(db, date, callback) {
// Query the Calendar for effective services
CalendarTable.getServicesEffective(db, date, function(err, services) {
// Database Query Error
if ( err ) {
return callback(err);
}
// Build Service ID String
let serviceIds = [];
... | javascript | {
"resource": ""
} |
q11970 | _getMatchingTripId | train | function _getMatchingTripId(db, originId, destinationId, departure, serviceIdString, callback) {
// Find a matching trip in the gtfs_stop_times table
let select = "SELECT trip_id FROM gtfs_trips " +
"WHERE service_id IN " + serviceIdString + " " +
"AND trip_id IN (" +
"SELECT trip_id FROM gtfs_stop_tim... | javascript | {
"resource": ""
} |
q11971 | getTripsByDate | train | function getTripsByDate(db, date, opts, callback) {
// Parse Args
if ( callback === undefined && typeof opts === 'function' ) {
callback = opts;
opts = {}
}
// Check cache for trips
let cacheKey = db.id + "-" + date + "-" + opts.routeId + "-" + opts.stopId;
let cache = cache_tripsByDate.get(cacheK... | javascript | {
"resource": ""
} |
q11972 | _finish | train | function _finish() {
done++;
if ( count === 0 || done === count ) {
| javascript | {
"resource": ""
} |
q11973 | simplyfy | train | function simplyfy(val){
switch(val[0]){
case 'z': // shorthand line to start
case 'Z':
val[0] = 'L'
val[1] = this.start[0]
val[2] = this.start[1]
break
case 'H': // shorthand horizontal line
val[0] = 'L'
val[2] = this.pos[1]
break
case 'V': // shorthand verti... | javascript | {
"resource": ""
} |
q11974 | setPosAndReflection | train | function setPosAndReflection(val){
var len = val.length
this.pos = [ val[len-2], val[len-1] ] | javascript | {
"resource": ""
} |
q11975 | toBeziere | train | function toBeziere(val){
var retVal = [val]
switch(val[0]){
case 'M': // special handling for M
this.pos = this.start = [val[1], val[2]]
return retVal
case 'L':
val[5] = val[3] = val[1]
val[6] = val[4] = val[2]
val[1] = this.pos[0]
val[2] = this.pos[1]
break
ca... | javascript | {
"resource": ""
} |
q11976 | findNextM | train | function findNextM(arr, offset){
if(offset === false) return false
for(var i = offset, len = arr.length;i < len;++i){ | javascript | {
"resource": ""
} |
q11977 | getFriendlyBrowser | train | function getFriendlyBrowser(browserName) {
browserName = browserName || "";
if (typeof browserName === "string" && browserName) {
if (browserName === "MicrosoftEdge") {
browserName = "edge";
}
if (browserName === "internet explorer") {
browserName = "ie";
}
else | javascript | {
"resource": ""
} |
q11978 | Glob | train | function Glob(options) {
if (!(this instanceof Glob)) {
return new Glob(options);
}
Emitter.call(this);
| javascript | {
"resource": ""
} |
q11979 | train | function (opts) {
this.options = opts || {};
this.pattern = null;
this.middleware = {};
this.includes = {};
this.excludes = {};
this.files = [];
| javascript | {
"resource": ""
} | |
q11980 | train | function (glob, opts) {
if (opts.ignore) {
this.map('exclude', opts.ignore, opts);
}
if (opts.exclude) {
this.map('exclude', opts.exclude, opts);
}
if (opts.include) {
this.map('include', opts.include, opts);
}
// if not disabled by the user, run the built-ins
if (!thi... | javascript | {
"resource": ""
} | |
q11981 | train | function (pattern, options) {
options = options || {};
this.pattern = new Pattern(pattern, options);
this.recurse = this.shouldRecurse(this.pattern, options);
// if middleware are registered, use the glob, otherwise regex
| javascript | {
"resource": ""
} | |
q11982 | train | function (file) {
return new File({
pattern: this.pattern,
recurse: this.recurse, | javascript | {
"resource": ""
} | |
q11983 | train | function(pattern, options) {
var opts = this.setDefaults(options);
if (typeof opts.recurse === 'boolean') {
| javascript | {
"resource": ""
} | |
q11984 | train | function(method, arr/*, arguments*/) {
var args = [].slice.call(arguments, 2);
utils.arrayify(arr || []).forEach(function (obj) {
| javascript | {
"resource": ""
} | |
q11985 | train | function(pattern, options, cb) {
if (typeof options === 'function') {
return this.readdir(pattern, {}, options);
}
this.emit('read');
this.setPattern(pattern, options);
this.iteratorAsync(this.pattern.base, function (err) {
| javascript | {
"resource": ""
} | |
q11986 | train | function(pattern, options) {
this.emit('read');
this.setPattern(pattern, options);
this.iteratorSync(this.pattern.base);
| javascript | {
"resource": ""
} | |
q11987 | train | function(pattern, options) {
this.emit('read');
this.setPattern(pattern, options);
var res | javascript | {
"resource": ""
} | |
q11988 | File | train | function File(file) {
this.cache = new Map();
this.history = [];
this.pattern = file.pattern;
this.recurse = file.recurse;
this.dirname = | javascript | {
"resource": ""
} |
q11989 | Pattern | train | function Pattern(glob, options, isNegated) {
utils.defineProp(this, 'cache', new Map());
this.negated = !!isNegated;
| javascript | {
"resource": ""
} |
q11990 | train | function(str){
if(_.isUndefined(str))
str = '00';
| javascript | {
"resource": ""
} | |
q11991 | train | function(num){
if(_.isUndefined(num) || num == 0)
num = '00';
if(_.isString(num) || _.isNumber(num))
num = new BigNumber(String(num));
| javascript | {
"resource": ""
} | |
q11992 | train | function(addr, format){
if(_.isUndefined(format) || !_.isString(format))
format = 'hex';
if(_.isUndefined(addr)
|| !_.isString(addr))
addr = '0000000000000000000000000000000000000000';
if(addr.substr(0, 2) == '0x' && format | javascript | {
"resource": ""
} | |
q11993 | train | function(length) {
var charset = "abcdef0123456789";
var i;
var result = "";
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
if(window.crypto && window.crypto.getRandomValues) {
values = new Uint32Array(length);
window.crypto.getRandomValues(values);
... | javascript | {
"resource": ""
} | |
q11994 | train | function(value){
if(_.isUndefined(value) || !_.isObject(value))
| javascript | {
"resource": ""
} | |
q11995 | train | function(context){
Object.defineProperty(context, 'length', {
get: function() {
var count = 0;
// count valid accounts in browser storage
_.each(this.get(), function(account, accountIndex){
if(_.isUndefined(account)
|| !_.isObject(accoun... | javascript | {
"resource": ""
} | |
q11996 | pipe | train | function pipe(funcs) {
return function pipeRewire(config) {
const args = Array.prototype.slice.call(arguments, 1);
(funcs || []).forEach(func => {
if (func && typeof func === 'function') {
| javascript | {
"resource": ""
} |
q11997 | mergeScripts | train | function mergeScripts(crsScripts) {
const scripts = {
build: path.join(__dirname, 'scripts/build.js'),
start: path.join(__dirname, 'scripts/start.js'),
test: path.join(__dirname, 'scripts/test.js'),
| javascript | {
"resource": ""
} |
q11998 | compose | train | function compose(...args) {
// convert pipe to compose by reverse the array
const crsConfigs = args.slice(0).reverse();
const crsConfig = {
env: pipe(crsConfigs.map(c => c.env)),
paths: pipe(crsConfigs.map(c => c.paths)),
webpack: pipe(crsConfigs.map(c => c.webpack)),
| javascript | {
"resource": ""
} |
q11999 | createReactScripts | train | function createReactScripts(scriptsDir) {
// obtain the crs.config path
// we allow user to use crs.config under app directory instead if scriptsDir is not provided
// in this case, we do not allow customize new scripts and template
const crsConfigPath = path.join(scriptsDir || process.cwd(), 'crs.config.js');
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.