repo stringlengths 5 67 | code stringlengths 52 373k | complexity float64 1 10 | label stringclasses 4
values |
|---|---|---|---|
ciena-blueplanet/bunsen-core | function (state, action) {
return _.defaults({
isValidating: action.isValidating,
lastAction: IS_VALIDATING
}, state)
} | 1.3 | Simple |
NLeSC/spot | function addWidgetForFilter (view, filter, editModeHint) {
var gridster = view._widgetsGridster;
var row = filter.row || 1;
var col = filter.col || 1;
var sizeX = filter.size_x || 3;
var sizeY = filter.size_y || 3;
var el = gridster.add_widget('<div class="widgetOuterFrame"></div>', sizeX, sizeY, col, row)... | 1.1 | Simple |
ciena-blueplanet/bunsen-core | function inRange (value, min, max) {
const int = parseInt(value, 10)
return (
`${int}` === `${value.replace(/^0/, '')}` &&
int >= min &&
int <= max
)
} | 2.5 | Simple |
helpers/helper-md | function markdown(options) {
return new Remarkable(extend({
breaks: false,
html: true,
langPrefix: 'lang-',
linkify: true,
typographer: false,
xhtmlOut: false
}, options));
} | 1.6 | Simple |
NLeSC/spot | function partitionValueToIndex (partition, value) {
var group;
if (!partition) {
// no(sub)partitioning return first element
return 0;
}
// with (sub)partitioning
group = partition.groups.get(value, 'value');
if (group) {
// string in partition
return group.groupIndex;
} else {
// s... | 2.7 | Simple |
ciena-blueplanet/bunsen-core | function _validateArray (path, model, validateModelType) {
const results = []
let subPath = `${path}/items`
if (_.isPlainObject(model.items)) {
if (model.items.type === 'object') {
results.push(validateSubModel(subPath, model.items, validateModelType))
}
} else if (Array.isArray(model.items)) {
... | 1.3 | Simple |
ciena-blueplanet/bunsen-core | function getDefaults (value, path, model, resolveRef) {
const schema = findSchema(model, path, resolveRef)
const schemaDefault = _.clone(schema.default)
if (model.type === 'object') {
const subSchemaDefaults = {}
_.forIn(schema.properties, function (subSchema, propName) {
const defaults = getDefaul... | 2.6 | Simple |
ciena-blueplanet/bunsen-core | function getDefaultedValue ({inputValue, previousValue, bunsenId, renderModel, mergeDefaults}) {
const isInputValueEmpty = isEmptyValue(inputValue)
if (previousValue !== undefined) {
return inputValue
}
const resolveRef = schemaFromRef(renderModel.definitions)
const defaultValue = getDefaults(inputValue... | 5.2 | Moderate |
ciena-blueplanet/bunsen-core | function fieldValidation (dispatch, getState, fieldValidators, formValue, initialFormValue, all) {
let fieldsBeingValidated = []
const allValidationPromises = []
fieldValidators.forEach(validator => {
/**
* Field validator definition
* @property {String} field field to validate
* @property {Str... | 1.1 | Simple |
ciena-blueplanet/bunsen-core | function _guardPromiseAll (promises, all, callback) {
if (promises.length === 0) {
callback()
} else {
all(promises).then(() => {
callback()
})
}
} | 1.1 | Simple |
ciena-blueplanet/bunsen-core | function getPropertyOrder (properties) {
const primitiveProps = []
const complexProps = []
_.forIn(properties, (prop, propName) => {
if (prop.type === 'object' || prop.type === 'array') {
complexProps.push(propName)
} else {
primitiveProps.push(propName)
}
})
return primitiveProps.co... | 2.4 | Simple |
ciena-blueplanet/bunsen-core | function addModelCell (propertyName, model, cellDefinitions) {
const cell = {}
var defName = propertyName
var counter = 1
while (defName in cellDefinitions) {
defName = `${propertyName}${counter}`
counter++
}
cellDefinitions[defName] = cell
const props = getPropertyOrder(model.properties)
co... | 1.2 | Simple |
jacob-meacham/serverless-plugin-offline-kinesis-events | async function run() {
// Read the records
const records = await BB.all(process.argv.slice(2).map(f => readAsync(f)))
// Write them to Kinesis
return BB.map(records, record => kinesis.putRecord({
Data: JSON.stringify(yaml.safeLoad(record)),
PartitionKey: '0',
StreamName: process.env.LAMBDA_KINESIS_S... | 1.1 | Simple |
ciena-blueplanet/bunsen-core | function appendModelPath (modelPath, id, internal) {
const addedModelPath = getModelPath(id)
if (internal) {
if (modelPath === '') {
return `properties._internal.${addedModelPath}`
}
return `${modelPath}.properties._internal.${addedModelPath}`
}
if (modelPath === '') {
return addedModelPat... | 3.1 | Moderate |
ciena-blueplanet/bunsen-core | function extendCell (cell, cellDefinitions) {
cell = _.clone(cell)
while (cell.extends) {
const extendedCell = cellDefinitions[cell.extends]
if (!_.isObject(extendedCell)) {
throw new Error(`'${cell.extends}' is not a valid model definition`)
}
delete cell.extends
cell = _.defaults(cell, e... | 2.8 | Simple |
ciena-blueplanet/bunsen-core | function normalizeArrayOptions (cell, cellDefinitions) {
const arrayOptions = _.clone(cell.arrayOptions)
if (arrayOptions.itemCell) {
if (Array.isArray(arrayOptions.itemCell)) {
arrayOptions.itemCell = arrayOptions.itemCell.map(cell => normalizeCell(cell, cellDefinitions))
} else {
arrayOptions.... | 1.1 | Simple |
ciena-blueplanet/bunsen-core | function pluckFromArrayOptions (cell, modelPath, models, cellDefinitions) {
if (cell.arrayOptions.tupleCells) {
cell.arrayOptions.tupleCells.forEach(function (cell, index) {
pluckModels(cell, modelPath.concat(index), models, cellDefinitions)
})
}
if (cell.arrayOptions.itemCell) {
const itemCell ... | 1.2 | Simple |
ciena-blueplanet/bunsen-core | function pluckModels (cell, modelPath, models, cellDefinitions) {
cell = extendCell(cell, cellDefinitions)
if (_.isObject(cell.model)) {
const addedPath = appendModelPath(modelPath.modelPath(), cell.id, cell.internal)
models[addedPath] = cell.model
} else if (cell.children) { // recurse on objects
cel... | 1.9 | Simple |
ciena-blueplanet/bunsen-core | function aggregateModels (view, modelPath) {
const models = {}
view.cells.forEach(function (cell) {
const newPath = typeof cell.model === 'string' ? modelPath.concat(cell.model) : modelPath
pluckModels(cell, newPath, models, view.cellDefinitions)
})
return models
} | 2 | Simple |
ciena-blueplanet/bunsen-core | function expandModel (model, view) {
const modelPath = new BunsenModelPath(model)
const modelExpansions = aggregateModels(view, modelPath)
let newModel = model
_.forEach(modelExpansions, (propertyModel, path) => {
newModel = addBunsenModelProperty(newModel, propertyModel, path)
})
return newModel
} | 1.2 | Simple |
godaddy/asset-system | function svgs(req, res) {
const bundle = new Bundle(
req.url.slice(1, -5).split('-').map(function map(name) {
return assets[name];
})
);
bundle.run(function (err, output) {
if (err) throw err;
res.setHeader('Content-Length', Buffer(output).length);
res.writeHead(200, { 'Content-Type': ... | 1.2 | Simple |
godaddy/asset-system | function html(req, res) {
fs.readFile(path.join(__dirname, 'index.html'), function read(err, file) {
if (err) throw err;
res.setHeader('Content-Length', file.length);
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(file);
});
} | 2.1 | Simple |
godaddy/asset-system | function client(req, res) {
const compiler = webpack(config);
compiler.outputFileSystem = fsys;
compiler.run((err, stats) => {
const file = fsys.readFileSync(path.join(__dirname, 'dist', 'client.js'));
res.setHeader('Content-Length', file.length);
res.writeHead(200, { 'Content-Type': 'text/javascrip... | 1.5 | Simple |
ciena-blueplanet/bunsen-core | function convertObjectCell (cell) {
return _.chain(cell.rows)
.map(rowsToCells)
.assign(_.pick(cell, CARRY_OVER_PROPERTIES))
.value()
} | 1.4 | Simple |
ciena-blueplanet/bunsen-core | function convertArrayCell (cell) {
const {item} = cell
const arrayOptions = _.chain(item)
.pick(ARRAY_CELL_PROPERTIES)
.assign({
itemCell: convertCell(item)
})
.value()
return {
arrayOptions,
model: cell.model
}
} | 1.3 | Simple |
ciena-blueplanet/bunsen-core | function convertRenderer (cell) {
const {renderer} = cell
if (renderer === undefined) {
return
}
const basicRenderers = [
'boolean',
'string',
'number'
]
if (basicRenderers.indexOf(renderer) >= 0) {
return {name: renderer}
}
return customRenderer(renderer, cell.properties)
} | 2.8 | Simple |
ciena-blueplanet/bunsen-core | function grabClassNames (cell) {
const classNames = _.pickBy({
cell: cell.className,
value: cell.inputClassName,
label: cell.labelClassName
})
if (_.size(classNames) > 0) {
return classNames
}
} | 2.2 | Simple |
ciena-blueplanet/bunsen-core | function rowsToCells (rows) {
if (!rows) {
return {}
}
const children = rows
.map((row) => {
return {
children: _.map(row, convertCell)
}
})
return {
children
}
} | 1.2 | Simple |
godaddy/asset-system | function warning(lines) {
lines.unshift(''); // Extra whitespace at the start.
lines.push(''); // Extra whitespace at the end.
lines.forEach(function each(line) {
console.error('asset-bundle:warning', line);
});
} | 1.2 | Simple |
godaddy/asset-system | function viewBox(details) {
svg.viewBox = `${details.x || 0} ${details.y || 0} ${details.width} ${details.height}`;
fn(null, svg);
} | 1.4 | Simple |
NLeSC/spot | function () {
var filter = this.collection.parent.filter;
if (!filter || !this.isFilled) {
return false;
}
filter.releaseDataFilter();
if (this.type === 'partition') {
var partition = filter.partitions.get(this.rank, 'rank');
filter.partitions.remove(partition);
} else if (thi... | 3.9 | Moderate |
jacob-meacham/serverless-plugin-offline-kinesis-events | function getWebpackRunnableLambda(slsWebpack, stats, functionName) {
const handler = slsWebpack.loadHandler(stats, functionName, true)
const context = slsWebpack.getContext(functionName)
return wrapHandler(handler, context)
} | 1.4 | Simple |
NLeSC/spot | function onClick (ev, elements) {
var model = this._Ampersandview.model;
var partition = model.filter.partitions.get(1, 'rank');
if (elements.length > 0) {
partition.updateSelection(partition.groups.models[elements[0]._index]);
model.filter.updateDataFilter();
app.me.dataview.getData();
}
} | 2.4 | Simple |
NLeSC/spot | function getColor (i) {
i = parseInt(i);
if (i < 0 || i >= colors.length) {
// pick a color from the scale defined above
return scale(((i - colors.length) * (211 / 971)) % 1);
} else {
return chroma(colors[i]);
}
} | 2.7 | Simple |
uzyn/web3-loader | function init(loader) {
var loaderConfig = loaderUtils.getLoaderConfig(loader, 'web3Loader');
web3 = require('./lib/web3')(loaderConfig.provider);
config = mergeConfig(loaderConfig);
isDebug = loader.debug;
} | 1.5 | Simple |
uzyn/web3-loader | function mergeConfig(loaderConfig) {
var defaultConfig = {
// Web3
provider: 'http://localhost:8545',
// For deployment
from: web3.eth.accounts[0],
gasLimit: web3.eth.getBlock(web3.eth.defaultBlock).gasLimit,
// Specify contract constructor parameters, if any.
// constructorParams: {
... | 1.6 | Simple |
uzyn/web3-loader | function deploy(contract, callback, contractMap) {
// Reuse existing contract address
if (config.deployedContracts.hasOwnProperty(contract.name)) {
contract.address = config.deployedContracts[contract.name];
return callback(null, contract);
}
linkBytecode(contract, contractMap);
// Deploy a new one
... | 2.6 | Simple |
ciena-blueplanet/bunsen-core | function _validateRootAttributes (view, model, cellValidator) {
const results = [
_validateCells(view, model, cellValidator)
]
const knownAttributes = ['version', 'type', 'cells', 'cellDefinitions']
const unknownAttributes = _.difference(Object.keys(view), knownAttributes)
results.push({
errors: [],
... | 1.3 | Simple |
NLeSC/spot | function () {
// Create and attach our main view
this.mainView = new MainView({
model: this.me,
el: document.body
});
// this kicks off our backbutton tracking (browser history)
// and will cause the first matching handler in the router
// to fire.
this.router.history.start({
... | 1.6 | Simple |
kenodressel/mysql-to-rest | function (i) {
if (i >= columns.length) {
insertIntoDB();
return;
}
var dbField = columns[i];
var field = dbField.Field;
//Check required fields
if (d... | 8 | Complex |
kenodressel/mysql-to-rest | function insertIntoDB() {
lastQry = connection.query('INSERT INTO ?? SET ?', [req.params.table , insertJson] , function (err, rows) {
if (err) {
console.error(err);
res.statusCode = 500;
res.s... | 2.3 | Simple |
kenodressel/mysql-to-rest | function updateIntoDB() {
//Yaaay, alle Tests bestanden gogo, insert!
lastQry = connection.query('UPDATE ?? SET ? WHERE ?? = ?', [req.params.table , updateJson, updateSelector.field, updateSelector.value] , function (err) {
if (err) return sendError(res,er... | 2 | Simple |
kenodressel/mysql-to-rest | function sendSuccessAnswer(table, res, id, field) {
if(typeof field === "undefined") {
if(id === 0) {
//Just assume that everything went okay. It looks like a non numeric primary key.
res.send({
result: 'success',
table: table
});
... | 2.2 | Simple |
kenodressel/mysql-to-rest | function checkIfSentvaluesAreSufficient(req,dbField) {
if(dbField.Default == 'FILE') {
//For 'File' fields just return the link ot the file
if(req.files.hasOwnProperty(dbField.Field)) {
var file = req.files[dbField.Field].hasOwnProperty('name') ? req.files[dbField.Field] : req.files[dbF... | 6.3 | Complex |
kenodressel/mysql-to-rest | function sendError(res,err) {
console.error(err);
// also log last executed query, for easier debugging
console.error(lastQry.sql);
res.statusCode = 500;
res.send({
result: 'error',
err: err
});
} | 1.6 | Simple |
kenodressel/mysql-to-rest | function findPrim(columns,field) {
var primary_keys = columns.filter(function (r) {return r.Key === 'PRI';});
//for multiple primary keys, just take the first
if(primary_keys.length > 0) {
return primary_keys[0].Field;
}
//If the provided field is a string, we might have a chance
if(t... | 1.1 | Simple |
mandnyc/ssml-builder | function checkRateRange(num) {
var numString = num.substring(0, num.length - 1);
var parseNum = parseInt(numString);
if (parseNum < 20) {
throw new Error("The minimum rate is twenty percentage. Received: " + parseNum);
}
} | 2.1 | Simple |
mandnyc/ssml-builder | function isInList(value, listOfValues, msg) {
value = value.toLowerCase().trim();
if (listOfValues.indexOf(value) === -1) {
throw new Error(msg);
}
} | 2 | Simple |
pebble/clay | function equals(x, y) {
var a = isFunction(x) ? x() : x;
var b = isFunction(y) ? y() : y;
var aKeys;
if (a == b)
return true;
else if (a == _null || b == _null)
return false;
else if (isValue(a) || isValue(b))
return isDate(a) && isDate(b) && +a==+b;
else if (isList(a)) {
... | 1.9 | Simple |
pebble/clay | function parseDate(fmt, date) {
var indexMap = {}; // contains reGroupPosition -> typeLetter or [typeLetter, value array]
var reIndex = 1;
var timezoneOffsetMatch;
var timezoneIndex;
var match;
var format = replace(fmt, /^\?/);
if (format!=fmt && !trim(date))
return _null;
if (ma... | 4.6 | Moderate |
pebble/clay | function collectUniqNodes(list, func) {
var result = [];
var nodeIds = {};
var currentNodeId;
flexiEach(list, function(value) {
flexiEach(func(value), function(node) {
if (!nodeIds[currentNodeId = getNodeId(node)]) {
result.push(node);
nodeIds[currentNodeId] = true;
... | 2 | Simple |
pebble/clay | function triggerHandler(eventName, event, target) {
var match = !bubbleSelector;
var el = bubbleSelector ? target : registeredOn;
if (bubbleSelector) {
var selectorFilter = getFilterFunc(bubbleSelector, registeredOn);
while (el && el != registere... | 4.6 | Moderate |
Backendless/JS-Code-Runner | function enrichMethodNode(methodNode, method) {
method.description && (methodNode.description = method.description)
if (method.tags.route) {
let httpPath = method.tags.route
let httpMethod = 'GET'
const sepPos = httpPath.indexOf(' ')
if (sepPos !== -1) {
httpMethod = httpPath.substr(0, sepPo... | 3.9 | Moderate |
refractproject/minim | function refract(value) {
if (value instanceof Element) {
return value;
}
if (typeof value === 'string') {
return new StringElement(value);
}
if (typeof value === 'number') {
return new NumberElement(value);
}
if (typeof value === 'boolean') {
return new BooleanElement(value);
}
if... | 4.7 | Moderate |
zurb/supercollider | function statusLog(file, data, time) {
var msg = '';
var diff = (process.hrtime(time)[1] / 1000000000).toFixed(2);
var adapters = Object.keys(data._adapterData).join(', ');
msg += format('Supercollider: processed %s in %s', chalk.cyan(file), chalk.magenta(diff + ' s'));
if (adapters.length) {
msg += for... | 2.6 | Simple |
tmcw/stickshift | function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false);
setGuttersForLineNumbers(op... | 8.5 | Complex |
tmcw/stickshift | function updateWidgetHeight(line) {
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
line.widgets[i].height = line.widgets[i].node.offsetHeight;
} | 2.5 | Simple |
tmcw/stickshift | function ensureLineWrapped(lineView) {
if (lineView.node == lineView.text) {
lineView.node = elt("div", null, null, "position: relative");
if (lineView.text.parentNode)
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
lineView.node.appendChild(lineView.text);
if (... | 3.5 | Moderate |
tmcw/stickshift | function extendSelection(doc, head, other, options) {
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
} | 1.4 | Simple |
tmcw/stickshift | function skipAtomic(doc, pos, bias, mayClear) {
var flipped = false, curPos = pos;
var dir = bias || 1;
doc.cantEdit = false;
search: for (;;) {
var line = getLine(doc, curPos.line);
if (line.markedSpans) {
for (var i = 0; i < line.markedSpans.length; ++i) {
var sp = line.m... | 8.2 | Complex |
tmcw/stickshift | function drawSelectionCursor(cm, range, output) {
var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
cursor.style.left = pos.left + "px";
cursor.style.top = pos.top + "px";
cur... | 3.4 | Moderate |
tmcw/stickshift | function findViewForLine(cm, lineN) {
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
return cm.display.view[findViewIndex(cm, lineN)];
var ext = cm.display.externalMeasured;
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
return ext;
} | 3.5 | Moderate |
tmcw/stickshift | function prepareMeasureForLine(cm, line) {
var lineN = lineNo(line);
var view = findViewForLine(cm, lineN);
if (view && !view.text)
view = null;
else if (view && view.changes)
updateLineForChanges(cm, view, lineN, getDimensions(cm));
if (!view)
view = updateExternalMeasurement(cm, ... | 4.1 | Moderate |
tmcw/stickshift | function charWidth(display) {
if (display.cachedCharWidth != null) return display.cachedCharWidth;
var anchor = elt("span", "xxxxxxxxxx");
var pre = elt("pre", [anchor]);
removeChildrenAndAdd(display.measure, pre);
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
... | 3.2 | Moderate |
tmcw/stickshift | function endOperation(cm) {
var op = cm.curOp, group = op.ownsGroup;
if (!group) return;
try { fireCallbacksForOps(group); }
finally {
operationGroup = null;
for (var i = 0; i < group.ops.length; i++)
group.ops[i].cm.curOp = null;
endOperations(group);
}
} | 2.8 | Simple |
tmcw/stickshift | function setScrollTop(cm, val) {
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
cm.doc.scrollTop = val;
if (!gecko) updateDisplaySimple(cm, {top: val});
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
cm.display.scrollbars.setScrollTop(val);
if (gecko) updateDis... | 3.6 | Moderate |
tmcw/stickshift | function ensureCursorVisible(cm) {
resolveScrollToPos(cm);
var cur = cm.getCursor(), from = cur, to = cur;
if (!cm.options.lineWrapping) {
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
to = Pos(cur.line, cur.ch + 1);
}
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cur... | 3 | Simple |
tmcw/stickshift | function takeToken(cm, pos, precise, asArray) {
function getObj(copy) {
return {start: stream.start, end: stream.pos,
string: stream.current(),
type: style || null,
state: copy ? copyState(doc.mode, state) : state};
}
var doc = cm.doc, mode = doc.mode, style;... | 2.5 | Simple |
tmcw/stickshift | function buildLineContent(cm, lineView) {
// The padding-right forces the element to have a 'border', which
// is needed on Webkit to be able to get line-level bounding
// rectangles for it (in measureChar).
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
var builder = ... | 8.5 | Complex |
tmcw/stickshift | function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) return;
var special = builder.cm.options.specialChars, mustWrap = false;
if (!special.test(text)) {
builder.col += text.length;
var content = document.createTextNode(text);
builder.map.push(builder.pos... | 8.8 | Critical |
tmcw/stickshift | function(at, lines, height) {
this.height += height;
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
} | 2.2 | Simple |
tmcw/stickshift | function clearSelectionEvents(array) {
while (array.length) {
var last = lst(array);
if (last.ranges) array.pop();
else break;
}
} | 2.4 | Simple |
tmcw/stickshift | function() {
// don't create more object URLs than needed
if (blob_changed || !object_url) {
object_url = get_URL().createObjectURL(blob);
}
if (target_view) {
target_view.location.href = object_url;
} else {
var new_tab = view.open(object_url, "_blank");
if (new_tab == ... | 3.9 | Moderate |
tmcw/stickshift | function DOMMouseMoveTracker(
onMove,
/*function*/ onMoveEnd,
/*DOMElement*/ domNode) {
this.$DOMMouseMoveTracker_isDragging = false;
this.$DOMMouseMoveTracker_animationFrameID = null;
this.$DOMMouseMoveTracker_domNode = domNode;
this.$DOMMouseMoveTracker_onMove = onMove;
this.$DOMMouseMoveT... | 1.9 | Simple |
tmcw/stickshift | function(target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function() {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachE... | 1.2 | Simple |
tmcw/stickshift | function(
/*number*/ combinedWidth,
/*number*/ leftOffset,
/*number*/ cellWidth,
/*?number*/ cellMinWidth,
/*?number*/ cellMaxWidth,
/*number|string*/ columnKey,
/*object*/ event) {
if (Locale.isRTL()) {
leftOffset = -leftOffset;
}
this.setState({
isColumnResizing: tr... | 2.9 | Simple |
tmcw/stickshift | function forEachColumn(children, callback) {
React.Children.forEach(children, function(child) {
if (child.type === FixedDataTableColumnGroup.type) {
forEachColumn(child.props.children, callback);
} else if (child.type === FixedDataTableColumn.type) {
callback(child);
}
});
} | 2.5 | Simple |
tmcw/stickshift | function mapColumns(children, callback) {
var newChildren = [];
React.Children.forEach(children, function(originalChild) {
var newChild = originalChild;
// The child is either a column group or a column. If it is a column group
// we need to iterate over its columns and then potentially generate a
... | 2 | Simple |
tmcw/stickshift | function FixedDataTableRowBuffer(
rowsCount,
/*number*/ defaultRowHeight,
/*number*/ viewportHeight,
/*?function*/ rowHeightGetter)
{
invariant(
defaultRowHeight !== 0,
"defaultRowHeight musn't be equal 0 in FixedDataTableRowBuffer"
);
this.$FixedDataTableRowBuffer_bufferSet = n... | 2.7 | Simple |
tmcw/stickshift | function cx(classNames) {
var classNamesArray;
if (typeof classNames == 'object') {
classNamesArray = Object.keys(classNames).filter(function(className) {
return classNames[className];
});
} else {
classNamesArray = Array.prototype.slice.call(arguments);
}
return classNamesArray.map(getClas... | 1.2 | Simple |
tmcw/stickshift | function(obj) {
var ret = {};
var key;
invariant(
obj instanceof Object && !Array.isArray(obj),
'keyMirror(...): Argument must be an object.'
);
for (key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
}
ret[key] = key;
}
return ret;
} | 3.2 | Moderate |
tmcw/stickshift | function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
var key;
// Test for A's keys different from B.
for (key in objA) {
if (objA.hasOwnProperty(key) &&
(!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
return false;
}
}
// Test for B's keys missing fro... | 4.5 | Moderate |
darul75/ng-prettyjson | function(a){var b;
// the final two arguments are the length, and the entire string itself;
// we don't care about those.
if(arguments.length<7)throw new Error("markup() must be called from String.prototype.replace()");return b=e.apply(null,arguments),'<span class="'+d[b]+'">'+a+"</span>"} | 2 | Simple |
HuddleEng/PhantomXHR | function FakeEvent(type, bubbles, cancelable, target) {
this.initEvent(type, bubbles, cancelable, target);
} | 1.3 | Simple |
jonschlinkert/grunt-prettify | function padcomments(str, num) {
var nl = _str.repeat('\n', (num || 1));
return str.replace(/(\s*)(<!--.+)\s*(===.+)?/g, nl + '$1$2$1$3');
} | 1.9 | Simple |
vecnatechnologies/backbone-torso | function(obj, cache) {
cache[obj.cid] = obj;
this.listenToOnce(obj, 'before-dispose', function() {
delete cache[obj.cid];
});
} | 1.2 | Simple |
vecnatechnologies/backbone-torso | function hotswap(currentNode, newNode, ignoreElements) {
var newNodeType = newNode.nodeType,
currentNodeType = currentNode.nodeType,
swapMethod;
if(newNodeType !== currentNodeType) {
$(currentNode).replaceWith(newNode);
} else {
swapMethod = swapMethods[newNodeType] || swapMethods['... | 2.8 | Simple |
vecnatechnologies/backbone-torso | function cleanupStickitData(node) {
var $node = $(node);
var stickitValue = $node.data('stickit-bind-val');
if (node.tagName === 'OPTION' && node.value !== undefined && stickitValue !== node.value) {
$node.removeData('stickit-bind-val');
}
} | 2.9 | Simple |
vecnatechnologies/backbone-torso | function($el, template, context, opts) {
var newDOM, newHTML,
el = $el.get(0);
opts = opts || {};
newHTML = opts.newHTML || template(context);
if (opts.force) {
$el.html(newHTML);
} else {
newDOM = this.copyTopElement(el);
$(newDOM).html(newHTML);
... | 3.3 | Moderate |
vecnatechnologies/backbone-torso | function(currentNode, newNode, ignoreElements) {
var currentCaret, activeElement,
currentNodeContainsActiveElement = false;
try {
activeElement = document.activeElement;
} catch (error) {
activeElement = null;
}
if (activeElement && currentNode && $.contains(activ... | 4.6 | Moderate |
vecnatechnologies/backbone-torso | function(el) {
var newDOM = document.createElement(el.tagName);
_.each(el.attributes, function(attrib) {
newDOM.setAttribute(attrib.name, attrib.value);
});
return newDOM;
} | 1.2 | Simple |
vecnatechnologies/backbone-torso | function(options) {
options = options || {};
options.idsToFetch = options.idsToFetch || this.trackedIds;
options.setOptions = options.setOptions || {remove: false};
return this.__loadWrapper(function() {
if (options.idsToFetch && options.idsToFetch.length) {... | 2.5 | Simple |
vecnatechnologies/backbone-torso | function(ids, options) {
options = options || {};
options.idsToFetch = _.intersection(ids, this.getTrackedIds());
return this.fetch(options);
} | 2 | Simple |
vecnatechnologies/backbone-torso | function(ids) {
this.remove(_.difference(this.trackedIds, ids));
parentInstance.registerIds(ids, ownerKey);
this.trackedIds = ids;
} | 1.4 | Simple |
vecnatechnologies/backbone-torso | function(options) {
options = options || {};
//find ids that we don't have in cache and aren't already in the process of being fetched.
var idsNotInCache = _.difference(this.getTrackedIds(), _.pluck(parentInstance.models, 'id'));
var idsWithPromises = _.pick(parentInstan... | 1.4 | Simple |
vecnatechnologies/backbone-torso | function(modelIdentifier) {
var model = this.get(modelIdentifier);
parentClass.remove.apply(this, arguments);
if (model) {
var trackedIdsWithoutModel = this.getTrackedIds();
trackedIdsWithoutModel = _.without(trackedIdsWithoutModel, model.id);
... | 2.3 | Simple |
vecnatechnologies/backbone-torso | function(args) {
base.call(this, args);
this.loadedOnceDeferred = new $.Deferred();
this.loadedOnce = false;
this.loadingCount = 0;
// Loading is a convenience flag that is the equivalent of loadingCount > 0
this.loading = false;
} | 1.5 | Simple |
vecnatechnologies/backbone-torso | function(fetchMethod, options) {
var object = this;
this.loadingCount++;
this.loading = true;
this.trigger('load-begin');
return $.when(fetchMethod.call(object, options)).always(function() {
if (!object.loadedOnce) {
object.loadedOnce = true;
obj... | 2.7 | Simple |
vecnatechnologies/backbone-torso | function(viewPrepare) {
var viewContext = viewPrepare() || {};
var behaviorContext = _.omit(this.toJSON(), 'view');
_.extend(behaviorContext, this.prepare());
viewContext[this.alias] = behaviorContext;
return viewContext;
} | 2.2 | Simple |
vecnatechnologies/backbone-torso | function() {
this.listenTo(this.view, 'initialize:complete', this.__augmentViewPrepare);
this.listenTo(this.view, 'before-dispose-callback', this.__dispose);
_.each(eventMap, function(callback, event) {
this.listenTo(this.view, event, this[callback]);
}, this);
} | 1.2 | Simple |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 29