_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q60500
|
stdCall
|
validation
|
function stdCall(options, call, args, cb) {
var val = '';
for (var key in args) {
val += '&' + encodeURIComponent(key) + '=' + encodeURIComponent(args[key]);
}
if (call !== undefined) {
call = '?command=' + call;
}
if (call === undefined) {
call = '';
}
if (val === undefined) {
val = '';
}
http.get({
hostname: 'localhost',
port: options.httpPort,
path: '/requests/status.json' + call + val,
auth: ':' + options.httpPassword,
agent: false
}, function(res) {
if (cb !== undefined) {
cb(res);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q60501
|
projectConfigAddPaths
|
validation
|
function projectConfigAddPaths(originalConfig) {
const config = originalConfig;
if (!Object.prototype.hasOwnProperty.call(config.paths.src, TASK_NAME)) {
config.paths.src[TASK_NAME] = `${config.dirs.src}/styles/`;
}
if (!Object.prototype.hasOwnProperty.call(config.paths.dest, TASK_NAME)) {
config.paths.dest[TASK_NAME] = `${config.dirs.dest}/styles/`;
}
return config;
}
|
javascript
|
{
"resource": ""
}
|
q60502
|
findHeader
|
validation
|
function findHeader(aoa) {
const {i} = aoa.reduce(
(prev, row, i) => {
const len = rowLength(row)
if (prev.len < len) {
return {i, len}
}
return prev
},
{i: -1, len: 0}
)
return i
}
|
javascript
|
{
"resource": ""
}
|
q60503
|
lookup
|
validation
|
function lookup(name, obj) {
for (const key in obj) {
const re = RegExp(key, 'i')
if (name.match(re)) {
return obj[key]
}
}
//else
return null
}
|
javascript
|
{
"resource": ""
}
|
q60504
|
isSsh
|
validation
|
function isSsh(input) {
if (Array.isArray(input)) {
return input.indexOf("ssh") !== -1 || input.indexOf("rsync") !== -1;
}
if (typeof input !== "string") {
return false;
}
var prots = protocols(input);
input = input.substring(input.indexOf("://") + 3);
if (isSsh(prots)) {
return true;
}
// TODO This probably could be improved :)
return input.indexOf("@") < input.indexOf(":");
}
|
javascript
|
{
"resource": ""
}
|
q60505
|
validation
|
function(options, cb) {
return doNpmCommand({
npmCommand: 'install',
cmdArgs: options.dependencies,
cmdOptions: {
production: options.production || false,
loglevel: options.loglevel || undefined,
save: options.save || false,
'save-dev': options.saveDev || false,
'save-exact': options.saveExact || false,
prefix: options.prefix || undefined,
},
dir: options.dir
}, cb);
}
|
javascript
|
{
"resource": ""
}
|
|
q60506
|
validation
|
function(){
var i = 0, len = SinonExpect.assertions.length,
matcher;
for(i, len; i < len; i++){
matcher = SinonExpect.assertions[i];
(function(matcher){
SinonExpect.SinonAssertions.prototype[matcher] = function(){
var args = Array.prototype.slice.call(arguments),
sinon = SinonExpect._sinon;
args.unshift(this.obj);
sinon.assert[matcher].apply(
sinon.assert,
args
);
};
}(matcher));
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60507
|
validation
|
function(thingy) {
// simple DOM lookup utility function
if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
if (!thingy.addClass) {
// extend element with a few useful methods
thingy.hide = function() { this.style.display = 'none'; };
thingy.show = function() { this.style.display = ''; };
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
thingy.removeClass = function(name) {
var classes = this.className.split(/\s+/);
var idx = -1;
for (var k = 0; k < classes.length; k++) {
if (classes[k] == name) { idx = k; k = classes.length; }
}
if (idx > -1) {
classes.splice( idx, 1 );
this.className = classes.join(' ');
}
return this;
};
thingy.hasClass = function(name) {
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
};
}
return thingy;
}
|
javascript
|
{
"resource": ""
}
|
|
q60508
|
validation
|
function(elem, appendElem, stylesToAdd) {
// glue to DOM element
// elem can be ID or actual DOM element object
this.domElement = ZeroClipboard.$(elem);
// float just above object, or zIndex 99 if dom element isn't set
var zIndex = 99;
if (this.domElement.style.zIndex) {
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
}
if (typeof(appendElem) == 'string') {
appendElem = ZeroClipboard.$(appendElem);
}
else if (typeof(appendElem) == 'undefined') {
appendElem = document.getElementsByTagName('body')[0];
}
// find X/Y position of domElement
var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
// create floating DIV above element
this.div = document.createElement('div');
var style = this.div.style;
style.position = 'absolute';
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
style.width = '' + box.width + 'px';
style.height = '' + box.height + 'px';
style.zIndex = zIndex;
style.left = '0px';
style.top = '0px';
if (typeof(stylesToAdd) == 'object') {
for (addedStyle in stylesToAdd) {
style[addedStyle] = stylesToAdd[addedStyle];
}
}
// style.backgroundColor = '#f00'; // debug
appendElem.appendChild(this.div);
this.div.innerHTML = this.getHTML( box.width, box.height );
}
|
javascript
|
{
"resource": ""
}
|
|
q60509
|
_full_delete
|
validation
|
function _full_delete(hash, key1, key2){
if( key1 && key2 && hash &&
hash[key1] && hash[key1][key2] ){
delete hash[key1][key2];
}
if( us.isEmpty(hash[key1]) ){
delete hash[key1];
}
}
|
javascript
|
{
"resource": ""
}
|
q60510
|
SocketTransport
|
validation
|
function SocketTransport(URL, options) {
if (!URL) {
throw new Error('A WebSocket URL must be passed to the SocketTransport constructor!');
}
if (!(this instanceof SocketTransport)) {
return new SocketTransport(URL, options);
}
/**
* The URL to use for connecting to the WebSocket server.
* Typically, it looks like "ws://host.tld/path", where path may be empty.
* @type {string}
*/
this._URL = URL;
/**
* A map of options to control the transport's behaviour.
*/
this._options = options || {};
/**
* The current socket object in use.
* Since WebSockets can not be re-used after they have been closed,
* this reference points to the current (i.e. most recent) socket in use.
* @type {?external:WebSocket}
*/
this._socket = null;
/**
* A descriptive state of the transport, for internal logic use.
* This controls the various state transitions.
* @type {string}
*/
this._state = 'unconnected';
/**
* Whether the transport is active.
* True means that the user intends to be connected.
* False is when the user has explicitly requested a connection shutdown.
* Inactive transports do not attempt reconnection when closed or when an error occurs.
* @type {boolean}
*/
this._active = false;
/**
* The reconnection timeout. Set when an unplanned disconnect occurs.
* It is cleared when _deactivate() is called.
*/
this._reconnectTimeout = null;
EventEmitter2.call(this);
/**
* We store a map of "standard listeners" - that is, functions that we are going
* to be adding as event listeners on WebSocket objects.
* This way, we have a reference to them, so we can do .removeEventListener().
* @type {Object.<string,function>}
*/
var self = this;
var listeners = {
open: function() {
self._handleOpen();
},
error: function(error) {
self._handleError(error);
},
close: function(closeEvent) {
self._handleDisconnect();
},
message: function(messageEvent) {
self.emit('message', messageEvent.data);
}
};
this._standardListeners = listeners;
}
|
javascript
|
{
"resource": ""
}
|
q60511
|
Commander
|
validation
|
function Commander(client, options) {
if (!(this instanceof Commander)) {
return new Commander(client, options);
}
EventEmitter2.call(this);
this.setMaxListeners(0);
options = options || {};
options.retryStrategy = options.retryStrategy || defaultRetry;
this._client = client;
this._options = options;
}
|
javascript
|
{
"resource": ""
}
|
q60512
|
addListElementFontSize
|
validation
|
function addListElementFontSize(element)
{
var hDataWeight = -9007199254740992;
var lDataWeight = 9007199254740992;
$.each(element.find("li"), function(){
cDataWeight = getDataWeight(this);
if (cDataWeight == undefined)
{
logWarning("No \"data-weight\" attribut defined on <li> element");
}
else
{
hDataWeight = cDataWeight > hDataWeight ? cDataWeight : hDataWeight;
lDataWeight = cDataWeight < lDataWeight ? cDataWeight : lDataWeight;
}
});
$.each(element.find("li"), function(){
var dataWeight = getDataWeight(this);
var percent = Math.abs((dataWeight - lDataWeight)/(lDataWeight - hDataWeight));
$(this).css('font-size', (1 + (percent * settings['multiplier'])) + "em");
});
}
|
javascript
|
{
"resource": ""
}
|
q60513
|
validation
|
function(direction, cloud_element) {
var start = $( '#cloudGraphPagingStart' ).val();
var rows = $( '#cloudGraphPagingRows' ).val();
var startAt = start ? parseInt(start) : 0;
var numRows = rows ? parseInt(rows) : 20;
var newStart = Math.max(startAt + (rows * direction),0);
$( '#cloudGraphPagingStart' ).val(newStart);
var graph_element = $( '#graph-content', cloud_element );
$( '#canvas', graph_element).empty();
init_graph( graph_element );
}
|
javascript
|
{
"resource": ""
}
|
|
q60514
|
doSubmit
|
validation
|
function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (form.getAttribute('method') != 'POST') {
form.setAttribute('method', 'POST');
}
if (form.getAttribute('action') != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (! s.skipEncodingOverride) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
setTimeout(function() { timedOut = true; cb(); }, s.timeout);
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
extraInputs.push(
$('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
.appendTo(form)[0]);
}
}
// add iframe to doc and submit the form
$io.appendTo('body');
$io.data('form-plugin-onload', cb);
form.submit();
}
finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action',a);
if(t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
|
javascript
|
{
"resource": ""
}
|
q60515
|
AppClient
|
validation
|
function AppClient(URL, options) {
if (!(this instanceof AppClient)) {
return new AppClient(URL, options);
}
options = options || {};
//TODO: Implement option passing.
var transport = options.transport || new SocketTransport(URL);
var RPC = options.RPC || new JSONRPC(transport);
var commander = options.commander || new Commander(RPC);
// Every time we manage to connect, all pending calls are retried:
transport.on('connect', function() {
setTimeout(function() {
commander.triggerRetries();
}, 10000 * Math.random());
});
// Make transport errors non-fatal:
transport.on('error', function() {});
//TODO: Listen for drop notifications and immediately reject all RPCs with an { isRetriable: true } error.
// Initialize getters so that all underlying resources may be conveniently accessed.
Object.defineProperties(this, {
transport: { enumerable: true, get: function() { return transport; } },
RPC: { enumerable: true, get: function() { return RPC; } },
commander: { enumerable: true, get: function() { return commander; } }
});
// Start the transport right away!
transport.start();
}
|
javascript
|
{
"resource": ""
}
|
q60516
|
writeTobuffer
|
validation
|
function writeTobuffer(value, buffer) {
write(buffer, value, OFFSET, LITTLE_ENDIAN, MANTISSA_LENGTH, NUMBER_OF_BYTES);
}
|
javascript
|
{
"resource": ""
}
|
q60517
|
buf2hex
|
validation
|
function buf2hex(buffer, options = { prefix: true }) {
var hex = Array.prototype.map
.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2))
.join('');
return options.prefix === true ? `0x${hex}` : hex;
}
|
javascript
|
{
"resource": ""
}
|
q60518
|
num2hex
|
validation
|
function num2hex(value, options) {
if (value === undefined) throw new Error('Value is undefined');
var buffer = Buffer.alloc(NUMBER_OF_BYTES);
writeTobuffer(value, buffer);
return buf2hex(buffer, options);
}
|
javascript
|
{
"resource": ""
}
|
q60519
|
hex2num
|
validation
|
function hex2num(value) {
if (value === undefined) throw new Error('Value is undefined');
var buffer = hex2buf(value);
return readFromBuffer(buffer);
}
|
javascript
|
{
"resource": ""
}
|
q60520
|
validation
|
function () {
var f = $.jstree._focused();
if(f && f !== this) {
f.get_container().removeClass("jstree-focused");
}
if(f !== this) {
this.get_container().addClass("jstree-focused");
focused_instance = this.get_index();
}
this.__callback();
}
|
javascript
|
{
"resource": ""
}
|
|
q60521
|
validation
|
function() {
var json = {};
$.each(this, function(k,v) {
if (!_isFunction(v)) {
json[k] = v;
}
});
return json;
}
|
javascript
|
{
"resource": ""
}
|
|
q60522
|
validation
|
function() {
var proxy = this, app = this.app;
$(window).bind('hashchange.' + this.app.eventNamespace(), function(e, non_native) {
// if we receive a native hash change event, set the proxy accordingly
// and stop polling
if (proxy.is_native === false && !non_native) {
Sammy.log('native hash change exists, using');
proxy.is_native = true;
window.clearInterval(Sammy.HashLocationProxy._interval);
}
app.trigger('location-changed');
});
if (!Sammy.HashLocationProxy._bindings) {
Sammy.HashLocationProxy._bindings = 0;
}
Sammy.HashLocationProxy._bindings++;
}
|
javascript
|
{
"resource": ""
}
|
|
q60523
|
validation
|
function() {
$(window).unbind('hashchange.' + this.app.eventNamespace());
Sammy.HashLocationProxy._bindings--;
if (Sammy.HashLocationProxy._bindings <= 0) {
window.clearInterval(Sammy.HashLocationProxy._interval);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60524
|
validation
|
function(verb, path) {
var app = this, routed = false;
this.trigger('lookup-route', {verb: verb, path: path});
if (typeof this.routes[verb] != 'undefined') {
$.each(this.routes[verb], function(i, route) {
if (app.routablePath(path).match(route.path)) {
routed = route;
return false;
}
});
}
return routed;
}
|
javascript
|
{
"resource": ""
}
|
|
q60525
|
validation
|
function(location, name, data, callback) {
if (_isArray(name)) {
callback = data;
data = name;
name = null;
}
return this.load(location).then(function(content) {
var rctx = this;
if (!data) {
data = _isArray(this.previous_content) ? this.previous_content : [];
}
if (callback) {
$.each(data, function(i, value) {
var idata = {}, engine = this.next_engine || location;
name ? (idata[name] = value) : (idata = value);
callback(value, rctx.event_context.interpolate(content, idata, engine));
});
} else {
return this.collect(data, function(i, value) {
var idata = {}, engine = this.next_engine || location;
name ? (idata[name] = value) : (idata = value);
return this.event_context.interpolate(content, idata, engine);
}, true);
}
});
}
|
javascript
|
{
"resource": ""
}
|
|
q60526
|
validation
|
function(name, data) {
if (typeof data == 'undefined') { data = {}; }
if (!data.context) { data.context = this; }
return this.app.trigger(name, data);
}
|
javascript
|
{
"resource": ""
}
|
|
q60527
|
validation
|
function(partialPath, locals) {
var normalizedPartialPath = normalizeTemplatePath(partialPath, path.dirname(normalizedTemplatePath));
return exports.compile(normalizedPartialPath)(locals);
}
|
javascript
|
{
"resource": ""
}
|
|
q60528
|
validation
|
function(type, content, textAfter, state) {
if (this.jsonMode) {
return /^[\[,{]$/.test(content) || /^}/.test(textAfter);
} else {
if (content == ";" && state.lexical && state.lexical.type == ")") return false;
return /^[;{}]$/.test(content) && !/^;/.test(textAfter);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60529
|
enteringString
|
validation
|
function enteringString(cm, pos, ch) {
var line = cm.getLine(pos.line);
var token = cm.getTokenAt(pos);
if (/\bstring2?\b/.test(token.type)) return false;
var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4);
stream.pos = stream.start = token.start;
for (;;) {
var type1 = cm.getMode().token(stream, token.state);
if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1);
stream.start = stream.pos;
}
}
|
javascript
|
{
"resource": ""
}
|
q60530
|
resolve
|
validation
|
function resolve(paths){
paths = Array.isArray(paths) ? paths : [ paths ];
var fullPath = path.resolve.apply(this, paths).replace(/\\/g, '/');
return {
fullPath: fullPath,
dirName: path.dirname(fullPath),
fileName: path.basename(fullPath),
extName: path.extname(fullPath).replace('.','')
};
}
|
javascript
|
{
"resource": ""
}
|
q60531
|
existsOrCreate
|
validation
|
function existsOrCreate(filePath, opts, cb){
if(arguments.length===2){
cb = arguments[1];
opts = {};
}
opts.encoding = opts.encoding || 'utf8';
opts.data = opts.data || opts.content || '';
opts.mode = opts.mode || '0777';
opts.replace = opts.replace ? true : false;
var fp = resolve(filePath);
var isFile = opts.hasOwnProperty('isFile') ? opts.isFile : !!fp.extName;
fs.exists(fp.fullPath, function(exists){
if(exists && !opts.replace) cb(null, exists);
else {
// file doesn't exists, create folder first
mkdirp((isFile ? fp.dirName : fp.fullPath), opts.mode, function(err) {
if (err) cb(new Error('fsExt.existsOrCreate: creating folders failed').cause(err));
else if(isFile || opts.replace){
// folders are created, so create file
fs.writeFile(fp.fullPath, opts.data, opts.encoding, function(err){
if (err) cb(new Error('fsExt.existsOrCreate: creating file failed').cause(err));
else cb(null, exists);
});
}
else cb(null, exists);
});
}
});
}
|
javascript
|
{
"resource": ""
}
|
q60532
|
existsOrCreateSync
|
validation
|
function existsOrCreateSync(filePath, opts){
opts = opts || {};
opts.encoding = opts.encoding || 'utf8';
opts.data = opts.data || opts.content || '';
opts.mode = opts.mode || '0777';
var fp = resolve(filePath);
var isFile = opts.hasOwnProperty('isFile') ? opts.isFile : !!fp.extName;
var exists = fs.existsSync(fp.fullPath);
if(!exists || opts.replace){
mkdir((isFile ? fp.dirName : fp.fullPath));
if(isFile || opts.replace) fs.writeFileSync(fp.fullPath, opts.data, opts.encoding);
}
function mkdir(fullPath){
if(fs.existsSync(fullPath)) return;
else {
var parentPath = fullPath.split('/');
parentPath.pop();
mkdir(parentPath.join('/'));
fs.mkdirSync(fullPath, opts.mode);
}
}
return exists;
}
|
javascript
|
{
"resource": ""
}
|
q60533
|
unwatchAll
|
validation
|
function unwatchAll(){
for(var filePath in _fileWatchers) {
if(_fileWatchers[filePath]) _fileWatchers[filePath].close();
delete _fileWatchers[filePath];
}
for(var dirPath in _dirWatchers) {
if(_dirWatchers[dirPath]) _dirWatchers[dirPath].close();
delete _dirWatchers[dirPath];
}
}
|
javascript
|
{
"resource": ""
}
|
q60534
|
writeFile
|
validation
|
function writeFile(filePath, data, callback, count){ // callback(err)
if(typeof callback !== 'function') throw new Error('Wrong arguments');
filePath = path.resolve(filePath);
count = count || 0;
var maxLimit = 5; // 5 * 500ms = 2,5s
fs.writeFile(filePath, data, function(err) {
if(err) {
if(count >= maxLimit) callback(new Error('fsExt.writeFile: max repeat limit reached').cause(err)); // repeat limit reached
else setTimeout(function(){
writeFile(filePath, data, callback, count + 1);
}, 500);
}
else callback();
});
}
|
javascript
|
{
"resource": ""
}
|
q60535
|
readFile
|
validation
|
function readFile(filePath, opts, callback, count){ // callback(err)
if(arguments.length===2){
callback = arguments[1];
opts = null;
}
if(typeof callback !== 'function') throw new Error('Wrong arguments');
filePath = path.resolve(filePath);
count = count || 0;
var maxLimit = 5; // 5 * 500ms = 2,5s
fs.readFile(filePath, opts, function(err, data) {
if(err) {
if(count >= maxLimit) callback(new Error('fsExt.readFie: max repeat limit reached').cause(err)); // repeat limit reached
else setTimeout(function(){
readFile(filePath, opts, callback, count + 1);
}, 500);
}
else callback(null, data);
});
}
|
javascript
|
{
"resource": ""
}
|
q60536
|
getFileInfo
|
validation
|
function getFileInfo(fileId, filePath, cb, repeated){ // cb(err, fileInfo)
repeated = repeated || 0;
var fullPath = resolve(filePath).fullPath;
fs.exists(fullPath, function(exists){
if(!exists) cb();
else fs.stat(fullPath, function(err, stat){
if(err && err.code === 'ENOENT') { // directory or file removed, just skip it
cb();
}
else if(err && repeated < 5) setTimeout(function(){
getFileInfo(fileId, fullPath, cb, repeated+1);
}, 200);
else if(err) cb(err);
else cb(null, getFileItem(fileId, stat, fullPath));
});
});
}
|
javascript
|
{
"resource": ""
}
|
q60537
|
getPathAncestors
|
validation
|
function getPathAncestors(filename){
var tree = filename.split('/');
tree.pop(); // remove last
var treePath = [];
for(var i=0;i<tree.length;i++){
treePath.push(createId(tree, i));
}
function createId(tree, count){
var id = '';
for(var i=0;i<=count;i++){
id += (i>0 ? '/' : '') + tree[i];
}
return id;
}
return treePath;
}
|
javascript
|
{
"resource": ""
}
|
q60538
|
getName
|
validation
|
function getName(fileId, isFile){
var splitted = fileId.split('/'); // get filename
var filename = splitted[splitted.length - 1]; // get file name
if(!isFile) return filename;
filename = filename.split('.');
if(filename.length === 1) return filename[0]; // file has no extension
filename.pop(); // remove extension if it has one
return filename.join('.');
}
|
javascript
|
{
"resource": ""
}
|
q60539
|
getExt
|
validation
|
function getExt(filename){
var splitted = filename.split('.');
if(splitted.length === 1) return ''; // file has no extension
return splitted[splitted.length - 1]; // get file extension
}
|
javascript
|
{
"resource": ""
}
|
q60540
|
getFileItem
|
validation
|
function getFileItem(fileId, stat, filePath){
return {
id:fileId,
fullPath: filePath,
name: getName(fileId, !stat.isDirectory()),
ancestors: getPathAncestors(fileId),
isDir:stat.isDirectory(),
isFile:!stat.isDirectory(),
ext:!stat.isDirectory() ? getExt(fileId) : null,
modifiedDT: stat.mtime, // (stat.ctime.getTime() > stat.mtime.getTime()) ? stat.ctime : stat.mtime,
createdDT: stat.birthtime,
size: stat.size
};
}
|
javascript
|
{
"resource": ""
}
|
q60541
|
getDirChildren
|
validation
|
function getDirChildren(parentId, items){
var children = {};
for(var id in items){
if(items[id].ancestors[ items[id].ancestors.length-1 ] === parentId)
children[id] = items[id];
}
return children;
}
|
javascript
|
{
"resource": ""
}
|
q60542
|
compareDirFiles
|
validation
|
function compareDirFiles(parentId, old_children, descendants){
var changes = [],
not_found = object.extend({}, old_children);
for(var id in descendants) {
if(descendants[id].ancestors[ descendants[id].ancestors.length-1 ] === parentId) { // compare only direct children
if(!old_children[id]) { // not found in current children - created
changes.push({ event:'created', file:descendants[id] });
old_children[id] = descendants[id];
}
else if(old_children[id].modifiedDT < descendants[id].modifiedDT) { // found and updated
changes.push({ event:'updated', file:descendants[id] });
old_children[id] = descendants[id];
delete not_found[id];
}
else { // file found, not not updated
delete not_found[id];
}
}
}
// removed files
for(var id in not_found) {
changes.push({ event:'removed', file:not_found[id] });
delete old_children[id];
}
return changes;
}
|
javascript
|
{
"resource": ""
}
|
q60543
|
validation
|
function(fn, ctx) {
var task = !ctx ? fn : fn.bind(ctx);
this.reads.push(task);
scheduleFlush(this);
return task;
}
|
javascript
|
{
"resource": ""
}
|
|
q60544
|
validation
|
function(fn, ctx) {
var task = !ctx ? fn : fn.bind(ctx);
this.writes.push(task);
scheduleFlush(this);
return task;
}
|
javascript
|
{
"resource": ""
}
|
|
q60545
|
validation
|
function(props) {
if (typeof props != 'object') { throw new Error('expected object'); }
var child = Object.create(this);
mixin(child, props);
child.fastdom = this;
// run optional creation hook
if (child.initialize) { child.initialize(); }
return child;
}
|
javascript
|
{
"resource": ""
}
|
|
q60546
|
flush
|
validation
|
function flush(fastdom) {
var reads = fastdom.reads.splice(0, fastdom.reads.length),
writes = fastdom.writes.splice(0, fastdom.writes.length),
error;
try {
runTasks(reads);
runTasks(writes);
} catch (e) { error = e; }
fastdom.scheduled = false;
// If the batch errored we may still have tasks queued
if (fastdom.reads.length || fastdom.writes.length) { scheduleFlush(fastdom); }
if (error) {
if (fastdom.catch) { fastdom.catch(error); }
else { throw error; }
}
}
|
javascript
|
{
"resource": ""
}
|
q60547
|
create
|
validation
|
function create(props) {
var knob = Object.create(this);
// apply Widget defaults, then overwrite (if applicable) with Knob defaults
_canvasWidget2.default.create.call(knob);
// ...and then finally override with user defaults
Object.assign(knob, Knob.defaults, props);
// set underlying value if necessary... TODO: how should this be set given min/max?
if (props.value) knob.__value = props.value;
// inherits from Widget
knob.init();
return knob;
}
|
javascript
|
{
"resource": ""
}
|
q60548
|
processPointerPosition
|
validation
|
function processPointerPosition(e) {
var xOffset = e.clientX,
yOffset = e.clientY;
var radius = this.rect.width / 2;
this.lastValue = this.value;
if (!this.usesRotation) {
if (this.lastPosition !== -1) {
//this.__value -= ( yOffset - this.lastPosition ) / (radius * 2);
this.__value = 1 - yOffset / this.rect.height;
}
} else {
var xdiff = radius - xOffset;
var ydiff = radius - yOffset;
var angle = Math.PI + Math.atan2(ydiff, xdiff);
this.__value = (angle + Math.PI * 1.5) % (Math.PI * 2) / (Math.PI * 2);
if (this.lastRotationValue > .8 && this.__value < .2) {
this.__value = 1;
} else if (this.lastRotationValue < .2 && this.__value > .8) {
this.__value = 0;
}
}
if (this.__value > 1) this.__value = 1;
if (this.__value < 0) this.__value = 0;
this.lastRotationValue = this.__value;
this.lastPosition = yOffset;
var shouldDraw = this.output();
if (shouldDraw) this.draw();
}
|
javascript
|
{
"resource": ""
}
|
q60549
|
setContextValue
|
validation
|
function setContextValue(setChainContext, chainId, name, value) {
if (value instanceof Function) {
throw new FunctionAsValueException();
}
setChainContext(chainId, name, value);
}
|
javascript
|
{
"resource": ""
}
|
q60550
|
recurse
|
validation
|
function recurse(node) {
// first navigate to the first sibling
if (node.previousSibling) recurse(node.previousSibling);
// then add the string representation of the nodes ('backward' recursion)
switch (node.nodeType) {
case 8: // comment
html += "<!--" + node.nodeValue + "-->";
break;
// case 10: // doctype: jsDom does not know doctype as previousSibling.
}
}
|
javascript
|
{
"resource": ""
}
|
q60551
|
validation
|
function(url, prev, done) {
if (url.indexOf('bootstrap/') === 0) {
var component = url.substr('bootstrap/'.length+1);
var file = cmsDir+'/src/scss/bootstrap/_'+component+'.scss';
try {
var stats = fs.lstatSync(file);
if (stats.isFile()) {
return { file: file };
}
} catch (ex) {
// file does not exist
}
}
return sass.compiler.NULL; // do nothing
}
|
javascript
|
{
"resource": ""
}
|
|
q60552
|
streamToBuffer
|
validation
|
function streamToBuffer(stream, cb){ // cb(err, buffer);
var bufs = [];
stream.on('data', function(d){
bufs.push(d);
})
.on('end', function(){
cb(null, Buffer.concat(bufs));
})
.on('error', function(err){
cb(err);
});
}
|
javascript
|
{
"resource": ""
}
|
q60553
|
Bucks
|
validation
|
function Bucks(params) {
this._tasks = [];
this._taskcount = 0;
this._results = [];
this.callback = none;
this.failure = none;
this._alive = true;
this._interrupt = false;
this.__id = uid();
Bucks.living[this.__id] = this;
this.initialize(params);
}
|
javascript
|
{
"resource": ""
}
|
q60554
|
cached
|
validation
|
function cached(opt) {
if (typeof opt == 'undefined' || opt === null) opt = {};
if (typeof opt == 'string') opt = {type:opt};
if (typeof opt.id != 'string') opt.id = _random_string(8);
opt = Object.assign({}, getSettings(), opt);
for (var i in opt) checkSetting(i, opt[i]);
return function (func, key, descriptor) {
if (key) func = func[key]; //for ES6 notation
const f = function (...rest) {
const _key = _hash(rest, opt.id);
return cacheObj.get(opt, _key)
.then(res => {
if (typeof res == 'undefined' || res === null) {
res = _update.bind(this)(opt, func, rest);
}
return res;
});
}
f.forceUpdate = function(...rest){
_update.bind(this, opt, func)(rest)
}
if (key) {
//ES6 notation
descriptor.value = f;
} else {
//vanilla js notation
return f;
}
}
}
|
javascript
|
{
"resource": ""
}
|
q60555
|
validation
|
function (...rest) {
const _key = _hash(rest, opt.id);
return cacheObj.get(opt, _key)
.then(res => {
if (typeof res == 'undefined' || res === null) {
res = _update.bind(this)(opt, func, rest);
}
return res;
});
}
|
javascript
|
{
"resource": ""
}
|
|
q60556
|
getChain
|
validation
|
function getChain(storage, name) {
if (storage[GET_CHAIN_METHOD]) {
return storage[GET_CHAIN_METHOD](name);
}
var chain = Object.assign({}, storage[name]);
chain['$chainId'] = (0, _Util.generateUUID)();
return Object.assign({}, chain);
}
|
javascript
|
{
"resource": ""
}
|
q60557
|
getChainDataById
|
validation
|
function getChainDataById(storage, chainId) {
if (storage[GET_CHAIN_METHOD]) {
return storage[GET_CHAIN_METHOD](chainId);
}
return storage[chainId];
}
|
javascript
|
{
"resource": ""
}
|
q60558
|
getChainContext
|
validation
|
function getChainContext(storage, chainId, field) {
if (storage[GET_CHAIN_CONTEXT_METHOD]) {
return storage[GET_CHAIN_CONTEXT_METHOD](chainId, field);
}
if (storage[chainId]) {
return storage[chainId][field];
}
}
|
javascript
|
{
"resource": ""
}
|
q60559
|
create
|
validation
|
function create(props) {
var multiButton = Object.create(this);
_canvasWidget2.default.create.call(multiButton);
Object.assign(multiButton, MultiButton.defaults, props);
if (props.value) {
multiButton.__value = props.value;
} else {
multiButton.__value = [];
for (var i = 0; i < multiButton.count; i++) {
multiButton.__value[i] = 0;
}multiButton.value = [];
}
multiButton.active = {};
multiButton.__prevValue = [];
multiButton.init();
return multiButton;
}
|
javascript
|
{
"resource": ""
}
|
q60560
|
mkSprite
|
validation
|
function mkSprite(srcFiles, destImage, options, callback) {
options.src = srcFiles,
grunt.verbose.writeln('Options passed to Spritesmth:', JSON.stringify(options));
spritesmith(options, function(err, result) {
// If an error occurred, callback with it
if (err) {
grunt.fatal(err);
return;
}
// Otherwise, write out the result to destImg
var destDir = path.dirname(destImage);
grunt.file.mkdir(destDir);
fs.writeFileSync(destImage, result.image, 'binary');
grunt.log.writeln(destImage, 'created.');
callback(result.coordinates);
});
}
|
javascript
|
{
"resource": ""
}
|
q60561
|
hasPath
|
validation
|
function hasPath(object, path, hasFunc) {
path = isKey$1(path, object) ? [path] : castPath$1(path);
var result,
index = -1,
length = path.length;
while (++index < length) {
var key = toKey$1(path[index]);
if (!(result = object != null && hasFunc(object, key))) {
break;
}
object = object[key];
}
if (result) {
return result;
}
var length = object ? object.length : 0;
return !!length && isLength(length) && isIndex(key, length) &&
(isArray$1(object) || isArguments(object));
}
|
javascript
|
{
"resource": ""
}
|
q60562
|
baseSet
|
validation
|
function baseSet(object, path, value, customizer) {
if (!isObject$2(object)) {
return object;
}
path = isKey$2(path, object) ? [path] : castPath$2(path);
var index = -1,
length = path.length,
lastIndex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = toKey$2(path[index]),
newValue = value;
if (index != lastIndex) {
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) {
newValue = isObject$2(objValue)
? objValue
: (isIndex$1(path[index + 1]) ? [] : {});
}
}
assignValue(nested, key, newValue);
nested = nested[key];
}
return object;
}
|
javascript
|
{
"resource": ""
}
|
q60563
|
mixin
|
validation
|
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
|
javascript
|
{
"resource": ""
}
|
q60564
|
isString
|
validation
|
function isString(value) {
return typeof value == 'string' ||
(!isArray$3(value) && isObjectLike$4(value) && objectToString$4.call(value) == stringTag);
}
|
javascript
|
{
"resource": ""
}
|
q60565
|
arrayIncludes
|
validation
|
function arrayIncludes(array, value) {
var length = array ? array.length : 0;
return !!length && baseIndexOf(array, value, 0) > -1;
}
|
javascript
|
{
"resource": ""
}
|
q60566
|
baseIndexOf
|
validation
|
function baseIndexOf(array, value, fromIndex) {
if (value !== value) {
return baseFindIndex(array, baseIsNaN, fromIndex);
}
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
|
javascript
|
{
"resource": ""
}
|
q60567
|
countHolders
|
validation
|
function countHolders(array, placeholder) {
var length = array.length,
result = 0;
while (length--) {
if (array[length] === placeholder) {
result++;
}
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q60568
|
createRecurry
|
validation
|
function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials;
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
}
var result = wrapFunc(func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, newHoldersRight, argPos, ary, arity);
result.placeholder = placeholder;
return setWrapToString(result, func, bitmask);
}
|
javascript
|
{
"resource": ""
}
|
q60569
|
insertWrapDetails
|
validation
|
function insertWrapDetails(source, details) {
var length = details.length,
lastIndex = length - 1;
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
details = details.join(length > 2 ? ', ' : ' ');
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
}
|
javascript
|
{
"resource": ""
}
|
q60570
|
toFinite
|
validation
|
function toFinite(value) {
if (!value) {
return value === 0 ? value : 0;
}
value = toNumber(value);
if (value === INFINITY$3 || value === -INFINITY$3) {
var sign = (value < 0 ? -1 : 1);
return sign * MAX_INTEGER;
}
return value === value ? value : 0;
}
|
javascript
|
{
"resource": ""
}
|
q60571
|
toNumber
|
validation
|
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol$3(value)) {
return NAN;
}
if (isObject$4(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject$4(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
|
javascript
|
{
"resource": ""
}
|
q60572
|
arrayLikeKeys
|
validation
|
function arrayLikeKeys(value, inherited) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
// Safari 9 makes `arguments.length` enumerable in strict mode.
var result = (isArray$4(value) || isArguments$1(value))
? baseTimes(value.length, String)
: [];
var length = result.length,
skipIndexes = !!length;
for (var key in value) {
if ((inherited || hasOwnProperty$6.call(value, key)) &&
!(skipIndexes && (key == 'length' || isIndex$3(key, length)))) {
result.push(key);
}
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q60573
|
assignInDefaults
|
validation
|
function assignInDefaults(objValue, srcValue, key, object) {
if (objValue === undefined ||
(eq$3(objValue, objectProto$7[key]) && !hasOwnProperty$6.call(object, key))) {
return srcValue;
}
return objValue;
}
|
javascript
|
{
"resource": ""
}
|
q60574
|
baseRest
|
validation
|
function baseRest(func, start) {
start = nativeMax$1(start === undefined ? (func.length - 1) : start, 0);
return function() {
var args = arguments,
index = -1,
length = nativeMax$1(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = array;
return apply$1(func, this, otherArgs);
};
}
|
javascript
|
{
"resource": ""
}
|
q60575
|
isIndex$3
|
validation
|
function isIndex$3(value, length) {
length = length == null ? MAX_SAFE_INTEGER$3 : length;
return !!length &&
(typeof value == 'number' || reIsUint$3.test(value)) &&
(value > -1 && value % 1 == 0 && value < length);
}
|
javascript
|
{
"resource": ""
}
|
q60576
|
isIterateeCall
|
validation
|
function isIterateeCall(value, index, object) {
if (!isObject$5(object)) {
return false;
}
var type = typeof index;
if (type == 'number'
? (isArrayLike$1(object) && isIndex$3(index, object.length))
: (type == 'string' && index in object)
) {
return eq$3(object[index], value);
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
q60577
|
getRawTag$1
|
validation
|
function getRawTag$1(value) {
var isOwn = hasOwnProperty$7.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
} catch (e) {}
var result = nativeObjectToString$1.call(value);
{
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q60578
|
baseGetTag$1
|
validation
|
function baseGetTag$1(value) {
if (value == null) {
return value === undefined ? undefinedTag$1 : nullTag$1;
}
return (symToStringTag$2 && symToStringTag$2 in Object(value))
? _getRawTag(value)
: _objectToString(value);
}
|
javascript
|
{
"resource": ""
}
|
q60579
|
hashDelete$3
|
validation
|
function hashDelete$3(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
|
javascript
|
{
"resource": ""
}
|
q60580
|
mapCacheSet$3
|
validation
|
function mapCacheSet$3(key, value) {
var data = _getMapData(this, key),
size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
|
javascript
|
{
"resource": ""
}
|
q60581
|
castPath$3
|
validation
|
function castPath$3(value, object) {
if (isArray_1(value)) {
return value;
}
return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
}
|
javascript
|
{
"resource": ""
}
|
q60582
|
get$2
|
validation
|
function get$2(object, path, defaultValue) {
var result = object == null ? undefined : _baseGet(object, path);
return result === undefined ? defaultValue : result;
}
|
javascript
|
{
"resource": ""
}
|
q60583
|
validation
|
function(savePath, consolidate, useDotNotation, filePrefix, consolidateAll) {
this.savePath = savePath || '';
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
this.consolidateAll = consolidateAll === jasmine.undefined ? false : consolidateAll;
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
this.filePrefix = filePrefix || (this.consolidateAll ? 'junitresults' : 'TEST-');
}
|
javascript
|
{
"resource": ""
}
|
|
q60584
|
attachLibraryToSelf
|
validation
|
function attachLibraryToSelf () {
for(var i in libs)
if(libs.hasOwnProperty(i) && !self[i]) self[i] = libs[i];
return self;
}
|
javascript
|
{
"resource": ""
}
|
q60585
|
applyLibraryToPrototypes
|
validation
|
function applyLibraryToPrototypes () {
if(!attached) {
Object.defineProperty(Object.prototype, handle, {
configurable : true,
enumerable : false,
// Allow users to overwrite the handle on a per instance basis...
set: function (v) {
if(this[handle] !== v) {
Object.defineProperty(this, handle, {
configurable : true,
enumerable : true,
writable : true,
value : v
});
}
},
// Returns the libp library...
get: function () {
var ccId,
proto = getProto(this),
cId = proto.constructor.__get_protolib_id__,
lib = {},
i = 0,
last = null,
m;
currentThis = this;
do {
ccId = proto.constructor.__get_protolib_id__;
if(cached[ccId] && i === 0) {
return cached[ccId];
}
else if(cached[ccId]) {
for(m in cached[ccId])
if(cached[ccId].hasOwnProperty(m)) lib[m] = cached[ccId][m];
if(!inheritanceChain[cId]) inheritanceChain[cId] = [];
inheritanceChain[cId] = inheritanceChain[ccId].concat(inheritanceChain[cId]);
cached[cId] = lib;
return lib;
}
else {
if(!libp[ccId]) libp[ccId] = {};
for(m in libp[ccId])
if(libp[ccId].hasOwnProperty(m)) lib[m] = libp[ccId][m];
if(!inheritanceChain[ccId]) inheritanceChain[ccId] = [];
inheritanceChain[cId].unshift(ccId);
cached[cId] = lib;
last = ccId;
}
++i;
}
while (proto = getProto(proto)); // jshint ignore:line
lib.__protolib_cId__ = cId;
return lib;
}
});
attached = true;
}
return self;
}
|
javascript
|
{
"resource": ""
}
|
q60586
|
validation
|
function (v) {
if(this[handle] !== v) {
Object.defineProperty(this, handle, {
configurable : true,
enumerable : true,
writable : true,
value : v
});
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60587
|
validation
|
function () {
var ccId,
proto = getProto(this),
cId = proto.constructor.__get_protolib_id__,
lib = {},
i = 0,
last = null,
m;
currentThis = this;
do {
ccId = proto.constructor.__get_protolib_id__;
if(cached[ccId] && i === 0) {
return cached[ccId];
}
else if(cached[ccId]) {
for(m in cached[ccId])
if(cached[ccId].hasOwnProperty(m)) lib[m] = cached[ccId][m];
if(!inheritanceChain[cId]) inheritanceChain[cId] = [];
inheritanceChain[cId] = inheritanceChain[ccId].concat(inheritanceChain[cId]);
cached[cId] = lib;
return lib;
}
else {
if(!libp[ccId]) libp[ccId] = {};
for(m in libp[ccId])
if(libp[ccId].hasOwnProperty(m)) lib[m] = libp[ccId][m];
if(!inheritanceChain[ccId]) inheritanceChain[ccId] = [];
inheritanceChain[cId].unshift(ccId);
cached[cId] = lib;
last = ccId;
}
++i;
}
while (proto = getProto(proto)); // jshint ignore:line
lib.__protolib_cId__ = cId;
return lib;
}
|
javascript
|
{
"resource": ""
}
|
|
q60588
|
removeLibraryFromPrototypes
|
validation
|
function removeLibraryFromPrototypes () {
Object.defineProperty(Object.prototype, handle, { value: undefined });
delete Object.prototype[handle];
attached = false;
return self;
}
|
javascript
|
{
"resource": ""
}
|
q60589
|
getThisValueAndInvoke
|
validation
|
function getThisValueAndInvoke (callback) {
return callback(currentThis !== undefined && currentThis !== null ?
(typeof currentThis === 'object' ? currentThis : currentThis.valueOf()) : currentThis
);
}
|
javascript
|
{
"resource": ""
}
|
q60590
|
create
|
validation
|
function create(props) {
var button = Object.create(this);
_canvasWidget2.default.create.call(button);
Object.assign(button, Button.defaults, props);
if (props.value) button.__value = props.value;
button.init();
return button;
}
|
javascript
|
{
"resource": ""
}
|
q60591
|
bindProperty
|
validation
|
function bindProperty(o, parent, prop) {
Object.defineProperty(o, prop, {
get: function () {
try { return parent[prop]; } catch (e) {}
},
set: function (val) {
try { parent[prop] = val; } catch(e) {}
},
configurable: true
});
}
|
javascript
|
{
"resource": ""
}
|
q60592
|
getKeys
|
validation
|
function getKeys (o) {
switch(typeof o) {
case 'object':
return o ? Object.keys(o) : [];
case 'string':
var keys = [];
for(var i = 0; i < o.length; i++) keys.push(i.toString());
return keys;
default:
return [];
}
}
|
javascript
|
{
"resource": ""
}
|
q60593
|
camelize
|
validation
|
function camelize () {
var ret = [];
libs.object.every(arguments, function (s) {
if(s) {
if(typeof s === 'function') s = fixFirefoxFunctionString(s.toString());
s = s.toString().replace(/[^a-z0-9$]/gi, '_').replace(/\$(\w)/g, '$_$1').split(/[\s_]+/g);
libs.object.each(s, 1, s.length, function (i, k) {
this[k] = libs.string.ucFirst(i);
});
s = libs.string.lcFirst(s.join(''));
}
ret.push(s);
});
return ret.length === 1 ? ret[0] : ret;
}
|
javascript
|
{
"resource": ""
}
|
q60594
|
decamelize
|
validation
|
function decamelize () {
var ret = [];
libs.object.every(arguments, function (s) {
if(s) {
if(typeof s === 'function') s = fixFirefoxFunctionString(s.toString());
s = s.toString().replace(/([A-Z$])/g, function ($) {
return ' ' + (typeof $ === 'string' ? $.toLowerCase() : '');
}).replace(/function \(\)/g, 'function()');
}
ret.push(typeof s === 'string' ? s.trim() : s);
});
return ret.length === 1 ? ret[0] : ret;
}
|
javascript
|
{
"resource": ""
}
|
q60595
|
differenceFromString
|
validation
|
function differenceFromString (s, other) {
if(typeof other !== 'string' || typeof s !== 'string') return s;
var sarr = s.split(''), oarr = other.split('');
return libs.array.difference(sarr, oarr).join('');
}
|
javascript
|
{
"resource": ""
}
|
q60596
|
intersectString
|
validation
|
function intersectString (s, other) {
if(typeof other !== 'string' || typeof s !== 'string') return s;
var sarr = s.split(''), oarr = other.split('');
return libs.array.intersect(sarr, oarr).join('');
}
|
javascript
|
{
"resource": ""
}
|
q60597
|
repeat
|
validation
|
function repeat (s, times) {
times = parseInt(times, 10);
times = isNaN(times) || !isFinite(times) || times <= 0 ? 1 : times;
var os = s;
for(var i = 1; i < times; i++) s += os;
return s;
}
|
javascript
|
{
"resource": ""
}
|
q60598
|
rtrim
|
validation
|
function rtrim (s, what) {
what = typeof what === 'string' ? what : '\\s+';
return s.replace(new RegExp(what + '$'), '');
}
|
javascript
|
{
"resource": ""
}
|
q60599
|
ltrim
|
validation
|
function ltrim (s, what) {
what = typeof what === 'string' ? what : '\\s+';
return s.replace(new RegExp('^' + what), '');
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.