_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q62800 | getLanguagePriority | test | function getLanguagePriority(language, accepted, index) {
var priority = {o: -1, q: 0, s: 0};
for (var i = 0; i < accepted.length; i++) {
var spec = specify(language, accepted[i], index);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
... | javascript | {
"resource": ""
} |
q62801 | specify | test | function specify(language, spec, index) {
var p = parseLanguage(language)
if (!p) return null;
var s = 0;
if(spec.full.toLowerCase() === p.full.toLowerCase()){
s |= 4;
} else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) {
s |= 2;
} else if (spec.full.toLowerCase() === p.prefix.toLowerCase... | javascript | {
"resource": ""
} |
q62802 | preferredLanguages | test | function preferredLanguages(accept, provided) {
// RFC 2616 sec 14.4: no header = *
var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');
if (!provided) {
// sorted list of all languages
return accepts
.filter(isQuality)
.sort(compareSpecs)
.map(getFullLanguage);... | javascript | {
"resource": ""
} |
q62803 | compareSpecs | test | function compareSpecs(a, b) {
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
} | javascript | {
"resource": ""
} |
q62804 | parseAcceptCharset | test | function parseAcceptCharset(accept) {
var accepts = accept.split(',');
for (var i = 0, j = 0; i < accepts.length; i++) {
var charset = parseCharset(accepts[i].trim(), i);
if (charset) {
accepts[j++] = charset;
}
}
// trim accepts
accepts.length = j;
return accepts;
} | javascript | {
"resource": ""
} |
q62805 | parseCharset | test | function parseCharset(str, i) {
var match = simpleCharsetRegExp.exec(str);
if (!match) return null;
var charset = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';')
for (var j = 0; j < params.length; j++) {
var p = params[j].trim().split('=');
if (p[0] === 'q') {
... | javascript | {
"resource": ""
} |
q62806 | getCharsetPriority | test | function getCharsetPriority(charset, accepted, index) {
var priority = {o: -1, q: 0, s: 0};
for (var i = 0; i < accepted.length; i++) {
var spec = specify(charset, accepted[i], index);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
... | javascript | {
"resource": ""
} |
q62807 | specify | test | function specify(charset, spec, index) {
var s = 0;
if(spec.charset.toLowerCase() === charset.toLowerCase()){
s |= 1;
} else if (spec.charset !== '*' ) {
return null
}
return {
i: index,
o: spec.i,
q: spec.q,
s: s
}
} | javascript | {
"resource": ""
} |
q62808 | preferredCharsets | test | function preferredCharsets(accept, provided) {
// RFC 2616 sec 14.2: no header = *
var accepts = parseAcceptCharset(accept === undefined ? '*' : accept || '');
if (!provided) {
// sorted list of all charsets
return accepts
.filter(isQuality)
.sort(compareSpecs)
.map(getFullCharset);
}... | javascript | {
"resource": ""
} |
q62809 | parseEncoding | test | function parseEncoding(str, i) {
var match = simpleEncodingRegExp.exec(str);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var j = 0; j < params.length; j++) {
var p = params[j].trim().split('=');
if (p[0] === 'q') {
... | javascript | {
"resource": ""
} |
q62810 | getEncodingPriority | test | function getEncodingPriority(encoding, accepted, index) {
var priority = {o: -1, q: 0, s: 0};
for (var i = 0; i < accepted.length; i++) {
var spec = specify(encoding, accepted[i], index);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
... | javascript | {
"resource": ""
} |
q62811 | preferredEncodings | test | function preferredEncodings(accept, provided) {
var accepts = parseAcceptEncoding(accept || '');
if (!provided) {
// sorted list of all encodings
return accepts
.filter(isQuality)
.sort(compareSpecs)
.map(getFullEncoding);
}
var priorities = provided.map(function getPriority(type, in... | javascript | {
"resource": ""
} |
q62812 | parseAccept | test | function parseAccept(accept) {
var accepts = splitMediaTypes(accept);
for (var i = 0, j = 0; i < accepts.length; i++) {
var mediaType = parseMediaType(accepts[i].trim(), i);
if (mediaType) {
accepts[j++] = mediaType;
}
}
// trim accepts
accepts.length = j;
return accepts;
} | javascript | {
"resource": ""
} |
q62813 | parseMediaType | test | function parseMediaType(str, i) {
var match = simpleMediaTypeRegExp.exec(str);
if (!match) return null;
var params = Object.create(null);
var q = 1;
var subtype = match[2];
var type = match[1];
if (match[3]) {
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
for (var j = 0; j < kvps... | javascript | {
"resource": ""
} |
q62814 | getMediaTypePriority | test | function getMediaTypePriority(type, accepted, index) {
var priority = {o: -1, q: 0, s: 0};
for (var i = 0; i < accepted.length; i++) {
var spec = specify(type, accepted[i], index);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
re... | javascript | {
"resource": ""
} |
q62815 | specify | test | function specify(type, spec, index) {
var p = parseMediaType(type);
var s = 0;
if (!p) {
return null;
}
if(spec.type.toLowerCase() == p.type.toLowerCase()) {
s |= 4
} else if(spec.type != '*') {
return null;
}
if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {
s |= 2
} else... | javascript | {
"resource": ""
} |
q62816 | preferredMediaTypes | test | function preferredMediaTypes(accept, provided) {
// RFC 2616 sec 14.2: no header = */*
var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');
if (!provided) {
// sorted list of all types
return accepts
.filter(isQuality)
.sort(compareSpecs)
.map(getFullType);
}
var... | javascript | {
"resource": ""
} |
q62817 | quoteCount | test | function quoteCount(string) {
var count = 0;
var index = 0;
while ((index = string.indexOf('"', index)) !== -1) {
count++;
index++;
}
return count;
} | javascript | {
"resource": ""
} |
q62818 | splitKeyValuePair | test | function splitKeyValuePair(str) {
var index = str.indexOf('=');
var key;
var val;
if (index === -1) {
key = str;
} else {
key = str.substr(0, index);
val = str.substr(index + 1);
}
return [key, val];
} | javascript | {
"resource": ""
} |
q62819 | splitMediaTypes | test | function splitMediaTypes(accept) {
var accepts = accept.split(',');
for (var i = 1, j = 0; i < accepts.length; i++) {
if (quoteCount(accepts[j]) % 2 == 0) {
accepts[++j] = accepts[i];
} else {
accepts[j] += ',' + accepts[i];
}
}
// trim accepts
accepts.length = j + 1;
return accep... | javascript | {
"resource": ""
} |
q62820 | splitParameters | test | function splitParameters(str) {
var parameters = str.split(';');
for (var i = 1, j = 0; i < parameters.length; i++) {
if (quoteCount(parameters[j]) % 2 == 0) {
parameters[++j] = parameters[i];
} else {
parameters[j] += ';' + parameters[i];
}
}
// trim parameters
parameters.length = j... | javascript | {
"resource": ""
} |
q62821 | loadWebpackConfig | test | function loadWebpackConfig () {
var webpackConfig = require('./webpack.config.js');
webpackConfig.devtool = 'inline-source-map';
webpackConfig.module.preLoaders = [
{
test: /\.jsx?$/,
include: path.resolve('lib'),
loader: 'isparta'
}
];
return webpackConfig;
} | javascript | {
"resource": ""
} |
q62822 | assign | test | function assign (obj, keyPath, value) {
const lastKeyIndex = keyPath.length - 1
for (let i = 0; i < lastKeyIndex; ++i) {
const key = keyPath[i]
if (!(key in obj)) obj[key] = {}
obj = obj[key]
}
obj[keyPath[lastKeyIndex]] = value
} | javascript | {
"resource": ""
} |
q62823 | getFilterString | test | function getFilterString(selectedValues) {
if (selectedValues && Object.keys(selectedValues).length) {
return Object
// take all selectedValues
.entries(selectedValues)
// filter out filter components having some value
.filter(([, componentValues]) =>
filterComponents.includes(componentValues.compone... | javascript | {
"resource": ""
} |
q62824 | evaluatePage | test | function evaluatePage(page, fn) {
var args = Array.prototype.slice.call(arguments, 2);
return this.ready.then(function() {
var stack;
page = page || this.page;
var res = HorsemanPromise.fromCallback(function(done) {
// Wrap fn to be able to catch exceptions and reject Promise
stack = HorsemanPromise.re... | javascript | {
"resource": ""
} |
q62825 | waitForPage | test | function waitForPage(page, optsOrFn) {
var self = this;
var args, value, fname, timeout = self.options.timeout, fn;
if(typeof optsOrFn === "function"){
fn = optsOrFn;
args = Array.prototype.slice.call(arguments);
value = args.pop();
fname = fn.name || '<anonymous>';
} else if(typeof optsOrFn === "objec... | javascript | {
"resource": ""
} |
q62826 | Horseman | test | function Horseman(options) {
this.ready = false;
if (!(this instanceof Horseman)) { return new Horseman(options); }
this.options = defaults(clone(options) || {}, DEFAULTS);
this.id = ++instanceId;
debug('.setup() creating phantom instance %s', this.id);
var phantomOptions = {
'load-images': this.options.loadI... | javascript | {
"resource": ""
} |
q62827 | getColors | test | function getColors (image, cb) {
var data = [];
var img = createImage(image);
var promise = new Promise(function (resolve) {
img.onload = function () {
var canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0, img... | javascript | {
"resource": ""
} |
q62828 | createCubehelix | test | function createCubehelix (steps, opts) {
var data = [];
for (var i = 0; i < steps; i++ ){
data.push(cubehelix.rgb(i/steps, opts).map((v) => v/255));
}
return data;
} | javascript | {
"resource": ""
} |
q62829 | toImageData | test | function toImageData (colors) {
return colors.map((color) => color.map((v) => v*255).concat(255))
.reduce((prev, curr) => prev.concat(curr));
} | javascript | {
"resource": ""
} |
q62830 | compress | test | function compress (colors, factor) {
var data = [];
var len = (colors.length) / factor;
var step = (colors.length-1) / len;
for (var i = 0; i < colors.length; i+= step) {
data.push(colors[i|0]);
}
return data;
} | javascript | {
"resource": ""
} |
q62831 | toColormap | test | function toColormap (data) {
var stops = [];
for (var i = 0; i < data.length; i++) {
stops.push({
index: Math.round(i * 100 / (data.length - 1)) / 100,
rgb: data[i].map((v) => Math.round(v*255))
});
}
return stops;
} | javascript | {
"resource": ""
} |
q62832 | startDownload | test | function startDownload(src, storageFile) {
var uri = Windows.Foundation.Uri(src);
var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
var download = downloader.createDownload(uri, storageFile);
return download.startAsync();
} | javascript | {
"resource": ""
} |
q62833 | test | function(options) {
this._handlers = {
'progress': [],
'cancel': [],
'error': [],
'complete': []
};
// require options parameter
if (typeof options === 'undefined') {
throw new Error('The options argument is required.');
}
// require options.src paramete... | javascript | {
"resource": ""
} | |
q62834 | createAppChannel | test | function createAppChannel (app, key) {
assert(~['consumerChannel', 'publisherChannel'].indexOf(key),
'Channel key must be "consumerChannel" or "publisherChannel"')
assert(app.connection, 'Cannot create a channel without a connection')
assert(!app[key], 'Channel "' + key + '" already exists')
return co(func... | javascript | {
"resource": ""
} |
q62835 | errorHandler | test | function errorHandler (app, key, err) {
// delete app key
delete app[key]
// log and adjust err message
const msg = `"app.${key}" unexpectedly errored: ${err.message}`
debug(msg, err)
err.message = msg
// throw the error
throw err
} | javascript | {
"resource": ""
} |
q62836 | createAppConnection | test | function createAppConnection (app, url, socketOptions) {
assert(!app.connection, 'Cannot create connection if it already exists')
return co(function * () {
const conn =
app.connection =
yield amqplib.connect(url, socketOptions)
conn.__coworkersCloseHandler = module.exports.closeHandler.bind(... | javascript | {
"resource": ""
} |
q62837 | errorHandler | test | function errorHandler (app, err) {
delete app.connection
// log and adjust err message
const msg = `"app.connection" unexpectedly errored: ${err.message}`
debug(msg, err)
err.message = msg
// throw the error
throw err
} | javascript | {
"resource": ""
} |
q62838 | Application | test | function Application (options) {
if (!(this instanceof Application)) return new Application(options)
EventEmitter.call(this)
// options defaults
const env = getEnv()
const COWORKERS_CLUSTER = env.COWORKERS_CLUSTER
const COWORKERS_QUEUE = env.COWORKERS_QUEUE
const COWORKERS_QUEUE_WORKER_NUM = env.COWORKERS... | javascript | {
"resource": ""
} |
q62839 | assertAndConsumeAppQueue | test | function assertAndConsumeAppQueue (app, queueName) {
return co(function * () {
const queue = app.queueMiddlewares[queueName]
const queueOpts = queue.queueOpts
const consumeOpts = queue.consumeOpts
const handler = app.messageHandler(queueName)
yield app.consumerChannel.assertQueue(queueName, queue... | javascript | {
"resource": ""
} |
q62840 | parseShardFun | test | function parseShardFun (str /* : string */) /* : ShardV1 */ {
str = str.trim()
if (str.length === 0) {
throw new Error('empty shard string')
}
if (!str.startsWith(PREFIX)) {
throw new Error(`invalid or no path prefix: ${str}`)
}
const parts = str.slice(PREFIX.length).split('/')
const version = ... | javascript | {
"resource": ""
} |
q62841 | isEqualNode | test | function isEqualNode (a, b) {
return (
// Check if both nodes are ignored.
(isIgnored(a) && isIgnored(b)) ||
// Check if both nodes have the same checksum.
(getCheckSum(a) === getCheckSum(b)) ||
// Fall back to native isEqualNode check.
a.isEqualNode(b)
)
} | javascript | {
"resource": ""
} |
q62842 | dispatch | test | function dispatch (node, type) {
// Trigger event for this element if it has a key.
if (getKey(node)) {
var ev = document.createEvent('Event')
var prop = { value: node }
ev.initEvent(type, false, false)
Object.defineProperty(ev, 'target', prop)
Object.defineProperty(ev, 'srcElement', prop)
n... | javascript | {
"resource": ""
} |
q62843 | join | test | function join (socket, multiaddr, pub, cb) {
const log = socket.log = config.log.bind(config.log, '[' + socket.id + ']')
if (getConfig().strictMultiaddr && !util.validateMa(multiaddr)) {
joinsTotal.inc()
joinsFailureTotal.inc()
return cb('Invalid multiaddr')
}
if (getConfig().cryptoC... | javascript | {
"resource": ""
} |
q62844 | dataType | test | function dataType (value) {
if (!value) return null
if (value['anyOf'] || value['allOf'] || value['oneOf']) {
return ''
}
if (!value.type) {
return 'object'
}
if (value.type === 'array') {
return dataType(value.items || {}) + '[]'
}
return value.type
} | javascript | {
"resource": ""
} |
q62845 | pd | test | function pd(event) {
const retv = privateData.get(event);
console.assert(
retv != null,
"'this' is expected an Event object, but got",
event
);
return retv
} | javascript | {
"resource": ""
} |
q62846 | defineRedirectDescriptor | test | function defineRedirectDescriptor(key) {
return {
get() {
return pd(this).event[key]
},
set(value) {
pd(this).event[key] = value;
},
configurable: true,
enumerable: true,
}
} | javascript | {
"resource": ""
} |
q62847 | defineCallDescriptor | test | function defineCallDescriptor(key) {
return {
value() {
const event = pd(this).event;
return event[key].apply(event, arguments)
},
configurable: true,
enumerable: true,
}
} | javascript | {
"resource": ""
} |
q62848 | defineWrapper | test | function defineWrapper(BaseEvent, proto) {
const keys = Object.keys(proto);
if (keys.length === 0) {
return BaseEvent
}
/** CustomEvent */
function CustomEvent(eventTarget, event) {
BaseEvent.call(this, eventTarget, event);
}
CustomEvent.prototype = Object.create(BaseEvent.... | javascript | {
"resource": ""
} |
q62849 | getWrapper | test | function getWrapper(proto) {
if (proto == null || proto === Object.prototype) {
return Event
}
let wrapper = wrappers.get(proto);
if (wrapper == null) {
wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto);
wrappers.set(proto, wrapper);
}
return wrapp... | javascript | {
"resource": ""
} |
q62850 | wrapEvent | test | function wrapEvent(eventTarget, event) {
const Wrapper = getWrapper(Object.getPrototypeOf(event));
return new Wrapper(eventTarget, event)
} | javascript | {
"resource": ""
} |
q62851 | getListeners | test | function getListeners(eventTarget) {
const listeners = listenersMap.get(eventTarget);
if (listeners == null) {
throw new TypeError(
"'this' is expected an EventTarget object, but got another value."
)
}
return listeners
} | javascript | {
"resource": ""
} |
q62852 | defineEventAttributeDescriptor | test | function defineEventAttributeDescriptor(eventName) {
return {
get() {
const listeners = getListeners(this);
let node = listeners.get(eventName);
while (node != null) {
if (node.listenerType === ATTRIBUTE) {
return node.listener
... | javascript | {
"resource": ""
} |
q62853 | defineCustomEventTarget | test | function defineCustomEventTarget(eventNames) {
/** CustomEventTarget */
function CustomEventTarget() {
EventTarget.call(this);
}
CustomEventTarget.prototype = Object.create(EventTarget.prototype, {
constructor: {
value: CustomEventTarget,
configurable: true,
... | javascript | {
"resource": ""
} |
q62854 | test | function(fileName, retrying) {
let file = assets[fileName] || {};
let key = path.posix.join(uploadPath, fileName);
let putPolicy = new qiniu.rs.PutPolicy({ scope: bucket + ':' + key });
let uploadToken = putPolicy.uploadToken(mac);
let formUploader = new qiniu.form_up.FormUploade... | javascript | {
"resource": ""
} | |
q62855 | test | function(err) {
if (err) {
// eslint-disable-next-line no-console
console.log('\n');
return Promise.reject(err);
}
if (retryFilesCountDown < 0) retryFilesCountDown = 0;
// Get batch files
let _files = retryFiles.splice(
0,
batch... | javascript | {
"resource": ""
} | |
q62856 | test | function (ev) {
var nextPointers
if (!ev.defaultPrevented) {
if (_preventDefault) {
ev.preventDefault()
}
if (!_mouseDown) {
_mouseDown = true
nextPointers = utils.clone(_currPointers) // See [2]
nextPointers['mouse'] = [ev.pageX, ev.pageY]
if (!_sta... | javascript | {
"resource": ""
} | |
q62857 | teamcity | test | function teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
var flowId = document.title || new Date().getTime();
runner.on('suite', function (suite) {
if (suite.root) return;
suite.startDate = new Date();
log('##teamcity[testSuiteStarted name=\'' + escape(suite.title) + '\' flowId=\'' + flow... | javascript | {
"resource": ""
} |
q62858 | convert | test | function convert(integer) {
var str = Number(integer).toString(16);
return str.length === 1 ? '0' + str : str;
} | javascript | {
"resource": ""
} |
q62859 | parse | test | function parse(text, options) {
options = Object.assign({}, { relaxed: true }, options);
// relaxed implies not strict
if (typeof options.relaxed === 'boolean') options.strict = !options.relaxed;
if (typeof options.strict === 'boolean') options.relaxed = !options.strict;
return JSON.parse(text, (key, value)... | javascript | {
"resource": ""
} |
q62860 | stringify | test | function stringify(value, replacer, space, options) {
if (space != null && typeof space === 'object') (options = space), (space = 0);
if (replacer != null && typeof replacer === 'object')
(options = replacer), (replacer = null), (space = 0);
options = Object.assign({}, { relaxed: true }, options);
const do... | javascript | {
"resource": ""
} |
q62861 | serialize | test | function serialize(bson, options) {
options = options || {};
return JSON.parse(stringify(bson, options));
} | javascript | {
"resource": ""
} |
q62862 | makeDefineVirtualModule | test | function makeDefineVirtualModule(loader, load, addDep, args){
function namer(loadName){
var baseName = loadName.substr(0, loadName.indexOf("!"));
return function(part, plugin){
return baseName + "-" + part + (plugin ? ("." + plugin) : "");
};
}
function addresser(loadAddress){
return function(p... | javascript | {
"resource": ""
} |
q62863 | getFilename | test | function getFilename(name) {
var hash = name.indexOf('#');
var bang = name.indexOf('!');
return name.slice(hash < bang ? (hash + 1) : 0, bang);
} | javascript | {
"resource": ""
} |
q62864 | matchSemver | test | function matchSemver (myProtocol, senderProtocol, callback) {
const mps = myProtocol.split('/')
const sps = senderProtocol.split('/')
const myName = mps[1]
const myVersion = mps[2]
const senderName = sps[1]
const senderVersion = sps[2]
if (myName !== senderName) {
return callback(null, false)
}
... | javascript | {
"resource": ""
} |
q62865 | matchExact | test | function matchExact (myProtocol, senderProtocol, callback) {
const result = myProtocol === senderProtocol
callback(null, result)
} | javascript | {
"resource": ""
} |
q62866 | diffArrays | test | function diffArrays(arr1, arr2) {
if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
return true;
}
if (arr1.length !== arr2.length) {
return true;
}
for (var i = 0, len = arr1.length; i < len; i++) {
if (arr1[i] !== arr2[i]) {
... | javascript | {
"resource": ""
} |
q62867 | getSourceRuleString | test | function getSourceRuleString(sourceRule) {
function getRuleString(rule) {
if (rule.length === 1) {
return '"' + rule + '"';
}
return '("' + rule.join('" AND "') + '")';
}
return sourceRule.map(getRuleString).join(' OR ');
} | javascript | {
"resource": ""
} |
q62868 | getTimelineArgs | test | function getTimelineArgs(scope) {
var timelineArgs = {sourceType: scope.sourceType};
// if this is a valid sourceType...
if (rules.hasOwnProperty(scope.sourceType)) {
var sourceRules = rules[scope.sourceType];
var valid = false;
// Loop over the required args ... | javascript | {
"resource": ""
} |
q62869 | test | function(method,klass){
while(!!klass){
var key = null,
pro = klass.prototype;
// find method in current klass
Object.keys(pro).some(function(name){
if (method===pro[name]){
key = name;
return !0;
}
});
// me... | javascript | {
"resource": ""
} | |
q62870 | test | function(config){
_logger.info('begin dump files ...');
var map = {};
['fileInclude','fileExclude'].forEach(function(name){
var value = config[name];
if (!!value){
if (typeof value==='string'){
var reg = new RegExp(value,'i');
config[name] = functi... | javascript | {
"resource": ""
} | |
q62871 | test | function(config){
_logger.info('begin zip package ...');
var cmd = [
'java','-jar',
JSON.stringify(config.zip),
JSON.stringify(config.temp),
JSON.stringify(config.output)
].join(' ');
_logger.debug('do command: %s',cmd);
exec(cmd,function(error,stdout,stderr){
... | javascript | {
"resource": ""
} | |
q62872 | test | function(config){
if (!_fs.exist(config.output)){
return abortProcess(
config,'no package to be uploaded'
);
}
_logger.info('begin build upload form ...');
var form = new FormData();
var ex = _util.merge(
{
version: '0.1',
platform: 'ios&an... | javascript | {
"resource": ""
} | |
q62873 | test | function(config){
_logger.info('clear temporary directory and files');
_fs.rmdir(config.temp);
_fs.rm(config.output);
} | javascript | {
"resource": ""
} | |
q62874 | test | function(config){
var args = [].slice.call(arguments,0);
clearTemp(args.shift());
_logger.error.apply(_logger,args);
process.abort();
} | javascript | {
"resource": ""
} | |
q62875 | test | function(content){
var ret,
handler = function(map){
ret = map;
},
sandbox = {NEJ:{deps:handler, config:handler}};
// detect dep config
try{
//eval(content);
vm.createContext(sandbox);
vm.runInContext(content... | javascript | {
"resource": ""
} | |
q62876 | test | function(patform,deps,func){
var args = exports.formatARG.apply(
exports,arguments
);
if (!this.patches){
this.patches = [];
}
// illegal patch
if (!args[0]){
return;
}
// cache patch config
this.patches.push({
... | javascript | {
"resource": ""
} | |
q62877 | test | function(content){
// emulate NEJ patch env
var ret = {},
sandbox = {
NEJ:{
patch:_doPatch.bind(ret)
}
};
// eval content for nej patch check
try{
//eval(util.format('(%s)();',content));
v... | javascript | {
"resource": ""
} | |
q62878 | test | function(uri,deps,func){
var args = exports.formatARG.apply(
exports,arguments
);
this.isNEJ = !0;
this.dependency = args[1];
this.source = (args[2]||'').toString();
} | javascript | {
"resource": ""
} | |
q62879 | test | function(event){
if (event.type=='script'){
event.value = this._checkResInScript(
event.file,
event.content,
options
);
}
} | javascript | {
"resource": ""
} | |
q62880 | test | function(uri,config){
return this._formatURI(uri,{
fromPage:config.fromPage,
pathRoot:config.output,
webRoot:config.webRoot
});
} | javascript | {
"resource": ""
} | |
q62881 | test | function(uri,config){
uri = uri.replace(
config.srcRoot,
config.outHtmlRoot
);
return this._formatURI(uri,{
pathRoot:config.output,
webRoot:config.webRoot,
domain:config.mdlRoot
});
} | javascript | {
"resource": ""
} | |
q62882 | test | function(uri,config){
return uri.replace(
config.srcRoot,
config.outHtmlRoot
).replace(
config.webRoot,'/'
);
} | javascript | {
"resource": ""
} | |
q62883 | global | test | function global(map){
Object.keys(map).forEach(function(key){
var file = map[key],
arr = file.split('#'),
mdl = require('./lib/'+arr[0]+'.js');
// for util/logger#Logger
if (!!arr[1]){
// for util/logger#level,logger
var brr = arr[1].split(',')... | javascript | {
"resource": ""
} |
q62884 | fmix32 | test | function fmix32 (hash) {
hash ^= hash >>> 16
hash = multiply(hash, 0x85ebca6b)
hash ^= hash >>> 13
hash = multiply(hash, 0xc2b2ae35)
hash ^= hash >>> 16
return hash
} | javascript | {
"resource": ""
} |
q62885 | fmix32_pure | test | function fmix32_pure (hash) {
hash = (hash ^ (hash >>> 16)) >>> 0
hash = multiply(hash, 0x85ebca6b)
hash = (hash ^ (hash >>> 13)) >>> 0
hash = multiply(hash, 0xc2b2ae35)
hash = (hash ^ (hash >>> 16)) >>> 0
return hash
} | javascript | {
"resource": ""
} |
q62886 | bindKeys | test | function bindKeys (scope, obj, def, parentNode, path) {
var meta, key
if (typeof obj !== 'object' || obj === null)
throw new TypeError(
'Invalid type of value "' + obj + '", object expected.')
Object.defineProperty(obj, memoizedObjectKey, {
value: {},
configurable: true
})
Object.definePr... | javascript | {
"resource": ""
} |
q62887 | parentSetter | test | function parentSetter (x) {
var previousValue = memoizedObject[key]
var returnValue
// Optimistically set the memoized value, so it persists even if an error
// occurs after this point.
memoizedObject[key] = x
// Check for no-op.
if (x === previousValue) return x
// Need to qualify th... | javascript | {
"resource": ""
} |
q62888 | replaceNode | test | function replaceNode (value, previousValue, i) {
var activeNode = activeNodes[i]
var currentNode = node
var returnValue
// Cast values to null if undefined.
if (value === void 0) value = null
if (previousValue === void 0) previousValue = null
// If value is null, just remove the Node.
... | javascript | {
"resource": ""
} |
q62889 | pop | test | function pop () {
var i = this.length - 1
var previousValue = previousValues[i]
var value = Array.prototype.pop.call(this)
removeNode(null, previousValue, i)
previousValues.length = activeNodes.length = this.length
return value
} | javascript | {
"resource": ""
} |
q62890 | changeValue | test | function changeValue (node, value, attribute) {
var firstChild
switch (attribute) {
case 'textContent':
firstChild = node.firstChild
if (firstChild && !firstChild.nextSibling &&
firstChild.nodeType === TEXT_NODE)
firstChild.textContent = value
else node.textContent = value
break
cas... | javascript | {
"resource": ""
} |
q62891 | getNextNode | test | function getNextNode (index, activeNodes) {
var i, j, nextNode
for (i = index, j = activeNodes.length; i < j; i++)
if (activeNodes[i]) {
nextNode = activeNodes[i]
break
}
return nextNode
} | javascript | {
"resource": ""
} |
q62892 | updateChange | test | function updateChange (targetKey, path, key) {
var target = path.target
var index = path.index
var replaceKey = key
if (typeof index === 'number') {
target = target[key]
replaceKey = index
}
return function handleChange (event) {
target[replaceKey] = event.target[targetKey]
}
} | javascript | {
"resource": ""
} |
q62893 | simulacra | test | function simulacra (obj, def, matchNode) {
var document = this ? this.document : window.document
var Node = this ? this.Node : window.Node
var node, query
// Before continuing, check if required features are present.
featureCheck(this || window, features)
if (obj === null || typeof obj !== 'object' || isA... | javascript | {
"resource": ""
} |
q62894 | cleanNode | test | function cleanNode (scope, node) {
// A constant for showing text nodes.
var showText = 0x00000004
var document = scope ? scope.document : window.document
var treeWalker = document.createTreeWalker(
node, showText, processNodes.acceptNode, false)
var textNode
while (treeWalker.nextNode()) {
textNod... | javascript | {
"resource": ""
} |
q62895 | processNodes | test | function processNodes (scope, node, def) {
var document = scope ? scope.document : window.document
var key, branch, result, mirrorNode, parent, marker, indices
var i, j, treeWalker, orderedKeys
result = def[templateKey]
if (!result) {
node = node.cloneNode(true)
indices = []
matchNodes(scope, ... | javascript | {
"resource": ""
} |
q62896 | matchNodes | test | function matchNodes (scope, node, def) {
var document = scope ? scope.document : window.document
var treeWalker = document.createTreeWalker(
node, showAll, acceptNode, false)
var nodes = []
var i, j, key, currentNode, childWalker
var nodeIndex = 0
// This offset is a bit tricky, it's used to determine ... | javascript | {
"resource": ""
} |
q62897 | rehydrate | test | function rehydrate (scope, obj, def, node, matchNode) {
var document = scope ? scope.document : window.document
var key, branch, x, value, change, definition, mount, keyPath
var meta, valueIsArray, activeNodes, index, treeWalker, currentNode
for (key in def) {
branch = def[key]
meta = obj[metaKey][key... | javascript | {
"resource": ""
} |
q62898 | render | test | function render (obj, def, html) {
var i, nodes, handler, parser, element, elementPrototype
// If given bindings with a root node, pick only the binding keys.
if (Array.isArray(def)) def = def[1]
// Generating the render function is processing intensive. Skip if possible.
if (renderFnKey in def) return def[... | javascript | {
"resource": ""
} |
q62899 | featureCheck | test | function featureCheck (globalScope, features) {
var i, j, k, l, feature, path
for (i = 0, j = features.length; i < j; i++) {
path = features[i]
if (typeof path[0] === 'string') {
feature = globalScope
for (k = 0, l = path.length; k < l; k++) {
if (!(path[k] in feature)) throw new Erro... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.