_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38200 | train | function (timerId, timerName, t) {
if (this.enabled) {
if (this._startDate[timerId]) {
var duration = (t || (+new Date())) - this._startDate[timerId];
delete this._startDate[timerId];
if (console.profile) {
... | javascript | {
"resource": ""
} | |
q38201 | train | function (options) {
this.options = options;
// options.back can be used to change view 'Back' link.
if (options.back) {
this.back = options.back;
}
this.callSubviews('setOptions', options);
this.applyOptions(options);
} | javascript | {
"resource": ""
} | |
q38202 | train | function (method) {
if (this.subviews.length !== 0) {
var params = slice.call(arguments);
params.shift();
_.each(this.subviews, function (s) {
if (s[method]) {
s[method].apply(s, params);
}
... | javascript | {
"resource": ""
} | |
q38203 | train | function (e) {
e.preventDefault();
var $target = $(e.target);
while ($target) {
var route = $target.attr('route');
if (route) {
// A route has been defined, follow the link using
// Jackbone's default router.
... | javascript | {
"resource": ""
} | |
q38204 | train | function () {
// Note: Controllers are responsible of setting needRedraw.
if (this.needRedraw) {
// Create root element for the page
var page = document.createElement('div');
page.style.display = 'block';
page.setAttribute('data-r... | javascript | {
"resource": ""
} | |
q38205 | train | function () {
var that = this;
var now = +new Date();
var toRemove = _(this.controllers).filter(function (c) {
var age = (now - c.lastView);
return (age > 60000); // Keep in cache for 1 minute.
});
_(toRemove).each(function (c... | javascript | {
"resource": ""
} | |
q38206 | train | function () {
var content = ctrl.view;
var header = noHeader ? null : new Jackbone.DefaultHeader();
var footer = noFooter ? null : new Jackbone.DefaultFooter();
var view = new JQMView(header, content, footer);
// C... | javascript | {
"resource": ""
} | |
q38207 | train | function (separator, page, args) {
// By default, we return page name without arguments.
var ret = page;
if (typeof args !== 'undefined') {
if (args && args.length) {
// Some arguments have been provided, add them.
if (args.length !== 0) {
... | javascript | {
"resource": ""
} | |
q38208 | train | function (pageName, page, role) {
// Extends Views
// Create JQuery Mobile Page
var pageid = 'pagename-' + pageName.toLowerCase();
var isExistingPage = $('#' + pageid);
// For already existing pages, only delegate events so they can
// handle onPa... | javascript | {
"resource": ""
} | |
q38209 | train | function (pageName, role) {
var lastPageName = this.currentPageName || '';
var lastPageRole = this.currentPageRole || '';
this.currentPageName = pageName;
this.currentPageRole = role;
// Known transition, return it.
if (_(this.transitions)... | javascript | {
"resource": ""
} | |
q38210 | TiqDB | train | function TiqDB(config) {
var defaultConfig = {
client: 'sqlite3',
connection: {
host: 'localhost',
user: null,
password: null,
database: 'tiq',
filename: path.join(process.env.XDG_DATA_HOME ||
path.join(process.env.HOME, '.local', 'share'), 'tiq', 'store... | javascript | {
"resource": ""
} |
q38211 | train | function () {
this._super.onenter ();
if ( this.box.pageY < window.innerHeight ) {
this._hilite ();
} else {
this.tick.time ( function () {
this._hilite ();
}, 200 );
}
} | javascript | {
"resource": ""
} | |
q38212 | train | function ( code ) {
var text = code.firstChild;
if ( text ) {
text.data = text.data.substring ( 1 ); // we inserted a #
}
} | javascript | {
"resource": ""
} | |
q38213 | trampoline | train | function trampoline(queue) {
index = [0];
stack = [queue];
var queueIndex, queueLength;
var stackIndex = 1; // 1-indexed!
var stackLength = stack.length;
var topOfStack = true;
while (stackIndex) {
queue = stack[stackIndex - 1];
queueIndex = index[stackIndex - 1];
if (queueIndex === -1) {
... | javascript | {
"resource": ""
} |
q38214 | enterTurn | train | function enterTurn() {
var snapshot;
while ((snapshot = queue).length) {
queue = [];
trampoline(snapshot);
}
queue = null;
} | javascript | {
"resource": ""
} |
q38215 | createForBuild | train | function createForBuild(build) {
var exports = {};
function bundles(name, sourceType) {
/*jshint validthis: true */
var ml = build.bundles(name, sourceType);
return this.markSafe(ml);
}
exports.bundles = bundles;
function link(srcPath, relative) {
/*jshint validthis: true */
var ml =... | javascript | {
"resource": ""
} |
q38216 | Client | train | function Client (opts) {
var self = this
typeforce({
url: 'String',
otrKey: 'DSA',
// byRootHash: 'Function',
instanceTag: '?String',
autoconnect: '?Boolean' // defaults to true
}, opts)
EventEmitter.call(this)
this.setMaxListeners(0)
this._url = parseURL(opts.url)
this._autoconnect... | javascript | {
"resource": ""
} |
q38217 | preserveNamespace | train | function preserveNamespace (models) {
const prefixedModels = {}
if (connector.config.skipModelNamespace) {
// if namspace is not applied we do not need to preserve it
return models
} else {
for (var model in models) {
prefixedModels[models[model].name] = models[model]
}
... | javascript | {
"resource": ""
} |
q38218 | execute | train | function execute(req, res) {
this.state.pubsub.unsubscribe(req.conn, req.args);
} | javascript | {
"resource": ""
} |
q38219 | gfmTable | train | function gfmTable (data, options) {
options = options || {}
if (!data || !data.length) {
return ''
}
data = escapePipes(data)
var tableOptions = {
nowrap: !options.wrap,
padding: { left: '| ', right: ' ' },
columns: options.columns || [],
getColumn: function (columnName) {
return ... | javascript | {
"resource": ""
} |
q38220 | installPluginsFromConfigXML | train | function installPluginsFromConfigXML(args) {
events.emit('verbose', 'Checking config.xml for saved plugins that haven\'t been added to the project');
//Install plugins that are listed on config.xml
var projectRoot = cordova_util.cdProjectRoot();
var configPath = cordova_util.projectConfig(projectRoot);... | javascript | {
"resource": ""
} |
q38221 | train | function(grunt, gruntFilesArray, gruntOptions) {
/**
* @property styleGuideGenerator.grunt
* @type {Object}
*/
this.grunt = grunt;
/**
* An unexpanded grunt file array
*
* @property styleGuideGenerator.gruntFilesArray
* @type {Arra... | javascript | {
"resource": ""
} | |
q38222 | train | function(obj) {
if (typeof obj === "object") {
if (Array.isArray(obj) && obj.length > 1) {
obj = '[ '+toString(obj[0])+', ... ]';
}
}
return (obj+'');
} | javascript | {
"resource": ""
} | |
q38223 | preview | train | function preview (source, line, options) {
let from, to, pos
// set from/to line
if (Array.isArray(line)) {
from = line[0] | 0
to = line[1] | 0 || from
} else if (typeof line === 'object') {
from = to = line.line | 0
pos = {
line: line.line | 0,
column: line.column | 0
}
} els... | javascript | {
"resource": ""
} |
q38224 | readSource | train | function readSource (source, from, to, offset, delimiter) {
// fix args
from = from | 0
to = to | 0 || from
delimiter = delimiter || PREVIEW_OPTS.delimiter
if (typeof offset === 'undefined') {
offset = PREVIEW_OPTS.offset
} else {
offset = offset | 0
}
let lastIdx = -1
let currIdx = lastIdx
... | javascript | {
"resource": ""
} |
q38225 | getUrlParameter | train | function getUrlParameter(sPageURL) {
var url = sPageURL.split('?');
var obj = {};
if (url.length == 2) {
var sURLVariables = url[1].split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
ob... | javascript | {
"resource": ""
} |
q38226 | train | function ()
{
var tableData = [
['LOOP TYPE', ...config.counts]
];
var bases = [];
Object.keys(results['while desc']).forEach(function (countType)
{
var times = results['while desc'][countType];
var sum = times.reduce(function (acc, val)
... | javascript | {
"resource": ""
} | |
q38227 | getAttribute | train | function getAttribute(element, name) {
assertType(element, Node, false, 'Invalid element specified');
if (!element.getAttribute) return null;
let value = element.getAttribute(name);
if (value === '') return true;
if (value === undefined || value === null) return null;
try {
return JSON.parse(value);
... | javascript | {
"resource": ""
} |
q38228 | fileUpload | train | function fileUpload(fileURI, serverURI, fileUploadOptions) {
var deferred = q.defer();
var transfer = new FileTransfer();
transfer.upload(fileURI, serverURI, function uploadSuccess(response) {
deferred.resolve(response);
}, function uploadFailure(error) {
deferred.reject(error);
}, fileUploadOptions);... | javascript | {
"resource": ""
} |
q38229 | fileUploadRetry | train | function fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries) {
return fileUpload(fileURI, serverURI, fileUploadOptions)
.then(function(response) {
return response;
}, function() {
if (retries === 0) {
throw new Error("Can't upload to " + JSON.stringify(serverURI));
}
ret... | javascript | {
"resource": ""
} |
q38230 | addAllMtimes | train | function addAllMtimes(files, metalsmith, done) {
var source = metalsmith.source();
// File system will be accessed for each element so iterate in parallel.
each(Object.keys(files), getAddMtime, done);
/**
* Gets mtime of given `file` and adds it to metadata.
*
* @param {String} file
* @param {Fu... | javascript | {
"resource": ""
} |
q38231 | getAddMtime | train | function getAddMtime(file, done) {
fs.stat(path.join(source, file), addMtime);
/**
* Adds `stats.mtime` of `file` to its metadata.
*
* @param {Error} err
* @param {fs.Stats} stats
* @api private
*/
function addMtime(err, stats) {
if (err) {
// Skip elements of ... | javascript | {
"resource": ""
} |
q38232 | addMtime | train | function addMtime(err, stats) {
if (err) {
// Skip elements of `files` that don't point to existing files.
// This can happen if some other Metalsmith plugin does something
// strange with `files`.
if (err.code === 'ENOENT') {
debug('file %s not found', file);
r... | javascript | {
"resource": ""
} |
q38233 | train | function(object, type, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
var fieldsType = type || {};
for (var i = 0, ii = fields.length; i < ii; ++i) {
var params = fieldsType[1] || {};
... | javascript | {
"resource": ""
} | |
q38234 | train | function(value, type, property, fields, object) {
if (_.isUndefined(value) || _.isNull(value)) {
return value;
}
var params = {};
if (_.isArray(type)) {
params = type[1] || {};
type = type[0];
}
if (!(type in this._types)) {
... | javascript | {
"resource": ""
} | |
q38235 | train | function(delimiter) {
if (!_.isString(delimiter) && !_.isRegExp(delimiter)) {
throw new Error('Delimiter must be a string or a regular expression!');
}
this._defaultArrayDelimiter = delimiter;
return this;
} | javascript | {
"resource": ""
} | |
q38236 | train | function(value, params, property) {
value = +value;
if ('min' in params && value < params.min) {
throw new Error('Value "' + value +
'" of property "' + property + '" must not be less then "' + params.min + '"!');
}
if ('max' in params... | javascript | {
"resource": ""
} | |
q38237 | train | function(value, params, property) {
value = ''+value;
if ('pattern' in params && !params.pattern.test(value)) {
throw new Error('Value "' + value +
'" of property "' + property + '" does not match pattern "' + params.pattern + '"!');
}
... | javascript | {
"resource": ""
} | |
q38238 | train | function(value, params, property) {
if (_.isNumber(value) && !isNaN(value)) {
value = new Date(value);
}
else if (_.isString(value)) {
value = new Date(Date.parse(value));
}
if (!(value instanceof Date)) {
throw... | javascript | {
"resource": ""
} | |
q38239 | train | function(value, params, property, fields, object) {
if (_.isString(value)) {
value = value.split(params.delimiter || this._defaultArrayDelimiter);
}
if ('element' in params) {
for (var i = 0, ii = value.length; i < ii; ++i) {
valu... | javascript | {
"resource": ""
} | |
q38240 | train | function(value, params, property, fields, object) {
var that = this;
if (!_.isSimpleObject(value)) {
throw new Error('Value of property "' +
[property].concat(fields).join('.') +'" must be a simple object!');
}
if ('keys' in params) {... | javascript | {
"resource": ""
} | |
q38241 | train | function(value, params, property, fields, object) {
if (!_.isObject(value)) {
throw new Error('Value of property "' + property + '" must be an object!');
}
if ('instanceOf' in params) {
var instanceOf = params.instanceOf;
var clazzCl... | javascript | {
"resource": ""
} | |
q38242 | removeExisting | train | function removeExisting ()
{
if (fs.existsSync("web/assets"))
{
var stat = fs.lstatSync("web/assets");
if (stat.isFile() || stat.isSymbolicLink())
{
fs.unlinkSync("web/assets");
}
else
{
wrench.rmdirSyncRecursive("web/assets");
}
... | javascript | {
"resource": ""
} |
q38243 | componentsHome | train | function componentsHome(workdir) {
var bowerrc = path.join(workdir, '.bowerrc'),
defaultHome = path.join(workdir, 'bower_components');
return (fs.existsSync(bowerrc) && require(bowerrc).directory) || defaultHome;
} | javascript | {
"resource": ""
} |
q38244 | componentName | train | function componentName(rawname) {
var name = rawname.split(':')[0],
index = name.replace('\\', '/').indexOf('/');
return (index > 0) ? name.substring(0, index) : name;
} | javascript | {
"resource": ""
} |
q38245 | componentNames | train | function componentNames(workdir) {
workdir = workdir || process.cwd();
try {
var bowerJson = require(path.join(workdir, 'bower.json'));
return _(Object.keys(bowerJson.dependencies || {}))
.union(Object.keys(bowerJson.devDependencies || {}))
.value();
} catch (ex) {
// not found bower
//console.warn(ex.... | javascript | {
"resource": ""
} |
q38246 | resolve | train | function resolve(name, workdir) {
workdir = workdir || process.cwd();
var compName = componentName(name),
subname = name.substring(compName.length + 1),
basedir = path.join(componentsHome(workdir), compName),
bowerJson = require(path.join(basedir, 'bower.json'));
var mainfile = Array.isArray(bowerJson.main)
... | javascript | {
"resource": ""
} |
q38247 | uglify | train | function uglify(js) {
return ugli.minify(js, {
fromString: true,
mangle: false,
compress: {
warnings: false
}
}).code;
} | javascript | {
"resource": ""
} |
q38248 | failsafe | train | function failsafe(code, tracer, serverId, msg, opts, cb) { // eslint-disable-line
const self = this;
const retryTimes = opts.retryTimes || constants.DEFAULT_PARAM.FAILSAFE_RETRIES;
const retryConnectTime = opts.retryConnectTime || constants.DEFAULT_PARAM.FAILSAFE_CONNECT_TIME;
if (!tracer.retryTimes)... | javascript | {
"resource": ""
} |
q38249 | process | train | function process( ctx, obj ) {
try {
if ( Array.isArray( obj ) ) return processArray( ctx, obj );
switch ( typeof obj ) {
case "string":
return processString( ctx, obj );
case "object":
return processObject( ctx, obj );
default:
return obj;... | javascript | {
"resource": ""
} |
q38250 | PubSub | train | function PubSub(stats) {
// ref to statistics so they can be updated
// as subscriptions change
this._stats = stats;
// normal channels
this._channels = {};
// pattern channels
this._patterns = {};
this._count = {
channels: {
total: 0, // total number of channels
subscribers: 0... | javascript | {
"resource": ""
} |
q38251 | getChannelList | train | function getChannelList(channels) {
var i
, channel
, list = [];
for(i = 0;i < channels.length;i++) {
channel = channels[i];
list.push(channel,
this._channels[channel] ? this._channels[channel].length : 0);
}
return list;
} | javascript | {
"resource": ""
} |
q38252 | getChannels | train | function getChannels(pattern) {
if(!pattern) return Object.keys(this._channels);
var re = (pattern instanceof RegExp) ? pattern : Pattern.compile(pattern)
, k
, list = [];
for(k in this._channels) {
if(re.test(k)) {
list.push(k);
}
}
return list;
} | javascript | {
"resource": ""
} |
q38253 | cleanup | train | function cleanup(client) {
if(client.pubsub
&& client.pubsub.channels
&& client.pubsub.patterns
&& !client.pubsub.channels.length
&& !client.pubsub.patterns.length) {
client.pubsub = null;
}
} | javascript | {
"resource": ""
} |
q38254 | generateHelp | train | function generateHelp(flags) {
var max = 0;
for (var group in flags) {
for (var i = 0; i < flags[group].length; i++) {
var n = 2; // ' '
if (flags[group][i].longFlag) {
n += 2; // '--'
n += flags[group][i].longFlag.length;
}
if (flags[group][i].longFlag && flags[group][i... | javascript | {
"resource": ""
} |
q38255 | isPositiveFiniteInteger | train | function isPositiveFiniteInteger(value, errorMessage) {
value = Number(value);
if (isNaN(value) || !isFinite(value) || value < 0 || value % 1 !== 0) {
throw new RangeError(errorMessage.replace('$', value));
}
return value;
} | javascript | {
"resource": ""
} |
q38256 | defineObservableProperty | train | function defineObservableProperty(target, property, originalValue) {
//we store the value in an non-enumerable property with generated unique name
var internalPropName = '_' + (uidCounter++) + property;
if (target.hasOwnProperty(property)) {
Object.defineProperty(target, internalPr... | javascript | {
"resource": ""
} |
q38257 | createKarmaTypescriptConfig | train | function createKarmaTypescriptConfig(tsconfigJson, coverageDir) {
return {
tsconfig: tsconfigJson,
coverageOptions: {
instrumentation: !isDebug()
},
reports: {
'cobertura': {
directory: coverageDir,
sub... | javascript | {
"resource": ""
} |
q38258 | Sprite | train | function Sprite( aElement, aProperties, aContent )
{
aProperties = aProperties || {};
var domElement = "div";
if ( aElement && typeof aElement !== "object" )
{
domElement = /** @type {string} */ ( aElement);
}
/* creates HTML element of requested tag type in the DOM */
if ( !aE... | javascript | {
"resource": ""
} |
q38259 | train | function( e )
{
var event = new Event( aType );
event.target = self;
event.srcEvent = e;
aHandler( event );
} | javascript | {
"resource": ""
} | |
q38260 | checkHeaderFromStream | train | function checkHeaderFromStream(file, ctx) {
file.contents.pipe(es.wait(function (err, data) {
if (err) {
throw err;
}
var bufferFile = new File({
path: file.path,
contents: data
});
checkHeaderFromBuffer(bufferFile, ctx);
}));
} | javascript | {
"resource": ""
} |
q38261 | checkHeaderFromBuffer | train | function checkHeaderFromBuffer(file, ctx) {
if (isLicenseHeaderPresent(file)) {
log(file.path, ctx);
} else {
error(file.path, ctx);
}
} | javascript | {
"resource": ""
} |
q38262 | readLicenseHeaderFile | train | function readLicenseHeaderFile() {
if (licenseFileUtf8) {
return licenseFileUtf8;
}
if (fs.existsSync(licenseFilePath)) {
return fs.readFileSync(licenseFilePath, 'utf8').split(/\r?\n/);
}
throw new gutil.PluginError('gulp-license-check', new Error('The license header file doesn`t exist ' + licenseFile... | javascript | {
"resource": ""
} |
q38263 | log | train | function log(filePath, ctx) {
if (isInfoLogActive) {
ctx.emit('log', {
msg: HEADER_PRESENT,
path: filePath
});
gutil.log(gutil.colors.green(HEADER_PRESENT), filePath);
}
} | javascript | {
"resource": ""
} |
q38264 | error | train | function error(filePath, ctx) {
if (isErrorBlocking) {
throw new gutil.PluginError('gulp-license-check', new Error('The following file doesn`t contain the license header ' + filePath));
} else {
logError(filePath, ctx);
}
} | javascript | {
"resource": ""
} |
q38265 | logError | train | function logError(filePath, ctx) {
if (isErrorLogActive) {
ctx.emit('log', {
msg: HEADER_NOT_PRESENT,
path: filePath
});
gutil.log(gutil.colors.red(HEADER_NOT_PRESENT), filePath);
}
} | javascript | {
"resource": ""
} |
q38266 | isLicenseHeaderPresent | train | function isLicenseHeaderPresent(currentFile) {
if (!isFileEmpty(currentFile.contents)) {
var currentFileUtf8 = readCurrentFile(currentFile),
licenseFileUtf8 = readLicenseHeaderFile(),
skipStrict = 0;
if(currentFileUtf8[0] === '"use strict";' ) {
skipStrict = 1;
}
for (var i = skipStrict; i <... | javascript | {
"resource": ""
} |
q38267 | getConfigFromLS | train | function getConfigFromLS() {
var configStr = localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)];
if (typeof configStr === 'undefined') {
return null;
}
else {
return JSON.parse(configStr);
}
} | javascript | {
"resource": ""
} |
q38268 | setConfigToLS | train | function setConfigToLS(configObj) {
var configStr = JSON.stringify(configObj);
window.localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)] = configStr;
} | javascript | {
"resource": ""
} |
q38269 | getInitialBrowserStorageState | train | function getInitialBrowserStorageState() {
var memorizedFile = getConfigFromLS()[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY];
return memorizedFile.map(function (memItem) {
var browserStorageValue = window[memItem.storageType]['getItem'](getFullBSKey(memItem.key));
if (browserSt... | javascript | {
"resource": ""
} |
q38270 | initFromScratch | train | function initFromScratch(cbsConfigFromFile) {
cbsConfigFromFile.initialState.forEach(function (item) { return saveItemToBrowserStorage(item); });
return _a = {},
_a[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY] = cbsConfigFromFile.initialState,
_a;
var _a;
} | javascript | {
"resource": ""
} |
q38271 | initExisting | train | function initExisting(cbsConfigFromFile, cbsConfigFromLS) {
// Restore items that have been manually removed by a user
restoreManuallyRemovedItems(cbsConfigFromLS);
var configFileDifferOptions = {
fileInitialState: cbsConfigFromFile.initialState,
memoryInitialState: cbsConfigFromLS[browser_s... | javascript | {
"resource": ""
} |
q38272 | restoreManuallyRemovedItems | train | function restoreManuallyRemovedItems(cbsConfigFromLS) {
cbsConfigFromLS[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY].map(function (memoryItem) {
var storageItemValue = getItemValueFromBrowserStorage(memoryItem);
// the storage item has been removed, put back from memory object
... | javascript | {
"resource": ""
} |
q38273 | percentBy | train | function percentBy(valueMapper) {
var valueSetter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return function (input) {
if (input.isEmpty()) {
return input;
}
var percents = input.map(valueMapper).update(percent());
if (!valueSetter) ... | javascript | {
"resource": ""
} |
q38274 | train | function(deltaTime){
var currentTime = new Date().getTime();
deltaTime = deltaTime || currentTime-this.lastUpdated;
//Ignore minor updates
if (deltaTime < 5){
return this;
}
deltaTime /= 1000; //convert to seconds
//... | javascript | {
"resource": ""
} | |
q38275 | train | function(posX, posY){
//Calculate the position deltas while account for zone boundaries
var zoneWidth = Constants.Zone.WIDTH;
var zoneHeight = Constants.Zone.HEIGHT;
var deltaX = posX - this.get("posX");
if (Math.abs(deltaX) > zoneWidth/2){
(... | javascript | {
"resource": ""
} | |
q38276 | readFileSync | train | function readFileSync (fileName, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if (info.exists === false) {
var message1 = format (cc.MSG_DOES_NOT_EXIST, fileName);
throw new SafeFileError (cc.DOES_NOT_EXIST, message1);
}
if (info.isFile === false) {
... | javascript | {
"resource": ""
} |
q38277 | writeFileSync | train | function writeFileSync (fileName, data, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if ((info.exists === true) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, message1);
}
... | javascript | {
"resource": ""
} |
q38278 | safeGetState | train | function safeGetState (fileName) {
if ((fileName === undefined) || (fileName === null)) {
return (cc.INVALID_NAME);
}
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
return (cc.IS_NOT_A_FILE);
}
va... | javascript | {
"resource": ""
} |
q38279 | safeRecover | train | function safeRecover (fileName) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, m... | javascript | {
"resource": ""
} |
q38280 | safeReadFileSync | train | function safeReadFileSync (fileName, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc... | javascript | {
"resource": ""
} |
q38281 | safeWriteFileSync | train | function safeWriteFileSync (fileName, data, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileEr... | javascript | {
"resource": ""
} |
q38282 | verifyFileName | train | function verifyFileName (fileName)
{
// if fileName undefined or null, throw exception
if ((fileName === undefined) || (fileName === null)) {
var message1 = format (cc.MSG_INVALID_NAME);
throw new SafeFileError (cc.INVALID_NAME, message1);
}
} | javascript | {
"resource": ""
} |
q38283 | getState | train | function getState (file) {
// collect state for all possible data and recovery files
var state = {};
state.ephemeral = getFileInfo (file + ".eph");
state.ready = getFileInfo (file + ".rdy");
state.base = getFileInfo (file);
state.backup = getFileInfo (file + ".bak");
state.tertiary = getFile... | javascript | {
"resource": ""
} |
q38284 | performRecovery | train | function performRecovery (state, removeEphemeral) {
// if ephemeral flag true, and ephemeral file exists, remove it
if ((removeEphemeral) && (state.ephemeral.exists)) {
fs.unlinkSync (state.ephemeral.name);
}
// if only backups exist, restore from backup
var baseAvailable = state.base.exist... | javascript | {
"resource": ""
} |
q38285 | train | function (daString) {
// stop shouting
daString = daString.replace(/^([A-Z]*)$/, function (match, c) {
return (c ? c.toLowerCase() : '')
})
// prepare camels for _
daString = daString.replace(/([A-Z])/g, function (match, c) {
return (c ? '_' + c : '')
})
// conv... | javascript | {
"resource": ""
} | |
q38286 | bootModel | train | function bootModel(trinte, schema, file) {
if (/\.js$/i.test(file)) {
var name = file.replace(/\.js$/i, '');
var modelDir = path.resolve(__dirname, '../app/models');
trinte.models[name] = require(modelDir + '/' + name)(schema);// Include the mongoose file
global[name] = trinte.models... | javascript | {
"resource": ""
} |
q38287 | convertUnit | train | function convertUnit (xUnit, mUnit, mVal) {
if (xUnit !== mUnit) {
if (mUnit === 'em') {
mVal = options.px_em_ratio * mVal;
}
if (xUnit === 'em') {
mVal = mVal/options.px_em_ratio;
}
}
return mVal;
} | javascript | {
"resource": ""
} |
q38288 | loadModules | train | function loadModules(dir, container, args) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var file = files[i];
var filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
container[file] = {};
loadModules(filePath, container[file], args);
... | javascript | {
"resource": ""
} |
q38289 | loadPlugins | train | function loadPlugins(pluginNames) {
if (pluginNames) {
pluginNames.forEach(function(pluginName) {
var pluginNamespace = util.getNamespace(pluginName),
pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),... | javascript | {
"resource": ""
} |
q38290 | CLIEngine | train | function CLIEngine(options) {
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
rules.load(rulesdir);
... | javascript | {
"resource": ""
} |
q38291 | train | function(name, pluginobject) {
var pluginNameWithoutPrefix = util.removePluginPrefix(util.removeNameSpace(name));
if (pluginobject.rules) {
rules.import(pluginobject.rules, pluginNameWithoutPrefix);
}
loadedPlugins[pluginNameWithoutPrefix] = pluginobject;
} | javascript | {
"resource": ""
} | |
q38292 | train | function(directory) {
if (!this.packageJSONFinder) {
this.packageJSONFinder = new FileFinder(PACKAGE_FILENAME);
}
return this.packageJSONFinder.findInDirectoryOrParentsSync(directory || process.cwd());
} | javascript | {
"resource": ""
} | |
q38293 | train | function(moduleName, deps, callback) {
//if (moduleName === "jquery/selector") { debugger; }
if (!deps && !callback) {
return;
}
// Allow deps to be optional.
if (!callback && typeof deps === "function") {
callback = deps;
deps = undefined;
}
// Ensure dependencies is never falsey.
deps = ... | javascript | {
"resource": ""
} | |
q38294 | ShockwaveFilter | train | function ShockwaveFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/shockwave.frag', 'utf8'),
// custom uniforms
{
center: { type: 'v2', value: { x: 0.5, y: 0.5 } },
params: { type... | javascript | {
"resource": ""
} |
q38295 | getExtensionlessFilename | train | function getExtensionlessFilename( filename ) {
return filename.substr( 0, filename.length - path.extname( filename ).length);
} | javascript | {
"resource": ""
} |
q38296 | templateWithArgs | train | function templateWithArgs( apiDir, apiName, apiFuncName ) {
cacheAPIs[apiName] = {
reg: (RegularCacheClient
.replace(/%%api.root%%/g,apiDir)
.replace(/%%api.name%%/g,apiName)
.replace(/%%api.funcs%%/g,JSON.stringify(apiFuncName))),
service: (ServiceCacheClient
.replace(/%%api.root%%/g,apiDir)
.repl... | javascript | {
"resource": ""
} |
q38297 | copyArgumentsArray | train | function copyArgumentsArray(args) {
var copy = [];
var index = 0;
for (var i in args) {
copy[index] = args[i];
index++;
}
return copy;
} | javascript | {
"resource": ""
} |
q38298 | readRawBody | train | function readRawBody(req,res,rawBodyCallback,callbackScope) {
if ( typeof req._body !== 'undefined' && req._body ) {
rawBodyCallback.call(callbackScope,req,res);
} else {
req.rawBody = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
req.rawBody += chunk;
});
req.on('end', ... | javascript | {
"resource": ""
} |
q38299 | ConfigError | train | function ConfigError(lineno, line, file, err) {
this.name = ConfigError.name;
Error.call(this);
var fmt = '*** FATAL CONFIG FILE ERROR ***%s';
fmt += 'Reading the configuration file, at line %s%s';
fmt += '>>> %s%s';
fmt += err && err.message && !(err instanceof TypeDefError) ? err.message :
'Bad direc... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.