Dataset Viewer
Auto-converted to Parquet Duplicate
code
stringlengths
95
9.33k
complexity
float64
1.1
10
label
stringclasses
4 values
param_count
int64
0
14
local_statement_count
int64
1
132
total_statement_count
int64
1
132
local_variable_count
int64
0
30
total_variable_count
int64
0
37
local_nesting_depth
int64
0
59
total_nesting_depth
int64
0
59
() => { var events; var button; if (window.kelmu.data[id].settings.step && !stepButtonInitialized) { button = element.find(window.kelmu.data[id].settings.step); if (button.length > 0) { events = $._data(button[0], 'events'); stepButtonInitialized = t...
9.1
Critical
0
38
38
2
2
12
12
const textLayerElementFromPoint = (x, y, pageNumber) => { let svg = document.querySelector(`svg[data-pdf-annotate-page="${pageNumber}"]`); let rect = svg.getBoundingClientRect(); y = scaleUp(svg, {y}).y + rect.top; x = scaleUp(svg, {x}).x + rect.left; return [...svg.parentNode.querySelectorAll('.textLayer [da...
1.2
Simple
3
5
6
2
2
0
1
(items, selectedValues, selectedIdx) => { var arrayUtil = ariaUtilsArray; var preselect = this._checkPreselect(selectedIdx); selectedIdx = (preselect === undefined) ? selectedIdx : preselect; var maxSelectedCount = this._getTrueMaxSelectedCount(items); var pbM...
8.6
Critical
3
40
40
19
19
10
10
const fixInputString = (str) => { var br = /<br\s*\/?>|&lt;br\s*\/?&gt;/gi; if (sh.config.bloggerMode == true) str = str.replace(br, '\n'); if (sh.config.stripBrs == true) str = str.replace(br, ''); return str; }
3.4
Moderate
1
6
6
1
1
2
2
const parseIpfsPath = (ipfsPath) => { const invalidPathErr = new Error('invalid ipfs ref path') ipfsPath = ipfsPath.replace(/^\/ipfs\//, '') const matched = ipfsPath.match(/([^/]+(?:\/[^/]+)*)\/?$/) if (!matched) { throw invalidPathErr } const [hash, ...links] = matched[1].split('/') // check that a...
3.7
Moderate
1
9
9
4
4
2
2
(opt_capabilities, opt_flow) => { var capabilities = opt_capabilities || webdriver.Capabilities.phantomjs(); var exe = findExecutable(capabilities.get(BINARY_PATH_CAPABILITY)); var args = ['--webdriver-logfile=' + DEFAULT_LOG_FILE]; var logPrefs = capabilities.get(webdriver.Capability.LOGGING_PREFS); if (log...
6.2
Complex
2
30
33
11
11
6
6
const blockResizeStart = () => { var lastListeningElement; // We'll attach only one listener at a time, instead of adding it to every img, input, hr etc. // Listener will be attached upon selectionChange, we'll also check if there was any element that // got listener before (lastListeningElement) - if...
2.7
Simple
0
2
9
1
2
0
3
const equipFromInventory = (attributes, index, slotName) => { if (index >= attributes.inventory.length) { throw new InventoryIndexError(index); } var item = attributes.inventory[index]; if (!slotName) { slotName = item.slot; } if (!slotName) { ...
5.1
Moderate
3
18
18
1
1
7
7
const innerText = (html) => { var schema = new Schema(), domParser = new DomParser({}, schema), text = ''; var shortEndedElements = schema.getShortEndedElements(); var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' '); var blockElements = schema.getB...
5.4
Moderate
1
7
26
6
8
0
10
const _LegacyAppBar_updateFirstAndFinalDiv = () => { var appBarFirstDiv = this._element.querySelectorAll("." + _Constants.firstDivClass); appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; var appBarFinalDiv = this._element.querySelectorA...
8
Complex
0
37
37
4
4
8
8
(state) => { if (isObject(state)) { // get flux state based on current state with before state as well this._state = this.getState({}); // use just the state props from the input obj state = { page : state.page, rowsPerPage...
5.3
Moderate
1
14
14
1
1
5
5
const processActionGroup = (_ref2) => { var _ref2$updateSchemaNam = _ref2.updateSchemaName, updateSchemaName = _ref2$updateSchemaNam === undefined ? undefined : _ref2$updateSchemaNam, _ref2$store = _ref2.store, store = _ref2$store === undefined ? _store : _ref2$store, _ref2$error = _ref2....
6.3
Complex
1
5
23
11
21
1
4
(source) => { var oldSource = this.source; if (oldSource != source) { if (typeof source == 'string') { var m = source.match(/^([a-z]+):/); if (m) { source = source.substr(m[0].length); switch (m[1]) { case...
6.2
Complex
1
23
23
2
2
7
7
() => { var childClusters = this._childClusters.slice(), map = this._group._map, boundsZoom = map.getBoundsZoom(this._bounds), zoom = this._zoom + 1, mapZoom = map.getZoom(), i; //calculate how far we need to zoom down to see all of the markers while (childClusters.length > 0 ...
4.7
Moderate
0
12
12
7
7
3
3
const digit = (event) => { var element = event.element , code = event.keyCode || event.which , result; result = (code >= 48 && code <= 57) || code === 8 || code === 46; if (!result) event.preventDefault(); return { allowed: result, code: code, removal: code === 8 || code ...
3.9
Moderate
1
5
5
3
3
1
1
const handle = (type, req, res, out) => { var index = 0; var ended = false; // When called stop middlewares execution. res.end = end; // Handle next middleware in stack. function next(err) { var middleware = stack[index++]; // No more middlewares or early end. if (!middlewar...
5.2
Moderate
4
4
22
2
4
0
6
const loadAppConfigToContext = (appName, config, path, commonPath, initObjectTemplateFunc, sessionStore) => { let amorphicOptions = AmorphicContext.amorphicOptions; AmorphicContext.applicationConfig[appName] = { appPath: path, commonPath: commonPath, initObjec...
2.5
Simple
6
2
2
1
1
0
0
const configurePaths = (cfg) => { var sourcesBasePath = path.resolve(appPath, cfg.get('sourcesBasePath')) ,sources = cfg.get('sources') ,build = cfg.get('build') ,buildBaseUri ,buildDir = nodeEnv == 'development' ? build.baseDirNameDev : build.baseDirNameDist ,buildPath = path.join( path.resolve(ap...
6.9
Complex
1
22
22
9
9
1
1
(content, pos, isBackward) => { // possible case: editor reported that current syntax is // CSS, but it’s actually a HTML document (either `style` tag or attribute) var offset = 0; var subrange = this.styleTagRange(content, pos); if (subrange) { offset = subrange.start; pos -= subrange.start; ...
4.6
Moderate
3
13
13
6
6
4
4
const WorkerPool = (options) => { if (!(this instanceof WorkerPool)) return new WorkerPool(options); EventEmitter.call(this); this.enabled = false; this.size = getCores(); this.timeout = 120000; this.file = process.env.WMCC_WORKER_FILE || 'worker.js'; this.children = new Map(); this.uid = 0; t...
2.9
Simple
1
10
10
0
0
1
1
(first, startLine, startCol) => { var reader = this._reader, value = this.readNumber(first), ident, tt = Tokens.NUMBER, c = reader.peek(); if (isIdentStart(c)) { ident = this.readName(reader.read()); value += ident; ...
5.3
Moderate
3
19
19
5
5
2
2
(n, symbol, dp, callback) => { if (n < 0 || n > 7) { throw "Invalid digit number"; } if (!(symbol in MAX7219._Font)) { throw "Invalid symbol string"; } var byte = MAX7219._Font[symbol] | (dp ? (1 << 7) : 0); this._shiftOut(MAX7219._Registers["Digit" + n], byte, callback); }
3.5
Moderate
4
6
6
1
1
2
2
const getLowerBoundMatcher = (compare, query) => { // No lower bound if (!query.hasOwnProperty('$gt') && !query.hasOwnProperty('$gte')) { return function(){return true;}; } if (query.hasOwnProperty('$gt') && query.hasOwnProperty('$gte')) { if (compare(query.$gte, query.$gt) === 0) { return function (k...
1.1
Simple
2
11
17
0
0
5
5
const indent = (str, indent) => { if (typeof indent === 'number') { var indent_str = ''; while (indent_str.length < indent) indent_str += ' '; indent = indent_str; } var lines = str.split(/\n/); for (var i=0; i<lines.length;...
3.6
Moderate
2
10
10
3
3
4
4
const getSpecsRegex = () => { const argv = minimist(process.argv.slice(2)); /** * The command line argument `--ieBatch` is a string representing * the current batch to run, of total batches. * For example, `npm run test:unit:ci:ie -- --ieBatch 1of3` */ const [ currentRun, totalRuns ] = argv...
4.6
Moderate
0
16
16
8
8
2
2
const advanceMonths = (d, monthsInTheFuture, adjustForWeekend) => { if(!(d instanceof Date)) return d; monthsInTheFuture = monthsInTheFuture && libs.generic.isNumeric(monthsInTheFuture) ? monthsInTheFuture : 1; d.setTime(d.getTime() + (monthsInTheFuture * 2629...
4.4
Moderate
3
8
8
0
0
3
3
(function( subjects, input, frame, embeds, autoembed, parent, parentKey, options) { var rval = null; // prepare output, set limit, get array of frames var limit = -1; var frames; if(frame.constructor === Array) { rval = []; frames = frame; if(frames.length === 0) { ...
8.4
Complex
8
33
33
11
11
11
11
const isSimpleType = (node) => { switch (node.type) { case "Identifier": case "TSAnyKeyword": case "TSBooleanKeyword": case "TSNeverKeyword": case "TSNumberKeyword": case "TSObjectKeyword": case "TSStringKeyword": case "TSSymbolKeyword": case "...
6.8
Complex
1
12
12
0
0
5
5
const proxy = (scope, map, emitter) => { var args = slice.call(arguments, 3) , tmp = {}, len, name, methods, method, i if (isArray(map)) { len = map.length while (len--) { tmp[map[len]] = map[len] } map = tmp } for (name in map) { methods = map[name] if (!isArray(methods)) { ...
5.2
Moderate
3
17
17
7
7
7
7
(function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ { var cookies /*:Object*/ = {}; if (YAHOO.lang.isString(text) && text.length > 0) { var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent); //if (...
1.1
Simple
2
14
15
8
8
3
3
const generatePackageJson = (config) => { // Read the user's pkg.json var user_file; try { // Read from current file user_file = fs.readFileSync('./pkg.json').toString(); } catch (e) { user_file = null; } // Parse the user's pkg.json var user_json = null; if (user_file) { try { user_json = JSON.par...
7
Complex
1
29
29
7
7
6
6
(elTr, oRecord) => { var ok = this.get("formatRow") ? this.get("formatRow").call(this, elTr, oRecord) : true; if(ok) { // Hide the row to prevent constant reflows elTr.style.display = 'none'; // Update TD elements with new data var allTds = elTr.childNodes, e...
3.7
Moderate
2
10
10
5
5
2
2
const hessenbergQRStep = (M) => { const n = M.dimension; const me = M.elements; const csr = [0, 0, 0]; const cs = []; for (let k = 0; k < n - 1; ++k) { const row1 = k; const row2 = k + 1; const colK = k * n; const a = me[row1 + colK]; const b = me[row2 + colK]; rotg(a, b, csr); con...
6.2
Complex
1
34
34
26
26
4
4
(opts, obj) => { var overlay = this.overlay; $('.fancybox-overlay').stop(true, true); if (!overlay) { this.create(opts); } if (opts.locked && this.fixed && obj.fixed) { if (!overlay) { this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false; } ...
4.6
Moderate
2
11
11
1
1
4
4
const encodeArray_PRIM_BULK_PLAIN = ( encoder, data, properties ) => { // // Bulk Array of Primitives (PRIM_BULK_PLAIN) // // ........ + Signature ID // 01111000 [16-bit] // // Lookup signature var eid = encoder.getSignatureID( properties ), weave = []; encoder.counters.arr_prim_bulk_plain+=1; encoder.l...
4.1
Moderate
3
15
15
9
9
2
2
const parseNumberAndUnit = (mUnitPatterns, sValue) => { var oBestMatch = { numberValue: undefined, cldrCode: [] }; if (typeof sValue !== "string") { return oBestMatch; } var iBestLength = Number.POSITIVE_INFINITY; var sUnitCode, sKey; for (sUnitCode in mUnitPatterns) { for (sKey in mUnitPatter...
7.7
Complex
2
35
35
12
12
8
8
const isValidDefaultValue = (type, defaultVal) => { if (type === 'audio' && typeof defaultVal !== 'string') { return false; } if (type === 'array' && !Array.isArray(defaultVal)) { return false; } if (type === 'asset' && typeof defaultVal !== 'string') { return false; } if (type === 'boolean' && typeof defaultVa...
7.7
Complex
2
35
35
0
0
17
17
const isBlank = (str) => { if (str === undefined || str === null) { return true; } if (angular.isString(str)) { return str.trim().length === 0; } else { // TODO - not undefined but also not a string... return false; } }
3
Simple
1
5
5
0
0
2
2
const buildElementIdentifier = (element) => { if (element.id) { return `#${element.id}`; } let identifier = element.tagName.toLowerCase(); if (!element.parentNode) { return identifier; } const siblings = getSiblings(element); const childIndex = siblings.indexOf(element); if (!isOnlySibli...
3.6
Moderate
1
10
10
3
3
3
3
const deserializeAllDates = (model, json) => { _.each(json, function (value, name) { if ( !_.isDate( value ) && !isBackboneInstance( value ) ) { if ( _.isString( value ) && model.isSerializedDate( name, value ) ) { json[ name ] = model.deserializeDate( name, value ); } else if ( !isScalar( value ) && isRec...
3.8
Moderate
2
2
7
0
0
0
3
const $isInInvisibleState = (c) => { if (c.isVisible === false || c.$container.parentNode === null || c.width <= 0 || c.height <= 0 || c.parent === null || ...
4.9
Moderate
1
6
6
1
1
2
2
(target_object, path, value) => { var path_segments = path.split('.'), segment, resource_name = path_segments.pop(), i = 0, count = path_segments.length; if (Lava.schema.DEBUG && /[a-z]/.test(resource_name)) Lava.t("Terminal resource names must be uppercase"); for (; i < count; i++) { segment =...
5.5
Moderate
3
15
15
5
5
6
6
(a, key) => { var prefix = "spiritual-action:"; return prefix + (function() { a.target = null; a.data = (function(d) { if (gui.Type.isComplex(d)) { if (gui.Type.isFunction(d.stringify)) { d = d.stringify(); } else { try { JSON.stringify(d); } catch (jso...
3.2
Moderate
2
2
13
1
1
0
4
const read_keyword_summary = (input, offset) => { var scanner = Scanner(input); scanner.forward(offset); return { num_blocks: scanner.readNum(), num_entries: scanner.readNum(), key_index_decomp_len: _v2 && scanner.readNum(), // Ver >= 2.0 only key_in...
2.5
Simple
2
3
3
1
1
0
0
const _start = () => { if (!$animate) { $animate = $injector.get('$animate'); } $timeout.cancel(completeTimeout); // do not continually broadcast the started event: if (started) { return; } var document = $document[0]; var parent = d...
5.1
Moderate
0
18
18
4
4
5
5
(token,i,tokens) => { var type = token._type; if (!seenSingle && token.fromThen) { return true; }; var ifelse = type == 'IF' || type == 'UNLESS' || type == 'ELSE'; if (ifelse || type === 'CATCH') { seenSingle = true; }; if (ifelse || type === 'SWITCH' || type == 'TRY') { seenContro...
8.3
Complex
3
27
27
6
6
10
10
const isWriteable = (file) => { let writePermission = true; try { const __fd = fs.openSync(file, 'a'); fs.closeSync(__fd); } catch (e) { /* istanbul ignore next */ writePermission = false; } return writePermission; }
2.2
Simple
1
6
6
2
2
0
0
const CalculateCircleCenter = (A, B, C) => { const aSlope = (B.y - A.y) / (B.x - A.x); const bSlope = (C.y - B.y) / (C.x - B.x); if (aSlope === 0 || bSlope === 0) { // rotate the points about origin to retry and then rotate the answer back. // this should avoid div by zero. // we could pick any acute...
3.9
Moderate
3
9
9
4
4
1
1
(oThis) => { // do not mirror the arrow direction here in RTL mode, because otherwise the offset is calculated wrong // (Because the offset mirroring happens inside popup) // the arrow is later mirrored at the output... // this is the default case if no ...
8.5
Complex
1
41
41
14
14
9
9
const parseForwardRule = () => { var token, rule; if (arguments[0] === undefined || arguments[0] === null) { return; } if (typeof(arguments[0]) === "object") { return arguments[0]; } try { token = tokenize.apply(null, arguments); rule = { regexp: new RegExp('^' + token.name, 'i'), t...
3.3
Moderate
0
10
10
2
2
2
2
const writeBuffer = () => { fs.write(fd, buff, 0, buff.length, 0, function (error) { fs.close(fd); callback(error); }); }
1.2
Simple
0
1
3
0
0
0
1
const pwDecipher = (string) => { if(string) { if ( typeof pw !== 'string' || pw.length < 8 ) { throw new Error('Please set a password with 8 or ' + 'more chars on process.env.CIPHER_UTIL_PW!'); } if ( typeof algo !== 'string' || algo.len...
4.1
Moderate
1
9
9
3
3
3
3
() => { if (!selection.isSelected()) { return false; } if (selection.isMultiple()) { priv.selectionBorder.appear([priv.selStart, selection.end()]); } else { priv.selectionBorder.disappear(); } }
2.7
Simple
0
5
5
0
0
2
2
(matches) => { // Optimized by Jose Prado (http://joseprado.com) for (var i = 0; i < matches.length; i++) { if (matches[i] === null) continue; var itemI = matches[i], itemIEndPos = itemI.index + itemI.length ...
5.4
Moderate
1
15
15
5
5
4
4
(books, context, options) => { kb.fetcher.load(books).then(function (xhr) { renderThreeColumnBrowser2(books, context, options) }).catch(function (err) { complain(err) }) }
1.2
Simple
3
1
3
0
0
0
1
const store = (path, options) => { var str = templates[path]; var cached = options.cache && str && typeof str === 'string'; // cached (only if cached is a string and not a compiled template function) if (cached) return str; // store str = options.str; // remove extraneous utf8 BOM marker str = str.re...
3.4
Moderate
2
9
9
2
2
2
2
const deepest = (a, b, ca, cb) => { if (a === b) { return true; } else if (typeof a !== 'object' || typeof b !== 'object') { return false; } else if (a === null || b === null) { return false; } else if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { if (fastEqual) { return fastEqual.cal...
9.4
Critical
4
51
51
10
10
15
15
const one = (config, node) => { var offset = config.location.toOffset var parser = config.parser var doc = config.doc var type = node.type var start = offset(position.start(node)) var end = offset(position.end(node)) if (config.ignore.indexOf(type) === -1) { if (config.source.indexOf(type) !== -1) { ...
5.7
Moderate
2
18
18
6
6
6
6
(variables) => { var animation = false, animationstring = 'animation', keyframeprefix = '', domPrefixes = ["Webkit", "Moz", "O", "ms", "Khtml"], pfx = '', elm = document.querySelector("body"); if( elm.style.animationName !== undefined ) { animation = true; } ...
4.5
Moderate
1
15
15
7
7
4
4
const deleteRecord = (rType, idFun) => { return function(item, callback) { GLOBAL.debug('deleting', item, rType); var tc = []; getEs().delete({ _type: rType, _id : encodeURIComponent(idFun(item))}, function(err, deleteRes) { callback(err, deleteRes); }); }; }
1.2
Simple
2
1
5
0
1
0
2
(rng, forward) => { var self = this, sel, node, evt; if (!isValidRange(rng)) { return; } // Is IE specific range if (rng.select) { self.explicitRange = null; try { rng.select(); } catch (ex) { // Needed for some o...
8.8
Critical
2
33
33
4
4
11
11
const getClosestInstanceFromNode = (node) => { if (node[internalInstanceKey]) { return node[internalInstanceKey]; } // Walk up the tree until we find an ancestor whose instance we have cached. var parents = []; while (!node[internalInstanceKey]) { parents.push(node); if (node.parentNode) { ...
4.4
Moderate
1
15
15
3
3
5
5
(tplDiv) => { var params = this._cfg; /* check parameter: */ this.$assert(320, tplDiv != null); /* must not be already linked: */ this.$assert(322, params.tplDiv == null); /* must already have a markup waiting to be linked: */ this.$ass...
2.8
Simple
1
10
10
1
1
0
0
const genReq = (options,cb) => { log(options.verbose,"Starting twitreq ..."); if ( typeof options.protocol === "undefined" ) { options.protocol = PROTOCOL; } if ( typeof options.host === "undefined" ) { options.host = HOST; } if ( typeof options.oAuthSignatureMethod === "unde...
6.3
Complex
2
33
33
2
2
5
5
(parameters, argumentsToParse) => { var result = {}, len, idx, argument, parameter, name, lastNonPrefixIdx = 0; parameters = gpf.Parameter.create(pa...
6.5
Complex
2
27
27
7
7
8
8
const binl = (x, len) => { var T, j, i, l, h0 = 0x67452301, h1 = 0xefcdab89, h2 = 0x98badcfe, h3 = 0x10325476, h4 = 0xc3d2e1f0, A1, B1, C1, D1, E1, A2, B2, C2, D2, E2; /* append padding */ x[len >> 5] |= 0x80 << (len % 32); ...
6.2
Complex
2
36
36
19
19
2
2
const getTypeFromObjectBindingPattern = (pattern, includePatternInType, reportErrors) => { var members = ts.createMap(); var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (isComputedN...
3.4
Moderate
3
9
19
3
7
2
2
const addLoadToLinkSet = (linkSet, load) => { console.assert(load.status == 'loading' || load.status == 'loaded', 'loading or loaded on link set'); for (var i = 0, l = linkSet.loads.length; i < l; i++) if (linkSet.loads[i] == load) return; linkSet.loads.push(load); load.linkS...
5.4
Moderate
2
18
18
8
8
7
7
(renderer) => { var cache = this._cache; cache.use(renderer.__uid__); var chunks = cache.get('chunks'); if (chunks) { for (var c = 0; c < chunks.length; c++) { var chunk = chunks[c]; for (var k = 0; k < chunk.attributeBuffers.length; k++) { ...
5.3
Moderate
1
19
19
9
9
7
7
const parse = (content, options) => { options = options || {}; options = defaults(options, { addEsprimaInfo: false, parseJsDocTags: true, hideJsDocTags: true, trim: true }); var comments = []; var ast = esprima.parse(content, { tolerant: true, comment: true, tokens: true,...
6.1
Complex
2
19
19
6
6
4
4
(root, depth, context, delta) => { var i; var currentValue = context[depth]; var isMulti = currentValue.constructor === Array; if(depth === context.length-1) { if(isMulti) { for(i=0; i<currentValue.length; i++) { var curDelta = delta; ...
6.3
Complex
4
23
23
4
4
9
9
(key, value) => { if (typeof key !== 'string') { throw new TypeError('item key must be a string.'); } if (typeof value === 'undefined') { return this.getItem(key); } this.addItem(key, value); return value; }
2.6
Simple
2
6
6
0
0
2
2
(name, value) => { if (DOMProperty.isReservedProp(name)) { return false; } if ((name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { return false; } if (value === null) { return true; } switch (typeof value) { case 'boolean': return D...
5.1
Moderate
2
10
10
0
0
4
4
const removeCaretContainer = (caretContainer) => { var child, currentCaretContainer, lastContainer; if (caretContainer) { rng = selection.getRng(true); rng.setStartBefore(caretContainer); rng.setEndBefore(caretContainer); child = findFirstTextNode(caretContainer); if (child && ...
5.3
Moderate
1
18
18
3
3
5
5
(strategy, selector, mult, context) => { let ext = mult ? 's' : ''; let command = ''; context = !context ? context : `, '${context}'` ; switch (strategy) { case 'name': command = `au.getElement${ext}ByName('${selector}'${context})`; break; case 'accessibility id': com...
4.7
Moderate
4
14
14
2
2
1
1
const mergeMessages = (data) => { lastSync = (new Date()).getTime(); if (messages.length == 0) { messages = data; } else { var i = data.length - 1; var j = messages.length - 1; while (i >= 0 && j >= 0) { if (data[i].timestamp < messages[j].timestamp) { ...
3.8
Moderate
1
9
9
2
2
3
3
const selContainsNode = (selection, node, partialContainment) => { const nodeRange = node.ownerDocument.createRange(), iLen = selection.rangeCount; nodeRange.selectNodeContents(node); for (let i = 0; i < iLen; i++) { const selRange = selection.getRangeAt(i); // Edge bug (Issue #7321753); getRangeAt re...
6.1
Complex
3
16
16
4
4
5
5
const returnRankedIntents = (input, intents) => { return new Promise((resolve, reject) => { let lowerCase = input.toLowerCase(); let totalScore = 0; //loop through all loaded intents intents.forEach((intent) => { intent.score = 0; intent.utterences.forEach((u...
1.9
Simple
2
1
23
0
6
0
5
const then = (callback) => { if (typeof callback !== 'function') { throw new Error('Callback must be a function, instead got: ' + (typeof callback)); } function thenCallback (result) { callback(result); unbind('end', thenCallback); } bind('end', th...
1.2
Simple
1
5
7
0
0
1
1
const generate = () => { for(const i in Routes) { if(!Routes[i].generated) { Routes[i] = generateController(path.controllers, Routes[i]); } } for(const i in MiddleWares) { MiddleWares[i] = generateController(path.middlewares, MiddleWares[i]); } for(const i in GlobalMiddleWares) { Globa...
4.6
Moderate
0
11
11
5
5
6
6
const eliminateDuplicates = (browsers) => { var set = {}; browsers.forEach(function (browser) { var osgroup = browser.os; var subgroup = browser.long_name; var version = browser.short_version; var device; var browserName; if (browser.api_name === "iphone") { ...
6.1
Complex
1
4
29
2
7
0
3
() => { var UITinymceService = function() { var ID_ATTR = 'ui-tinymce'; // uniqueId keeps track of the latest assigned ID var uniqueId = 0; // getUniqueId returns a unique ID var getUniqueId = function() { uniqueId ++; return ID_ATTR + '-' + uniqueId; }; ...
1.2
Simple
0
2
8
0
2
0
2
(target, key, value, receiver) => { // If the receiver is not this observable (the observable might be on the proto chain), // set the key on the reciever. if (receiver !== this.proxy) { return makeObject.setKey(receiver, key, value, this); } // If it has a defined property definiition var computedValue...
6.1
Complex
4
9
22
2
6
2
5
const resetState = (node) => { _.each(node._tree.defaultState, (val, prop) => { node.state(prop, val); }); return node; }
1.2
Simple
1
2
3
0
0
0
1
const deserializeMember = (value, columnType) => { // Handle this special case first. // Simply return 'value' if a corresponding columnType is not defined. if (!columnType) { return value; } // Start by checking if the specified column type is valid. if (!isColumnTypeValid(colu...
6.9
Complex
2
24
24
2
2
4
4
const splitHtml = (html, opts, pcex) => { var _bp = pcex._bp // `brackets.split` is a heavy function, so don't call it if not necessary if (html && _bp[4].test(html)) { var jsfn = opts.expr && (opts.parser || opts.type) ? _compileJS : 0, list = brackets.split(html, 0, _bp), expr for (v...
5.9
Moderate
3
17
17
6
6
5
5
($nodeChart, data) => { var newSiblingCount = $.isArray(data) ? data.length : data.children.length; var existingSibligCount = $nodeChart.parent().is('td') ? $nodeChart.closest('tr').children().length : 1; var siblingCount = existingSibligCount + newSiblingCount; var insertPostion = (siblingCount...
5.7
Moderate
2
14
14
6
6
2
2
() => { // Assign 'this' to a variable for use in the closures below. var thisBlock = this; var dropdown = new Blockly.FieldDropdown( [[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, 'SPLIT'], [Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, 'JOIN']], function(newMode) { thisBlock.update...
1.2
Simple
0
9
16
2
3
0
2
const changeMetaState = (uri, update) => { return getMeta(uri) .then(old => mergeNewAndOldMeta(old, update)) .then(updatedMeta => putMeta(uri, updatedMeta)); }
1.1
Simple
2
1
1
0
0
0
1
(position, timeout, container) => { var self = this; setTimeout(function() { if (!self.isWadusAdded(container, 'cartodb-logo')) { var cartodb_link = document.createElement("div"); var is_retina = self.isRetinaBrowser(); cartodb_link.setAttribute('class','cartodb-logo'); car...
4.2
Moderate
3
2
11
1
5
0
2
const set_references = ( vm_options ) => { if ( vm_options.Dialog ) { Dialog = vm_options.Dialog; } if ( !Dialog ) { if ( typeof window !== 'undefined' && window.Dialog ) { Dialog = window.Dialog; } else { throw new Error( 'No r...
6.7
Complex
1
20
20
0
0
8
8
(sbm) => { // create the matrix var mat = {} mat.x = sbm.y mat.y = sbm.x mat.data = [] // populate for (var i = 0; i < mat.x; i++) { mat.data.push([]) for (var j = 0; j < mat.y; j++) { if (_.includes(sbm.data[j], i)) { mat.data[i].push(j) } } ...
3.5
Moderate
1
10
10
3
3
3
3
const filterWithQueryAndMatcher = (hints, matcher) => { var matchResults = $.map(hints, function (hint) { var searchResult = matcher.match(hint.value, query); if (searchResult) { searchResult.value = hint.value; searchResult.guess = hin...
5.7
Moderate
2
2
21
1
2
0
8
const edgeExtent = (graph, attribute) => { if (!isGraph(graph)) throw new Error('graphology-metrics/extent: the given graph is not a valid graphology instance.'); var attributes = [].concat(attribute); var edges = graph.edges(), edge, data, value, key, a, i, l; v...
5.6
Moderate
2
19
19
10
10
6
6
(done) => { var self = this; this.fire('updated'); this.fire('loading'); var map = this.options.map; this.getTiles(function(urls, err) { if(urls) { self.tilejson = urls; self.setUrl(self.tilejson.tiles[0]); // manage interaction self._reloadInteraction(); ...
3.7
Moderate
1
5
13
2
2
0
2
const Link = (rel, value) => { if (!(this instanceof Link)) { return new Link(rel, value); } if (!rel) throw new Error('Required <link> attribute "rel"'); this.rel = rel; if (typeof value === 'object') { // If value is a hashmap, just copy properties if (!value.href) throw new ...
5.1
Moderate
2
17
17
2
2
8
8
const getHash = () => { // Source SVG files contents o.files.forEach(function(file) { md5.update(fs.readFileSync(file, 'utf8')); }); // Options md5.update(JSON.stringify(o)); // grunt-webfont version var packageJson = require('../pkg.json'); md5.update(packageJson.version); // Template...
1.2
Simple
0
9
10
1
1
2
2
const off = (name, callback) => { var i, handlers, bindingName, names, hi; if (name) { names = name.toLowerCase().split(' '); i = names.length; while (i--) { name = names[i]; handlers = bindings[name]; // Unbind all handlers ...
6.3
Complex
2
27
27
5
5
10
10
const downloadDistantOrLoad = (fileUrl, f) => { if (!fileUrl || !_.isString(fileUrl)) { return f(); } var filename = path.basename(url.parse(fileUrl).path); debug('downloading %s -> %s', fileUrl, filename); request({ url: fileUrl }, function (err, resp, body) { if (err) { ...
3.2
Moderate
2
5
11
1
1
1
3
const VFile = (options) => { var prop var index var length if (!options) { options = {} } else if (typeof options === 'string' || buffer(options)) { options = {contents: options} } else if ('message' in options && 'messages' in options) { return options } if (!(this instanceof VFile)) { ...
5.7
Moderate
1
24
24
3
3
6
6
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
19