_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q50500 | getTargetTouch | train | function getTargetTouch (touches, target) {
return Array.prototype.slice.call(touches).filter(function (t) {
return t.target === target
})[0] || touches[0]
} | javascript | {
"resource": ""
} |
q50501 | train | function () {
// Scroll or window resize
$(window).on('resize scrollstop', _updateBoxes);
// User entry
$('input[type="number"]').on('keyup change click', events.onBoundaryChange); // 'click' is for spinners on input[number] control
// Boundary toggle
... | javascript | {
"resource": ""
} | |
q50502 | train | function (evt) {
var target = evt.target;
var val = parseInt(target.value, 10);
var id = target.id;
// Positive value was entered (negative values are allowed, but the boundaries would be off screen)
if (val > 0) {
if ($showBoundsCheck.is(':ch... | javascript | {
"resource": ""
} | |
q50503 | train | function (evt) {
// Ignore input fields
if ($(evt.target).is('input')) {
return true;
}
if (evt.shiftKey && 37 <= evt.keyCode && evt.keyCode <= 40) {
var key = 'key' + evt.keyCode;
var scrollVals = {
... | javascript | {
"resource": ""
} | |
q50504 | _drawBound | train | function _drawBound (side, dist) {
dist += 'px';
switch (side) {
case 'top':
$('.boundary-top').css({
top: dist,
height: dist,
marginTop: '-' + dist
});
break;
case 'right... | javascript | {
"resource": ""
} |
q50505 | viewCloud | train | function viewCloud(app) {
if (!app.config || !app.config.cloud) {
jitsu.log.error('Error: The app ' + app.name.magenta + ' don\'t have any cloud config.');
jitsu.log.error('You need deploy your app before get any cloud config.');
return callback(new Error());
}
jitsu.log.info('Viewing clou... | javascript | {
"resource": ""
} |
q50506 | setCloud | train | function setCloud(app) {
drones = drones || app.maxDrones;
ram = ram || (app.config.cloud ? app.config.cloud[0].ram : 256);
var cloud = {
datacenter: datacenter,
provider: provider,
drones: drones,
ram: ram
};
if (app.state === 'started') {
jitsu.log.info('App current... | javascript | {
"resource": ""
} |
q50507 | viewApp | train | function viewApp() {
jitsu.log.info('Fetching app ' + name.magenta);
jitsu.apps.view(name, function (err, app) {
if (err) {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
jitsu.log.help('Try running ' + 'jitsu deploy'.magenta);
return callback({});
... | javascript | {
"resource": ""
} |
q50508 | readApp | train | function readApp(next) {
jitsu.package.read(process.cwd(), function (err, pkg) {
if (err) {
callback(err);
}
name = pkg.name;
next();
});
} | javascript | {
"resource": ""
} |
q50509 | setupUserNoUsername | train | function setupUserNoUsername(callback) {
//
// Attempt to get the password three times.
//
var tries = 0;
function offerReset (username) {
jitsu.prompt.get(['reset'], function (err, res) {
if (err) {
return callback(err);
}
if (/^y[es]+/i.test(res['request pa... | javascript | {
"resource": ""
} |
q50510 | createDatabase | train | function createDatabase(database, callback) {
database.type = databases.alias(database.type);
//
// Make sure that the user is passing in a valid database type
//
if (databases.available.indexOf(database.type) === -1) {
jitsu.log.warn('Invalid database type ' + database.type.red);
data... | javascript | {
"resource": ""
} |
q50511 | isValid | train | function isValid(desc) {
if (desc.validator) {
if (desc.validator instanceof RegExp) {
return !desc.validator.test(value);
}
return !desc.validator(value);
}
return false;
} | javascript | {
"resource": ""
} |
q50512 | train | function(cmd) {
var lines = [], line
with (JavaImporter(java.lang, java.io)) {
var proccess = Runtime.getRuntime().exec(Array.prototype.slice.call(arguments))
var stream = new DataInputStream(proccess.getInputStream())
while (line = stream.readLine())
lines.push(line + '')
... | javascript | {
"resource": ""
} | |
q50513 | train | function(path) {
return path.lastIndexOf('.') != -1 ?
path.slice(path.lastIndexOf('.') + 1, path.length) :
null
} | javascript | {
"resource": ""
} | |
q50514 | train | function(msg, options) {
options = options || {}
var args = ['growlnotify', '-m', msg]
if (!this.binVersion()) throw new Error('growlnotify executable is required')
if (image = options.image) {
var flag, ext = this.extname(image)
flag = flag || ext == 'icns' && 'iconpath'
... | javascript | {
"resource": ""
} | |
q50515 | train | function() {
for (var name in this.commands)
if (this.commands.hasOwnProperty(name))
this.commands[name][1].length ?
this.main[name] = this.commands[name][1] :
this.main.__defineGetter__(name, this.commands[name][1])
} | javascript | {
"resource": ""
} | |
q50516 | createServer | train | function createServer () {
// Create server
var server = express.createServer();
// Configure Server
server.configure(function () {
// Built-in
server.use(express.methodOverride()); // Allow method override using _method form parameter
server.use(e... | javascript | {
"resource": ""
} |
q50517 | logConsole | train | function logConsole() {
return function (req, res, next) {
console.log('Received request: ' + req.method + ' ' + req.originalUrl);
next();
};
} | javascript | {
"resource": ""
} |
q50518 | signRequest | train | function signRequest(method, URI, host, port, token, secret, hashMethod, timestamp, nonce, bodyHash) {
// Parse request URI
var uri = URL.parse(URI, true);
if (uri.pathname == null) {
// Error: Bad request URI
return "";
}
// Construct normalized request string
var normaliz... | javascript | {
"resource": ""
} |
q50519 | percentEscape | train | function percentEscape(value) {
// Percent-escape per specification
var escapedString = '';
for (var i = 0; i < value.length; i++) {
var char = value.charCodeAt(i);
if ((char >= 48 && char <= 57) || // 09
(char >= 65 && char <= 90) || // AZ
(char >= 9... | javascript | {
"resource": ""
} |
q50520 | train | function(requestParameters, next) {
if(self.providerProvidesValidateNotReplayClient) {
self.provider.validateNotReplayClient(requestParameters.oauth_consumer_key, requestParameters.oauth_token, requestParameters.oauth_timestamp, requestParameters.oauth_nonce, function(err, result) {
if(err) {
... | javascript | {
"resource": ""
} | |
q50521 | kdtree | train | function kdtree() {
var kdtree = {},
axes = ["x", "y"],
root,
points = [];
kdtree.axes = function(x) {
if (!arguments.length) return axes;
axes = x;
return kdtree;
};
kdtree.points = function(x) {
if (!arguments.length) return points;
points = x;
root = null;
retu... | javascript | {
"resource": ""
} |
q50522 | train | function(path) {
if (JSpec.cache[path]) return JSpec.cache[path]
return JSpec.cache[path] =
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path) ||
JSpec.tryLoading(JSpec.options.fixturePath + '/' + path + '.html')
} | javascript | {
"resource": ""
} | |
q50523 | train | function(results, options) {
var uri = options.uri || 'http://' + window.location.host + '/results'
JSpec.post(uri, {
stats: JSpec.stats,
options: options,
results: map(results.allSuites, function(suite) {
if (suite.hasSpecs())
return {
... | javascript | {
"resource": ""
} | |
q50524 | train | function(results, options) {
var id = option('reportToId') || 'jspec'
var report = document.getElementById(id)
var failuresOnly = option('failuresOnly')
var classes = results.stats.failures ? 'has-failures' : ''
if (!report) throw 'JSpec requires the element #' + id + ' to output... | javascript | {
"resource": ""
} | |
q50525 | train | function(results, options) {
failuresOnly = option('failuresOnly')
print(color("\n Passes: ", 'bold') + color(results.stats.passes, 'green') +
color(" Failures: ", 'bold') + color(results.stats.failures, 'red') +
color(" Duration: ", 'bold') + color(results.duration, 'gr... | javascript | {
"resource": ""
} | |
q50526 | train | function(results, options) {
console.log('')
console.log('Passes: ' + results.stats.passes + ' Failures: ' + results.stats.failures)
each(results.allSuites, function(suite) {
if (suite.ran) {
console.group(suite.description)
each(suite.specs, function(spec){
... | javascript | {
"resource": ""
} | |
q50527 | train | function() {
return any(this.calls, function(call){
return self.expectedResult.an_instance_of ?
call.result.constructor == self.expectedResult.an_instance_of:
equal(self.expectedResult, call.result)
})
} | javascript | {
"resource": ""
} | |
q50528 | train | function() {
return any(this.calls, function(call){
return any(self.expectedArgs, function(i, arg){
return arg.an_instance_of ?
call.args[i].constructor == arg.an_instance_of:
equal(arg, call.args[i])
... | javascript | {
"resource": ""
} | |
q50529 | train | function(description, body) {
var self = this
extend(this, {
body: body,
description: description,
suites: [],
specs: [],
ran: false,
hooks: { 'before' : [], 'after' : [], 'before_each' : [], 'after_each' : [] },
// Add a spec to the suite
... | javascript | {
"resource": ""
} | |
q50530 | train | function(description, body) {
var spec = new JSpec.Spec(description, body)
this.specs.push(spec)
JSpec.stats.specs++ // TODO: abstract
spec.suite = this
} | javascript | {
"resource": ""
} | |
q50531 | train | function(description, body) {
var suite = new JSpec.Suite(description, body)
JSpec.allSuites.push(suite)
suite.name = suite.description
suite.description = this.description + ' ' + suite.description
this.suites.push(suite)
suite.suite = this
} | javascript | {
"resource": ""
} | |
q50532 | train | function(hook) {
if (this.suite) this.suite.hook(hook)
each(this.hooks[hook], function(body) {
JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + self.description + "': ")
})
} | javascript | {
"resource": ""
} | |
q50533 | train | function(description, body) {
extend(this, {
body: body,
description: description,
assertions: [],
// Add passing assertion
pass : function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.st... | javascript | {
"resource": ""
} | |
q50534 | train | function(message) {
this.assertions.push({ passed: true, message: message })
if (JSpec.assert) ++JSpec.stats.passes
} | javascript | {
"resource": ""
} | |
q50535 | train | function(message) {
this.assertions.push({ passed: false, message: message })
if (JSpec.assert) ++JSpec.stats.failures
} | javascript | {
"resource": ""
} | |
q50536 | train | function() {
each(this.assertions, function(assertion){
if (assertion.defer) assertion.run().report(), hook('afterAssertion', assertion)
})
} | javascript | {
"resource": ""
} | |
q50537 | train | function(object) {
var self = this
if (object == undefined || object == null) return 'null'
if (object === true) return 'true'
if (object === false) return 'false'
switch (typeof object) {
case 'number': return object
case 'string': return this.escapable.test(... | javascript | {
"resource": ""
} | |
q50538 | train | function(object) {
var module = object.constructor == JSpec.Module ? object : new JSpec.Module(object)
this.modules.push(module)
if ('init' in module) module.init()
if ('utilities' in module) extend(this.defaultContext, module.utilities)
if ('matchers' in module) this.addMatchers(module.ma... | javascript | {
"resource": ""
} | |
q50539 | train | function(name, args) {
args = toArray(arguments, 1)
return inject(JSpec.modules, [], function(results, module){
if (typeof module[name] == 'function')
results.push(JSpec.evalHook(module, name, args))
})
} | javascript | {
"resource": ""
} | |
q50540 | train | function(module, name, args) {
hook('evaluatingHookBody', module, name)
try { return module[name].apply(module, args) }
catch(e) { error('Error in hook ' + module.name + '.' + name + ': ', e) }
} | javascript | {
"resource": ""
} | |
q50541 | train | function(description) {
return find(this.allSuites, function(suite){
return suite.name == description || suite.description == description
})
} | javascript | {
"resource": ""
} | |
q50542 | train | function(fromSuite, toSuite) {
each(fromSuite.specs, function(spec){
spec.assertions = []
toSuite.specs.push(spec)
})
} | javascript | {
"resource": ""
} | |
q50543 | train | function(string, color) {
return "\u001B[" + {
bold : 1,
black : 30,
red : 31,
green : 32,
yellow : 33,
blue : 34,
magenta : 35,
cyan : 36,
white : 37
}[color] + 'm' + string + "\u001B[0m"
} | javascript | {
"resource": ""
} | |
q50544 | train | function(actual, expected, negate, name) {
return 'expected ' + puts(actual) + ' to ' +
(negate ? 'not ' : '') +
name.replace(/_/g, ' ') +
' ' + (expected.length > 1 ?
puts.apply(this, expected.slice(1)) :
'')
... | javascript | {
"resource": ""
} | |
q50545 | train | function(body) {
switch (body.constructor) {
case String:
if (captures = body.match(/^alias (\w+)/)) return JSpec.matchers[last(captures)]
if (body.length < 4) body = 'actual ' + body + ' expected'
return { match: function(actual, expected) { return eval(body) }}
... | javascript | {
"resource": ""
} | |
q50546 | train | function(key) {
return (value = query(key)) !== null ? value :
JSpec.options[key] || null
} | javascript | {
"resource": ""
} | |
q50547 | train | function(a, b) {
if (typeof a != typeof b) return
if (a === b) return true
if (a instanceof RegExp)
return a.toString() === b.toString()
if (a instanceof Date)
return Number(a) === Number(b)
if (typeof a != 'object') return
if (a.length !== undefined)
... | javascript | {
"resource": ""
} | |
q50548 | train | function(html) {
return html.toString()
.replace(/&/gmi, '&')
.replace(/"/gmi, '"')
.replace(/>/gmi, '>')
.replace(/</gmi, '<')
} | javascript | {
"resource": ""
} | |
q50549 | train | function(actual, matcher, expected) {
var assertion = new JSpec.Assertion(JSpec.matchers[matcher], actual, toArray(arguments, 2))
return assertion.run().result
} | javascript | {
"resource": ""
} | |
q50550 | train | function(actual) {
function assert(matcher, args, negate) {
var expected = toArray(args, 1)
matcher.negate = negate
assertion = new JSpec.Assertion(matcher, actual, expected, negate)
hook('beforeAssertion', assertion)
if (matcher.defer) assertion.run()
else JSpec.... | javascript | {
"resource": ""
} | |
q50551 | train | function(callback, a, b) {
return callback.length == 1 ? callback(b) : callback(a, b)
} | javascript | {
"resource": ""
} | |
q50552 | train | function(object, callback) {
if (object.constructor == Array)
for (var i = 0, len = object.length; i < len; ++i)
callIterator(callback, i, object[i])
else
for (var key in object)
if (object.hasOwnProperty(key))
callIterator(callback, key, object[key])
... | javascript | {
"resource": ""
} | |
q50553 | train | function(object, memo, callback) {
each(object, function(key, value){
memo = (callback.length == 2 ?
callback(memo, value):
callback(memo, key, value)) ||
memo
})
return memo
} | javascript | {
"resource": ""
} | |
q50554 | train | function(object, method) {
if (method) {
if (object['__prototype__' + method])
delete object[method]
else
object[method] = object['__original__' + method]
delete object['__prototype__' + method]
delete object['__original____' + method]
}
els... | javascript | {
"resource": ""
} | |
q50555 | train | function(object, method) {
hook('stubbing', object, method)
JSpec.stubbed.push(object)
var type = object.hasOwnProperty(method) ? '__original__' : '__prototype__'
object[type + method] = object[method]
object[method] = function(){}
return {
and_return : function(value)... | javascript | {
"resource": ""
} | |
q50556 | train | function(object, callback) {
return inject(object, [], function(memo, key, value){
memo.push(callIterator(callback, key, value))
})
} | javascript | {
"resource": ""
} | |
q50557 | train | function(object, callback) {
return inject(object, null, function(state, key, value){
if (state == undefined)
return callIterator(callback, key, value) ? value : state
})
} | javascript | {
"resource": ""
} | |
q50558 | train | function(object, callback) {
return inject(object, [], function(selected, key, value){
if (callIterator(callback, key, value))
selected.push(value)
})
} | javascript | {
"resource": ""
} | |
q50559 | train | function(name, body) {
hook('addingMatcher', name, body)
if (name.indexOf(' ') != -1) {
var matchers = name.split(/\s+/)
var prefix = matchers.shift()
each(matchers, function(name) {
JSpec.addMatcher(prefix + '_' + name, body(name))
})
}
this.matchers[na... | javascript | {
"resource": ""
} | |
q50560 | train | function(description, body) {
var suite = new JSpec.Suite(description, body)
hook('addingSuite', suite)
this.allSuites.push(suite)
this.suites.push(suite)
} | javascript | {
"resource": ""
} | |
q50561 | train | function(body, errorMessage) {
var dsl = this.DSL || this.DSLs.snake
var matchers = this.matchers
var context = this.context || this.defaultContext
var contents = this.contentsOf(body)
hook('evaluatingBody', dsl, matchers, context, contents)
try { with (dsl){ with (context) { with (m... | javascript | {
"resource": ""
} | |
q50562 | train | function(input) {
if (typeof input != 'string') return
input = hookImmutable('preprocessing', input)
return input.
replace(/\t/g, ' ').
replace(/\r\n|\n|\r/g, '\n').
split('__END__')[0].
replace(/([\w\.]+)\.(stub|destub)\((.*?)\)$/gm, '$2($1, $3)').
replace(/de... | javascript | {
"resource": ""
} | |
q50563 | train | function(start, end) {
var current = parseInt(start), end = parseInt(end), values = [current]
if (end > current) while (++current <= end) values.push(current)
else while (--current >= end) values.push(current)
return '[' + values + ']'
} | javascript | {
"resource": ""
} | |
q50564 | train | function() {
this.duration = Number(new Date) - this.start
hook('reporting', JSpec.options)
new (JSpec.options.reporter || JSpec.reporters.DOM)(JSpec, JSpec.options)
} | javascript | {
"resource": ""
} | |
q50565 | train | function(options) {
if (any(hook('running'), haveStopped)) return this
if (options) extend(this.options, options)
this.start = Number(new Date)
each(this.suites, function(suite) { JSpec.runSuite(suite) })
return this
} | javascript | {
"resource": ""
} | |
q50566 | train | function(suite) {
this.currentSuite = suite
this.evalBody(suite.body)
suite.ran = true
hook('beforeSuite', suite), suite.hook('before')
each(suite.specs, function(spec) {
hook('beforeSpec', spec)
suite.hook('before_each')
JSpec.runSpec(spec)
hook('afterSpec'... | javascript | {
"resource": ""
} | |
q50567 | train | function(spec) {
this.currentSpec = spec
try { this.evalBody(spec.body) }
catch (e) { fail(e) }
spec.runDeferredAssertions()
destub()
this.stats.specsFinished++
this.stats.assertions += spec.assertions.length
} | javascript | {
"resource": ""
} | |
q50568 | train | function(dependency, message) {
hook('requiring', dependency, message)
try { eval(dependency) }
catch (e) { throw 'JSpec depends on ' + dependency + ' ' + message }
return this
} | javascript | {
"resource": ""
} | |
q50569 | train | function(key, queryString) {
var queryString = (queryString || (main.location ? main.location.search : null) || '').substring(1)
return inject(queryString.split('&'), null, function(value, pair){
parts = pair.split('=')
return parts[0] == key ? parts[1].replace(/%20|\+/gmi, ' ') : value
... | javascript | {
"resource": ""
} | |
q50570 | train | function(message, e) {
if ('stack' in e)
require('util').puts(e.stack + '\n')
throw (message ? message : '') + e.toString() +
(e.line ? ' near line ' + e.line : '')
} | javascript | {
"resource": ""
} | |
q50571 | train | function(uri, data) {
if (any(hook('posting', uri, data), haveStopped)) return
var request = this.xhr()
request.open('POST', uri, false)
request.setRequestHeader('Content-Type', 'application/json')
request.send(JSpec.JSON.encode(data))
} | javascript | {
"resource": ""
} | |
q50572 | train | function(file, callback) {
if (any(hook('loading', file), haveStopped)) return
if ('readFile' in main)
return readFile(file)
else if (this.hasXhr()) {
var request = this.xhr()
request.open('GET', file, false)
request.send(null)
if (request.readyState == 4 &&
... | javascript | {
"resource": ""
} | |
q50573 | train | function(method, url, async, user, password) {
this.user = user
this.password = password
this.url = url
this.readyState = 1
this.method = method.toUpperCase()
if (async != undefined) this.async = async
if (this.async) this.onreadystatechange()
} | javascript | {
"resource": ""
} | |
q50574 | train | function(data) {
var self = this
this.data = data
this.readyState = 4
if (this.method == 'HEAD') this.responseText = null
this.responseHeaders['content-length'] = (this.responseText || '').length
if(this.async) this.onreadystatechange()
lastRequest = function(){
return ... | javascript | {
"resource": ""
} | |
q50575 | mockRequest | train | function mockRequest() {
return { and_return : function(body, type, status, headers) {
XMLHttpRequest = MockXMLHttpRequest
ActiveXObject = false
status = status || 200
headers = headers || {}
headers['content-type'] = type
JSpec.extend(XMLHttpRequest.prototype, {
response... | javascript | {
"resource": ""
} |
q50576 | train | function() {
return _.reduce(arguments, function(acc, elem) {
if (_.isArguments(elem)) {
return concat.call(acc, slice.call(elem));
}
else {
return concat.call(acc, elem);
}
}, []);
} | javascript | {
"resource": ""
} | |
q50577 | train | function(array, n, pad) {
var p = function(array) {
if (array == null) return [];
var part = _.take(array, n);
if (n === _.size(part)) {
return _.cons(part, p(_.drop(array, n)));
}
else {
return pad ? [_.take(_.cat(part, pad), n)] : [];
}
... | javascript | {
"resource": ""
} | |
q50578 | train | function(array, n, step) {
step = (step != null) ? step : n;
var p = function(array, n, step) {
if (_.isEmpty(array)) return [];
return _.cons(_.take(array, n),
p(_.drop(array, step), n, step));
};
return p(array, n, step);
} | javascript | {
"resource": ""
} | |
q50579 | train | function(array, fun) {
return _.cat.apply(null, _.map(array, fun));
} | javascript | {
"resource": ""
} | |
q50580 | train | function(array, inter) {
if (!_.isArray(array)) throw new TypeError;
var sz = _.size(array);
if (sz === 0) return array;
if (sz === 1) return array;
return slice.call(_.mapcat(array, function(elem) {
return _.cons(elem, [inter]);
}), 0, -1);
} | javascript | {
"resource": ""
} | |
q50581 | train | function(/* args */) {
if (!_.some(arguments)) return [];
if (arguments.length == 1) return arguments[0];
return _.filter(_.flatten(_.zip.apply(null, arguments), true), function(elem) {
return elem != null;
});
} | javascript | {
"resource": ""
} | |
q50582 | train | function(array, index) {
return [_.take(array, index), _.drop(array, index)];
} | javascript | {
"resource": ""
} | |
q50583 | train | function(array, n) {
var ret = [];
var sz = _.size(array);
if (n <= 0) return [];
if (n === 1) return array;
for(var index = 0; index < sz; index += n) {
ret.push(array[index]);
}
return ret;
} | javascript | {
"resource": ""
} | |
q50584 | train | function(array, fun, init) {
var ret = [];
var acc = init;
_.each(array, function(v,k) {
acc = fun(acc, array[k]);
ret.push(acc);
});
return ret;
} | javascript | {
"resource": ""
} | |
q50585 | train | function(array, pred) {
return _.filter(_.map(_.range(_.size(array)), function(i) {
return pred(i, array[i]);
}),
existy);
} | javascript | {
"resource": ""
} | |
q50586 | train | function(array, pred) {
if (!isSeq(array)) throw new TypeError;
var sz = _.size(array);
for (var index = 0; index < sz; index++) {
if(!truthy(pred(array[index]))) {
break;
}
}
return _.take(array, index);
} | javascript | {
"resource": ""
} | |
q50587 | train | function(array, pred) {
return [_.takeWhile(array, pred), _.dropWhile(array, pred)];
} | javascript | {
"resource": ""
} | |
q50588 | train | function(array, fun){
if (_.isEmpty(array) || !existy(array)) return [];
var fst = _.first(array);
var fstVal = fun(fst);
var run = concat.call([fst], _.takeWhile(_.rest(array), function(e) {
return _.isEqual(fstVal, fun(e));
}));
return concat.call([run], _.... | javascript | {
"resource": ""
} | |
q50589 | train | function(array, fun) {
return _.reduce(array, function(x, y) {
return fun(x, y) ? x : y;
});
} | javascript | {
"resource": ""
} | |
q50590 | train | function(array, fun) {
if (!isSeq(array)) throw new TypeError("expected an array as the first argument");
return _.filter(_.map(array, function(e) {
return fun(e);
}), existy);
} | javascript | {
"resource": ""
} | |
q50591 | train | function(obj, visitor, context) {
var result;
this.preorder(obj, function(value, key, parent) {
if (visitor.call(context, value, key, parent)) {
result = value;
return stopWalk;
}
}, context);
return result;
} | javascript | {
"resource": ""
} | |
q50592 | train | function(obj, strategy, visitor, context) {
return this.filter(obj, strategy, function(value, key, parent) {
return !visitor.call(context, value, key, parent);
});
} | javascript | {
"resource": ""
} | |
q50593 | train | function(obj, visitor, context, traversalStrategy) {
traversalStrategy = traversalStrategy || this._traversalStrategy;
walkImpl(obj, traversalStrategy, null, visitor, context);
} | javascript | {
"resource": ""
} | |
q50594 | train | function(obj, visitor, leafMemo, context) {
var reducer = function(value, key, parent, subResults) {
return visitor(subResults || leafMemo, value, key, parent);
};
return walkImpl(obj, this._traversalStrategy, null, reducer, context, true);
} | javascript | {
"resource": ""
} | |
q50595 | train | function(fun) {
var fixArgs = _.rest(arguments);
var f = function() {
var args = fixArgs.slice();
var arg = 0;
for ( var i = 0; i < (args.length || arg < arguments.length); i++ ) {
if ( args[i] === _ ) {
args[i] = arguments[arg++];
}
}
... | javascript | {
"resource": ""
} | |
q50596 | baseMapArgs | train | function baseMapArgs (fun, mapFun) {
return _.arity(fun.length, function () {
return fun.apply(this, __map.call(arguments, mapFun));
});
} | javascript | {
"resource": ""
} |
q50597 | train | function(/*, funs */){
var funs = (_.isArray(arguments[0])) ? arguments[0] : arguments;
return function(seed) {
return _.reduce(funs,
function(l,r) { return r(l); },
seed);
};
} | javascript | {
"resource": ""
} | |
q50598 | train | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.every(array, function(e) {
return _.every(preds, function(p) {
return p(e);
});
});
};
} | javascript | {
"resource": ""
} | |
q50599 | train | function(/* preds */) {
var preds = arguments;
return function(array) {
return _.some(array, function(e) {
return _.some(preds, function(p) {
return p(e);
});
});
};
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.