_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q40000 | getBehavioralDirectives | train | function getBehavioralDirectives(appName) {
var directives = {};
var me = this;
_.each(this.getAppFileNames(appName, 'jng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
// get the dire... | javascript | {
"resource": ""
} |
q40001 | getClientDirectives | train | function getClientDirectives(appName) {
var directives = [];
var me = this;
_.each(this.getAppFileNames(appName, 'ng.directives'), function (directiveName) {
// if not a JavaScript file, ignore it
if (!me.pancakes.utils.isJavaScript(directiveName)) { return; }
directiveName = dire... | javascript | {
"resource": ""
} |
q40002 | getGenericDirective | train | function getGenericDirective(prefix, attrName, filterType, isBind, isFilter) {
var directiveName = prefix + attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
var config = this.pancakes.cook('config', null);
var i18n = this.pancakes.cook('i18n', null);
var eventBus = this.pancakes.cook('eve... | javascript | {
"resource": ""
} |
q40003 | getGenericDirectives | train | function getGenericDirectives() {
var directives = {};
var genericDirectives = {
'src': 'file',
'title': 'i18n',
'placeholder': 'i18n',
'popover': 'i18n',
'value': 'i18n',
'alt': 'i18n',
'text': 'i18n',
... | javascript | {
"resource": ""
} |
q40004 | addDirectivesToJangular | train | function addDirectivesToJangular(directives) {
_.each(directives, function (directive, directiveName) {
jangular.addDirective(directiveName, directive);
});
} | javascript | {
"resource": ""
} |
q40005 | f_rol_tumu | train | function f_rol_tumu(_tahta_id) {
return result.dbQ.smembers(result.kp.tahta.ssetOzelTahtaRolleri(_tahta_id, true))
.then(function (_rol_idler) {
return f_rol_id(_rol_idler);
});
} | javascript | {
"resource": ""
} |
q40006 | getLitmusForModule | train | function getLitmusForModule (module) {
if (isLitmus(module)) {
return module;
}
if (module.test && isLitmus(module.test)) {
return module.test;
}
throw new Error('litmus: expected module to export litmus.Test or litmus.Suite');
} | javascript | {
"resource": ""
} |
q40007 | train | function (elbName, cb) {
query(elbName, function (err, data) {
if (err) return cb(err);
var result = [];
data.Instances.map(function (item) { result.push(item.InstanceId); });
cb(undefined, result);
});
} | javascript | {
"resource": ""
} | |
q40008 | isEventValid | train | function isEventValid (comp, type) {
// if a component has aleary triggered 'appear' event, then
// the 'appear' even† can't be triggered again utill the
// 'disappear' event triggered.
if (appearEvts.indexOf(type) <= -1) {
return true
}
if (comp._appear === undefined && type === 'disappear') {
retu... | javascript | {
"resource": ""
} |
q40009 | splitIntoSlabs | train | function splitIntoSlabs(str) {
var slabs = str.split('<!-- TEXTBLOCK -->');
return slabs.map(function(val, index, array) {
if (index % 2 == 1) {
var rawAttr = val.match(/<code>(.*)<\/code>/);
var attrs = JSON.parse(decodeURI(rawAttr[1]));
return attrs;
} else {
return val;
}
})... | javascript | {
"resource": ""
} |
q40010 | train | function(source, format, ctx) {
if (inputFormats.hasOwnProperty(format)) {
return inputFormats[format](source, ctx);
} else {
throw new Error('invalid format to make a text block from: ' + source.format);
}
} | javascript | {
"resource": ""
} | |
q40011 | train | function(source, ctx) {
if (source.hasOwnProperty('format')) {
if (validateFormats.hasOwnProperty(source.format)) {
return validateFormats[source.format](source, ctx);
} else {
throw new Error('invalid format for textblock: ' + source.format);
}
}
throw new Error('invalid format for textbl... | javascript | {
"resource": ""
} | |
q40012 | train | function(source, type) {
if (source.hasOwnProperty('format')) {
if (source.format !== type) {
if (source.format === 'section') {
var blocks = [];
source.blocks.forEach(function(val, index, array) {
var block = deleteTextBlockFormat(val, type);
if (block) {
blo... | javascript | {
"resource": ""
} | |
q40013 | train | function(blocks) {
var blockarr = blocks;
if (!(blockarr instanceof Array)) {
blockarr = [blockarr];
}
return {format: 'section', blocks: blockarr};
} | javascript | {
"resource": ""
} | |
q40014 | train | function(block, pos, ctx, callback) {
if (block.hasOwnProperty('htmlslabs')) {
outputSlabs(block.htmlslabs, ctx, callback);
} else {
if (formats.hasOwnProperty(block.format)) {
formats[block.format](block, pos, ctx, callback);
} else {
callback(new Error('unknown format: ' + block.format));
... | javascript | {
"resource": ""
} | |
q40015 | train | function(block) {
if (block.hasOwnProperty('htmlslabs')) {
return outputSlabsAsText(block.htmlslabs);
} else {
if (block.format === 'section') {
return block.blocks.reduce(function(previousValue, currentValue, currentIndex, array) {
return previousValue + extractTextBlockText(currentValue);
... | javascript | {
"resource": ""
} | |
q40016 | execute | train | function execute(req, res) {
var scanner = new Scanner(
req.db.getKeys(), req.info.cursor, req.info.pattern, req.info.count);
scanner.scan(req, res);
} | javascript | {
"resource": ""
} |
q40017 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = info.exec.offset
, arg = args[offset];
if(args.length > offset + 4) {
throw new CommandArgLength(info.exec.definition.name);
}
// cursor already parsed to integer by numeric validation
info... | javascript | {
"resource": ""
} |
q40018 | singletco | train | function singletco(partition) {
var select = function select(compare, a, i, j, k) {
while (true) {
if (j - i < 2) return;
var p = partition(compare, a, i, j);
if (k < p) j = p;else if (k > p) i = p + 1;else return;
}
};
return select;
} | javascript | {
"resource": ""
} |
q40019 | BlurXFilter | train | function BlurXFilter()
{
core.AbstractFilter.call(this,
// vertex shader
fs.readFileSync(__dirname + '/blurX.vert', 'utf8'),
// fragment shader
fs.readFileSync(__dirname + '/blur.frag', 'utf8'),
// set the uniforms
{
strength: { type: '1f', value: 1 }
... | javascript | {
"resource": ""
} |
q40020 | ActivityTask | train | function ActivityTask(task) {
if (!(this instanceof ActivityTask)) {
return new ActivityTask(task);
}
this.input = {};
if (task.config.input) {
this.input = JSON.parse(task.config.input);
}
// Depending on the language of the Decider impl, this can be an Array or Object
// This is a big assumpt... | javascript | {
"resource": ""
} |
q40021 | backboneOptsAsProps | train | function backboneOptsAsProps(subject, opts) {
if (!opts) {
opts = subject.options
}
subject.mergeOptions(subject.options, _.keys(opts));
//removing form view.options the options that ve been merged above
//so if we use view.getOption("opt") will return the merged opt and not the opt in view... | javascript | {
"resource": ""
} |
q40022 | omitBackboneOptsAsProps | train | function omitBackboneOptsAsProps(subject, omit) {
console.log("omitBackboneOptsAsProps:")
console.log(subject, subject.options, omit, _.omit(subject.options, omit))
backboneOptsAsProps(subject, _.omit(subject.options, omit))
} | javascript | {
"resource": ""
} |
q40023 | kappInit | train | function kappInit(subject, callback) {
//if expose option is added we expose this view
console.log("kappInit:", subject)
if (subject.getOption("expose_as")) {
console.log("kappInit: found exposeAs option " + subject.getOption("expose_as"))
subject.exposeAs(subject.getOption("expose_as"))
... | javascript | {
"resource": ""
} |
q40024 | lang | train | function lang(key, source) {
//first we retrive the lang value of the root of the DOM
var LANG = document.documentElement.lang;
//console.log(source)
//console.log(LANG+' '+key+' - '+source[LANG][key]);
if (_.isObject(source) && _.isObject(source[LANG]) && _.isString(source[LANG][key])) {
re... | javascript | {
"resource": ""
} |
q40025 | expose | train | function expose(subject, name) {
//console.log(window[name])
if (subject.isRendered()) {
exposer(subject, name);
} else {
subject.on("attach", function () {
exposer(subject, name);
})
}
} | javascript | {
"resource": ""
} |
q40026 | commutate | train | function commutate(key, list) {
_.each(list, function (v, k, l) {
if (k === key) {
l[key] = true
}
if (v === true && k !== key) {
l[k] = false
}
})
} | javascript | {
"resource": ""
} |
q40027 | Preprocessor | train | function Preprocessor(config, logger) {
const log = logger.create('preprocessor.gzip');
return (content, file, done) => {
const originalSize = content.length;
// const contentBuffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
zlib.gzip(content, (err, gzippedContent) => {
if (err... | javascript | {
"resource": ""
} |
q40028 | scrollPage | train | function scrollPage(to, offset, callback) {
if ( offset === void 0 ) offset = 0;
var startTime;
var duration = 500;
var startPos = window.pageYOffset;
var endPos = ~~(to.getBoundingClientRect().top - offset);
var scroll = function (timestamp) {
var elapsed;
startTime = startTime || timestamp;
... | javascript | {
"resource": ""
} |
q40029 | $$ | train | function $$(els) {
return els instanceof NodeList ? Array.prototype.slice.call(els) :
els instanceof HTMLElement ? [els] :
typeof els === 'string' ? Array.prototype.slice.call(document.querySelectorAll(els)) :
[];
} | javascript | {
"resource": ""
} |
q40030 | requestHandler | train | function requestHandler (method) {
return function (req, res, next) {
method.call(this, req, responseHandler(res, next));
}.bind(this);
} | javascript | {
"resource": ""
} |
q40031 | responseHandler | train | function responseHandler (res, next) {
return function (err, message) {
if (err || !message) {
next(err);
} else {
res.send(message);
}
}
} | javascript | {
"resource": ""
} |
q40032 | getPasswordObj | train | function getPasswordObj (values, keys) {
var passwordObj = {};
(keys || Object.keys(values)).forEach(function (key) {
passwordObj[values[key].password] = key;
});
return passwordObj;
} | javascript | {
"resource": ""
} |
q40033 | getResetterObj | train | function getResetterObj (values, keys) {
var resetterObj = {};
(keys || Object.keys(values)).forEach(function (key) {
if (values[key].resetter) {
resetterObj[values[key].resetter] = key;
}
});
return resetterObj;
} | javascript | {
"resource": ""
} |
q40034 | _first_split | train | function _first_split(character, string){
var retlist = null;
var eq_loc = string.indexOf(character);
if( eq_loc == 0 ){
retlist = ['', string.substr(eq_loc +1, string.length)];
}else if( eq_loc > 0 ){
var before = string.substr(0, eq_loc);
var after = string.substr(eq_loc +1, string.length);
... | javascript | {
"resource": ""
} |
q40035 | train | function(str, lim, suff){
var ret = str;
var limit = 10;
if( lim ){ limit = lim; }
var suffix = '';
if( suff ){ suffix = suff; }
if( str.length > limit ){
ret = str.substring(0, (limit - suffix.length)) + suffix;
}
return ret;
} | javascript | {
"resource": ""
} | |
q40036 | train | function(older_hash, newer_hash){
if( ! older_hash ){ older_hash = {}; }
if( ! newer_hash ){ newer_hash = {}; }
var ret_hash = {};
function _add (val, key){
ret_hash[key] = val;
}
each(older_hash, _add);
each(newer_hash, _add);
return ret_hash;
} | javascript | {
"resource": ""
} | |
q40037 | train | function(in_thing, filter_function, sort_function){
var ret = [];
// Probably an not array then.
if( typeof(in_thing) === 'undefined' ){
// this is a nothing, to nothing....
}else if( typeof(in_thing) != 'object' ){
throw new Error('Unsupported type in bbop.core.pare: ' +
typeof(in_thing) );
}e... | javascript | {
"resource": ""
} | |
q40038 | train | function(iobj, interface_list){
var retval = true;
each(interface_list, function(iface){
//print('|' + typeof(in_key) + ' || ' + typeof(in_val));
//print('|' + in_key + ' || ' + in_val);
if( typeof(iobj[iface]) == 'undefined' &&
typeof(iobj.prototype[iface]) == 'undefined' ){
retval = false;
... | javascript | {
"resource": ""
} | |
q40039 | train | function(qargs){
var mbuff = [];
for( var qname in qargs ){
var qval = qargs[qname];
// null is technically an object, but we don't want to render
// it.
if( qval != null ){
if( typeof qval == 'string' || typeof qval == 'number' ){
// Is standard name/value pair.
var nano_buffer = ... | javascript | {
"resource": ""
} | |
q40040 | train | function(len){
var random_base = [
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
];
var length = len || 10;
var cache = new Array();
for( var ii = 0; ii < length; ii+... | javascript | {
"resource": ""
} | |
q40041 | train | function(url){
var retlist = [];
// Pull parameters.
var tmp = url.split('?');
var path = '';
var parms = [];
if( ! tmp[1] ){ // catch bad url--nothing before '?'
parms = tmp[0].split('&');
}else{ // normal structure
path = tmp[0];
parms = tmp[1].split('&');
}
// Decompose parameters.
each(p... | javascript | {
"resource": ""
} | |
q40042 | train | function(str){
var retstr = str;
if( ! us.isUndefined(str) && str.length > 2 ){
var end = str.length -1;
if( str.charAt(0) == '"' && str.charAt(end) == '"' ){
retstr = str.substr(1, end -1);
}
}
return retstr;
} | javascript | {
"resource": ""
} | |
q40043 | train | function(str, delimiter){
var retlist = null;
if( ! us.isUndefined(str) ){
if( us.isUndefined(delimiter) ){
delimiter = /\s+/;
}
retlist = str.split(delimiter);
}
return retlist;
} | javascript | {
"resource": ""
} | |
q40044 | insertRight | train | function insertRight(parent, node) {
var index = parent.length - 1;
parent[index] = node;
parent.sizes[index] = (0, _util.length)(node) + (index > 0 ? parent.sizes[index - 1] : 0);
} | javascript | {
"resource": ""
} |
q40045 | splitTemplate | train | function splitTemplate (template) {
if (!template) {
return []
}
return split(template).filter((seg) => seg !== '' && seg !== undefined)
} | javascript | {
"resource": ""
} |
q40046 | createHeader | train | function createHeader (type, size) {
var header = new Buffer(8);
header.writeUInt8(type, 0);
header.writeUInt32BE(size, 4);
return header;
} | javascript | {
"resource": ""
} |
q40047 | validateArgs | train | function validateArgs (type, payload) {
if (!type) {
return new Error('type is required');
}
if (!payload) {
return new Error('payload is required');
}
if (!isNumber(type)) {
return new Error('type must be a number');
}
if (!isBuffer(payload) && !isString(payload)) {
return new Error('payl... | javascript | {
"resource": ""
} |
q40048 | sync | train | function sync(fn) {
return function(done) {
var res = isGenerator(fn) ? co(fn) : fn(done);
if (isPromise(res)) {
res.then(function(){ done(); }, done);
} else {
fn.length || done();
}
};
} | javascript | {
"resource": ""
} |
q40049 | train | function(regex){
//if it isn't global, `exec()` will not start at `lastIndex`
if(!regex.global)
regex.compile(regex.source, flags(regex));
regex.lastIndex = this.position;
var m = regex.exec(this.source);
//all matches must start at the current position.
if(m && m.index!=this.position){
return null;
... | javascript | {
"resource": ""
} | |
q40050 | get | train | function get(tree, i) {
if (i < 0 || i >= tree.size) {
return undefined;
}
var offset = (0, _util.tailOffset)(tree);
if (i >= offset) {
return tree.tail[i - offset];
}
return (0, _util.getRoot)(i, tree.root);
} | javascript | {
"resource": ""
} |
q40051 | formatjson | train | function formatjson(pis) {
return pis.map(function(pi) {
var newpi = {};
newpi[pi.tag] = pi.att;
return newpi;
});
} | javascript | {
"resource": ""
} |
q40052 | enumerate | train | function enumerate(collection) {
if (isObject(collection)) {
if (collection instanceof Map) {
return enumerateMap(collection)
} else if (isIterable(collection)) {
return enumerateIterable(collection)
} else {
return enumerateObject(collection)
}
... | javascript | {
"resource": ""
} |
q40053 | sightread | train | function sightread(element, childRegistry) {
if (!element || element === document) element = window;
if (!childRegistry && !getChildRegistry(element)) return;
// Clear the child registry.
if (!childRegistry) {
element.__private__.childRegistry = {};
childRegistry = getChildRegistry(element);
}
ele... | javascript | {
"resource": ""
} |
q40054 | lintStyles | train | function lintStyles(conf, undertaker) {
const sassSrc = path.join(conf.themeConfig.root, conf.themeConfig.sass.src, '**', '*.scss');
let stylelintConf = {
config: require('./stylelint.config'),
reporters: [{
formatter: 'string',
console: true
}],
failAfterError: conf.productionMode
}... | javascript | {
"resource": ""
} |
q40055 | render | train | function render(history, routes, store) {
const resolve = resolver(routes);
return function(location) {
resolve(location)
.then(config => {
renderPage(config.page(store, history), routes);
const actionParams = config.matchRoute(location.pathname).params;
c... | javascript | {
"resource": ""
} |
q40056 | resolver | train | function resolver(routes) {
return async function(context) {
const uri = context.error ? '/error' : context.pathname;
return routes.find(route => route.matchRoute(uri));
}
} | javascript | {
"resource": ""
} |
q40057 | Connection | train | function Connection(conn) {
if(!(this instanceof Connection)) {
return new Connection(conn);
}
var self = this;
if(!conn) { throw new TypeError("no connection set"); }
self._connection = conn;
} | javascript | {
"resource": ""
} |
q40058 | train | function(opts) {
opts = opts || {};
this.root = opts.path;
this.interval = opts.interval || DEFAULT_INTERVAL;
} | javascript | {
"resource": ""
} | |
q40059 | MySQL | train | function MySQL(config) {
var self = this;
config = config || {};
config.host = config.host || 'localhost';
config.port = config.port || 3306;
this.className = this.constructor.name;
this.config = config;
// Set client
this.client = mysql.createConnection(config);
// Assign storage
if... | javascript | {
"resource": ""
} |
q40060 | ANSIState | train | function ANSIState(legacy) {
var feed = '',
last_match = '',
stream_match = [],
_this = this;
PassThrough.call(this);
this.attrs = {};
this.reset();
this.is_reset = false;
this.setEncoding('utf8');
this.on('data', function(chunk) {
feed += chunk;
i... | javascript | {
"resource": ""
} |
q40061 | initClickEvent | train | function initClickEvent (tabheader) {
const box = tabheader.box
box.addEventListener('click', function (evt) {
let target = evt.target
if (target.nodeName === 'UL') {
return
}
if (target.parentNode.nodeName === 'LI') {
target = target.parentNode
}
const floor = target.getAttri... | javascript | {
"resource": ""
} |
q40062 | doScroll | train | function doScroll (node, val, finish) {
if (!val) {
return
}
if (finish === undefined) {
finish = Math.abs(val)
}
if (finish <= 0) {
return
}
setTimeout(function () {
if (val > 0) {
node.scrollLeft += 2
}
else {
node.scrollLeft -= 2
}
finish -= 2
doScroll... | javascript | {
"resource": ""
} |
q40063 | getScrollVal | train | function getScrollVal (rect, node) {
const left = node.previousSibling
const right = node.nextSibling
let scrollVal
// process left-side element first.
if (left) {
const leftRect = left.getBoundingClientRect()
// only need to compare the value of left.
if (leftRect.left < rect.left) {
scrol... | javascript | {
"resource": ""
} |
q40064 | fireEvent | train | function fireEvent (element, type, data) {
const evt = document.createEvent('Event')
evt.data = data
for (const k in data) {
if (data.hasOwnProperty(k)) {
evt[k] = data[k]
}
}
// need bubble.
evt.initEvent(type, true, true)
element.dispatchEvent(evt)
} | javascript | {
"resource": ""
} |
q40065 | getResolveHandlers | train | function getResolveHandlers(appName, routes, options) {
var resolveHandlers = {};
var me = this;
_.each(routes, function (route) {
// if no route name, don't do anything
if (!route.name) { return; }
// else generate the UI part based on the name
var uipart = me.getUIPart(a... | javascript | {
"resource": ""
} |
q40066 | getUIPart | train | function getUIPart(appName, route) {
var rootDir = this.pancakes.getRootDir();
var filePath = path.join(rootDir, 'app', appName, 'pages', route.name + '.page.js');
return this.loadUIPart(appName, filePath);
} | javascript | {
"resource": ""
} |
q40067 | execute | train | function execute(req, res) {
// setup the transaction
req.conn.transaction = new Transaction();
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q40068 | train | function ()
{
obj.set('exploded', currentExplode + (step * frame) );
RGraph.clear(obj.canvas);
RGraph.redrawCanvas(obj.canvas);
if (frame++ < frames) {
RGraph.Effects.updateCanvas(iterator);
} else {
... | javascript | {
"resource": ""
} | |
q40069 | Route | train | function Route(path, options) {
options = options || {};
this.path = path;
this.method = 'GET';
this.regexp = pathtoRegexp(path
, this.keys = []
, options.sensitive
, options.strict);
} | javascript | {
"resource": ""
} |
q40070 | insert | train | function insert (builder, node) {
finishPending (builder);
appendNode (builder, spec.insertNode (node [1]));
} | javascript | {
"resource": ""
} |
q40071 | list | train | function list (builder, node) {
finishPending (builder);
var key = node [1];
var sub = subBuilder (builder);
dispatch.nodes (sub, builder.dispatch, node, 2, node.length);
var template = getTemplate (sub);
appendNode (builder, spec.listNode (key, template));
} | javascript | {
"resource": ""
} |
q40072 | CFClient | train | function CFClient(config) {
if (!(config instanceof CFConfig)) {
throw CFClientException(
new Error('Given tokens must be an instance of CFConfig'),
'tokens must be an instance of CFConfig that contains: "protocol", "host", "username", "password", "skipSslValidation');
}
... | javascript | {
"resource": ""
} |
q40073 | CFConfig | train | function CFConfig(config) {
const cf = this;
extend(extend(cf, {
protocol: 'http',
host: 'api.bosh-lite.com',
//port : null, // omitted to let it be based on config or protocol
username: 'admin',
password: 'admin',
skipSslValidation: false
}), config)... | javascript | {
"resource": ""
} |
q40074 | demo_plugin | train | function demo_plugin (opts) {
// adds an emit plugin. Emit plugins are called on regular intervals and have
// the opertunity to add to the payload being sent to collectors. Data sent
// from emit plugins should not require tagging, and should be map ready.
this.add({role: 'metrics', hook: 'emit'}, emit)
//... | javascript | {
"resource": ""
} |
q40075 | tag | train | function tag (msg, done) {
var clean_data = {
source: 'demo-plugin',
payload: msg.payload
}
done(null, clean_data)
} | javascript | {
"resource": ""
} |
q40076 | map | train | function map (msg, done) {
var metric = {
source: msg.source,
name: 'my-metric',
values: {val: msg.payload.val},
tags: {tag: msg.payload.tag}
}
done(null, [metric])
} | javascript | {
"resource": ""
} |
q40077 | sink | train | function sink (msg, done) {
var metric = msg.metric
var as_text = JSON.stringify(metric, null, 1)
console.log(as_text)
done()
} | javascript | {
"resource": ""
} |
q40078 | ErrorLocked | train | function ErrorLocked (message) {
Error.call(this);
// Add Information
this.name = 'ErrorLocked';
this.type = 'client';
this.status = 423;
if (message) {
this.message = message;
}
} | javascript | {
"resource": ""
} |
q40079 | cache | train | function cache(options, compiled) {
// cachable
if (compiled && options.filename && options.cache) {
delete templates[options.filename];
cacheStore[options.filename] = compiled;
return compiled;
}
// check cache
if (options.filename && options.cache) {
return cacheStore[options.filename];
}
... | javascript | {
"resource": ""
} |
q40080 | store | train | function 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.repla... | javascript | {
"resource": ""
} |
q40081 | set | train | function set(name, value) {
// if no value then remove
if (!value) {
remove(name);
return;
}
if (localStorage) {
try {
localStorage.setItem(name, value);
}
catch (ex) {}
}
_.isFunction($cookies... | javascript | {
"resource": ""
} |
q40082 | get | train | function get(name) {
var value = (_.isFunction($cookies.get) ? $cookies.get(name) : $cookies[name]);
if (!value && localStorage) {
try {
value = localStorage.getItem(name);
}
catch (ex) {}
if (value) {
set(name, value);
... | javascript | {
"resource": ""
} |
q40083 | camelcase | train | function camelcase(val) {
if (!is_1.isValue(val))
return null;
var result = val.replace(/[^A-Za-z0-9]/g, ' ').replace(/^\w|[A-Z]|\b\w|\s+/g, function (m, i) {
if (+m === 0 || /(\.|-|_)/.test(m))
return '';
return i === 0 ? m.toLowerCase() : m.toUpperCase();
});
return... | javascript | {
"resource": ""
} |
q40084 | capitalize | train | function capitalize(val) {
if (!is_1.isValue(val))
return null;
val = val.toLowerCase();
return "" + val.charAt(0).toUpperCase() + val.slice(1);
} | javascript | {
"resource": ""
} |
q40085 | padLeft | train | function padLeft(val, len, offset, char) {
/* istanbul ignore if */
if (!is_1.isValue(val) || !is_1.isString(val))
return null;
// If offset is a string
// count its length.
if (is_1.isString(offset))
offset = offset.length;
char = char || ' ';
var pad = '';
while (len--)... | javascript | {
"resource": ""
} |
q40086 | padRight | train | function padRight(val, len, offset, char) {
/* istanbul ignore if */
if (!is_1.isValue(val) || !is_1.isString(val))
return null;
// If offset is a string
// count its length.
if (is_1.isString(offset))
offset = offset.length;
char = char || ' ';
while (len--) {
val +=... | javascript | {
"resource": ""
} |
q40087 | titlecase | train | function titlecase(val, conjunctions) {
if (!is_1.isValue(val))
return null;
// conjunctions
var conj = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
return val.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (m, i, t) {
if (i > 0 && i + m.length !==... | javascript | {
"resource": ""
} |
q40088 | uuid | train | function uuid() {
var d = Date.now();
// Use high perf timer if avail.
/* istanbul ignore next */
if (typeof performance !== 'undefined' && is_1.isFunction(performance.now))
d += performance.now();
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = ... | javascript | {
"resource": ""
} |
q40089 | validateOptions | train | function validateOptions(options) {
if (!options) {
return;
}
utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) {
if (!options.hasOwnProperty(key)) {
return;
}
if (!utils.isArray(options[key]) || options[key].length !== 2) {
throw new Error('Option "' + key + '"... | javascript | {
"resource": ""
} |
q40090 | getLocals | train | function getLocals(options) {
if (!options || !options.locals) {
return self.options.locals;
}
return utils.extend({}, self.options.locals, options.locals);
} | javascript | {
"resource": ""
} |
q40091 | cacheGet | train | function cacheGet(key, options) {
if (shouldCache(options)) {
return;
}
if (self.options.cache === 'memory') {
return self.cache[key];
}
return self.options.cache.get(key);
} | javascript | {
"resource": ""
} |
q40092 | cacheSet | train | function cacheSet(key, options, val) {
if (shouldCache(options)) {
return;
}
if (self.options.cache === 'memory') {
self.cache[key] = val;
return;
}
self.options.cache.set(key, val);
} | javascript | {
"resource": ""
} |
q40093 | remapBlocks | train | function remapBlocks(blocks, tokens) {
return utils.map(tokens, function (token) {
var args = token.args ? token.args.join('') : '';
if (token.name === 'block' && blocks[args]) {
token = blocks[args];
}
if (token.content && token.content.length) {
token.content = remapBlocks(... | javascript | {
"resource": ""
} |
q40094 | importNonBlocks | train | function importNonBlocks(blocks, tokens) {
var temp = [];
utils.each(blocks, function (block) { temp.push(block); });
utils.each(temp.reverse(), function (block) {
if (block.name !== 'block') {
tokens.unshift(block);
}
});
} | javascript | {
"resource": ""
} |
q40095 | getParents | train | function getParents(tokens, options) {
var parentName = tokens.parent,
parentFiles = [],
parents = [],
parentFile,
parent,
l;
while (parentName) {
if (!options || !options.filename) {
throw new Error('Cannot extend "' + parentName + '" because current template has no... | javascript | {
"resource": ""
} |
q40096 | FrontRouter | train | function FrontRouter() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_classCallCheck(this, FrontRouter);
this.options = {
pageRoot: opts.pageRoot || process.cwd(),
overwrite: opts.overwrite || false
};
this.routes = [];
// Figure out what li... | javascript | {
"resource": ""
} |
q40097 | compileToken | train | function compileToken (token, arg) {
let fn = tokens[token] || noOp
return function () {
return arg ? fn.call(this, arg) : fn.call(this)
}
} | javascript | {
"resource": ""
} |
q40098 | execute | train | function execute(req, res) {
this.state.pubsub.punsubscribe(req.conn, req.args);
} | javascript | {
"resource": ""
} |
q40099 | createModel | train | function createModel(string) {
const reVariable = /\$\{([a-z][\w\-]*)\}/ig;
const escapeCharCode = 92; // `\` symbol
const variables = [];
// We have to replace unescaped (e.g. not preceded with `\`) tokens.
// Instead of writing a stream parser, we’ll cut some edges here:
// 1. Find all tokens... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.