_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q7900 | titlecase | train | function titlecase() {
return function(data, render) {
var text = render(data);
if (text.length === 0) {
return text;
| javascript | {
"resource": ""
} |
q7901 | generateHeading | train | function generateHeading() {
var mixin = {};
// If two char are provided, first one is used as upperline of the text.
_.each(['==', '=', '-', '~', '\''], function(char, idx) {
// Mustach lambda function takes no parameters and return a function
// whose signature is data, render.
// see https://mustac... | javascript | {
"resource": ""
} |
q7902 | pre | train | function pre() {
return function(data, render) {
// remove first line if empty ; it happens because of
// the {{pre}} tag on one line.
logger.debug('empty line:', Boolean(data.match(/^\s+\n/, '')));
data = data.replace(/^\s+\n/, '');
// Find the first non-empty lines tabulation
var m = data.ma... | javascript | {
"resource": ""
} |
q7903 | propsNode | train | function propsNode (node) {
var props = flatmap(Object.keys(node), function (key) {
if (key == 'type' || key == 'value' || key == 'children') {
return;
}
var value = node[key];
if (key == 'data') {
value = JSON.parse(JSON.stringify(value));
}
return {
type: 'Property',
| javascript | {
"resource": ""
} |
q7904 | literalNode | train | function literalNode (value) {
if (value === undefined) {
return {
type: 'Identifier',
name: 'undefined'
};
}
else if (typeof value == 'function') {
throw Error('Unist property contains a function');
}
else if (value === null || typeof value != 'object') {
return {
type: 'Lit... | javascript | {
"resource": ""
} |
q7905 | train | function ( parent, child ) {
parent.then( function ( arg ) {
child.resolve( arg );
| javascript | {
"resource": ""
} | |
q7906 | train | function ( obj, arg, state ) {
if ( obj.state > promise.state.PENDING ) {
return;
}
obj.value = arg;
obj.state = state;
if ( !obj.deferred ) {
promise.delay( | javascript | {
"resource": ""
} | |
q7907 | view | train | function view(name, model, cb) {
var basePath = path.join(path.dirname(__filename), '../views');
var render = function(err, files) {
if (err) {
cb(err);
}
cb(null, mustache.render(files[0], model, {
toctreeChildren: files[1],
func: files[2],
member: files[3],
constant: file... | javascript | {
"resource": ""
} |
q7908 | train | function ( obj, arg ) {
if ( !array.contains( | javascript | {
"resource": ""
} | |
q7909 | train | function ( obj, arg ) {
var min = 0,
max = obj.length - 1,
idx, val;
while ( min <= max ) {
idx = Math.floor( ( min + max ) / 2 );
val = obj[idx];
if ( val < arg ) {
min = idx + 1;
| javascript | {
"resource": ""
} | |
q7910 | train | function ( obj, size ) {
var result = [],
nth = number.round( ( obj.length / size ), "up" ),
start = 0,
i = -1;
while ( ++i < nth ) {
| javascript | {
"resource": ""
} | |
q7911 | train | function ( obj, fn ) {
var result = [];
array.each( obj, function ( i ) {
| javascript | {
"resource": ""
} | |
q7912 | train | function ( obj, diff ) {
var result = [];
result = obj.filter( function ( i ) {
return !regex.null_undefined.test( i );
| javascript | {
"resource": ""
} | |
q7913 | train | function ( array1, array2 ) {
var result = [];
array.each( array1, function ( i ) {
if ( !array.contains( array2, i ) ) | javascript | {
"resource": ""
} | |
q7914 | train | function ( obj, arg, start, offset ) {
var fn = typeof arg === "function",
l = obj.length,
i = !isNaN( start ) ? start : 0,
nth = !isNaN( offset ) ? i + offset : l - 1;
if ( nth > ( l - 1) ) {
| javascript | {
"resource": ""
} | |
q7915 | train | function ( obj ) {
var result = [];
result = obj.reduce( function ( a, b ) {
| javascript | {
"resource": ""
} | |
q7916 | train | function ( obj ) {
var indexed = [];
utility.iterate( obj, function ( v ) {
| javascript | {
"resource": ""
} | |
q7917 | train | function ( array1, array2 ) {
var a = array1.length > array2.length ? array1 : array2,
b = ( a === array1 ? array2 : array1 );
| javascript | {
"resource": ""
} | |
q7918 | train | function ( obj, arg ) {
var n = obj.length - 1;
if ( arg >= ( n + 1 ) ) {
return obj;
}
else if ( isNaN( arg ) || arg === 1 ) {
| javascript | {
"resource": ""
} | |
q7919 | train | function ( obj, start, offset ) {
var result = [],
i = start - 1,
nth = start + offset, | javascript | {
"resource": ""
} | |
q7920 | train | function ( obj, arg ) {
array.each( arg, function ( i ) {
array.add( | javascript | {
"resource": ""
} | |
q7921 | train | function ( obj1, obj2 ) {
var result;
result = obj1.map( function ( i, idx ) {
| javascript | {
"resource": ""
} | |
q7922 | train | function ( obj ) {
var values = {},
count = 0,
nth = 0,
mode = [],
result;
// Counting values
array.each( obj, function ( i ) {
if ( !isNaN( values[i] ) ) {
values[i]++;
}
else {
values[i] = 1;
}
});
// Finding the highest occurring count
count = array.max... | javascript | {
"resource": ""
} | |
q7923 | train | function ( obj, arg ) {
array.remove( obj, 0, obj.length );
array.each( arg, function ( i ) | javascript | {
"resource": ""
} | |
q7924 | train | function ( obj, start, end ) {
if ( isNaN( start ) ) {
start = obj.index( start );
if ( start === -1 ) {
return obj;
}
}
else {
start = start | javascript | {
"resource": ""
} | |
q7925 | train | function ( obj, fn ) {
var remove;
if ( typeof fn !== "function" ) {
throw new Error( label.error.invalidArguments ); | javascript | {
"resource": ""
} | |
q7926 | train | function ( obj, fn ) {
if ( typeof fn !== "function" ) {
throw new Error( label.error.invalidArguments );
}
var remove = [];
array.each( obj, function ( i ) {
if ( fn( i ) !== false ) {
remove.push( i );
}
else {
| javascript | {
"resource": ""
} | |
q7927 | train | function ( obj, arg ) {
arg = arg || 1;
if ( arg < | javascript | {
"resource": ""
} | |
q7928 | train | function ( obj, arg ) {
var result = -1;
array.each( obj, function ( i, idx ) {
if ( i === arg ) {
| javascript | {
"resource": ""
} | |
q7929 | train | function ( obj, arg ) {
var nth = obj.length,
result;
if ( arg === 0 ) {
result = obj;
}
else {
if ( arg < 0 ) {
arg += nth;
}
else {
arg--;
}
result = array.limit( | javascript | {
"resource": ""
} | |
q7930 | train | function ( start, end, offset ) {
start = start || 0;
end = end || start;
offset = offset || 1;
var result = [],
n = -1,
nth = Math.max( 0, Math.ceil( ( end - start ) / | javascript | {
"resource": ""
} | |
q7931 | train | function ( obj, divisor ) {
var result = [],
total = obj.length,
nth = Math.ceil( total / divisor ),
low = Math.floor( total / divisor ),
lower = Math.ceil( total / nth ),
lowered = false,
start = 0,
i = -1;
// Finding the fold
if | javascript | {
"resource": ""
} | |
q7932 | train | function ( a, b ) {
var types = {a: typeof a, b: typeof b},
c, d, result;
if ( types.a === "number" && types.b === "number" ) {
result = a - b;
}
else {
c = a.toString();
d = b.toString();
if ( c < d ) {
result = -1;
}
else if ( c > | javascript | {
"resource": ""
} | |
q7933 | train | function ( obj ) {
var result = 0;
if ( obj.length > 0 ) {
result = obj.reduce( function ( prev, cur ) { | javascript | {
"resource": ""
} | |
q7934 | train | function ( ar ) {
var obj = {},
i = ar.length;
while ( i-- ) {
| javascript | {
"resource": ""
} | |
q7935 | train | function ( obj ) {
var result = [];
array.each( obj, function ( i ) {
| javascript | {
"resource": ""
} | |
q7936 | train | function ( obj, args ) {
var result = [];
// Preparing args
if ( !(args instanceof Array) ) {
args = typeof args === "object" ? array.cast( args ) : [args];
}
array.each( args, function ( i, idx ) {
if ( !( i instanceof Array ) ) {
this[idx] = [i];
}
});
// Building | javascript | {
"resource": ""
} | |
q7937 | train | function () {
return utility.iterate( cache.items, function ( v, k ) {
if | javascript | {
"resource": ""
} | |
q7938 | train | function ( uri, silent ) {
silent = ( silent === true );
if ( cache.items[uri] !== undefined ) {
delete cache.items[uri]; | javascript | {
"resource": ""
} | |
q7939 | train | function ( uri ) {
var item = cache.items[uri];
return item !== undefined && | javascript | {
"resource": ""
} | |
q7940 | train | function ( uri, property, value ) {
uri = utility.parse( uri ).href;
if ( cache.items[uri] === undefined ) {
cache.items[uri] = {};
cache.items[uri].permission = 0;
| javascript | {
"resource": ""
} | |
q7941 | train | function ( uri, verb ) {
if ( string.isEmpty( uri ) || string.isEmpty( verb ) ) {
throw new Error( label.error.invalidArguments );
}
uri = utility.parse( uri ).href;
verb = verb.toLowerCase();
var result = false,
bit = 0;
if ( !cache.get( uri, false ) | javascript | {
"resource": ""
} | |
q7942 | train | function ( args ) {
var result = 0;
array.each( args, function ( verb ) {
verb = verb.toLowerCase();
if ( regex.get_headers.test( verb ) ) {
result |= 4; | javascript | {
"resource": ""
} | |
q7943 | train | function ( xhr, uri, type ) {
var headers = string.trim( xhr.getAllResponseHeaders() ).split( "\n" ),
items = {},
o = {},
allow = null,
expires = new Date(),
cors = client.cors( uri );
array.each( headers, function ( i ) {
var header, value;
value = i.repla... | javascript | {
"resource": ""
} | |
q7944 | train | function ( xhr, type ) {
type = type || "";
var result, obj;
if ( ( regex.json_maybe.test( type ) || string.isEmpty( type ) ) && ( regex.json_wrap.test( xhr.responseText ) && Boolean( obj = json.decode( xhr.responseText, true ) ) ) ) {
result = obj;
}
else if ( regex.xml.test( type ) ) {
if ( type !== ... | javascript | {
"resource": ""
} | |
q7945 | train | function ( uri ) {
var cached = cache.get( uri, false ),
bit = !cached ? 0 : cached.permission,
result = {allows: [], bit: bit, map: {partial: 8, read: 4, write: 2, "delete": 1, unknown: 0}};
if ( bit & 1) {
result.allows.push( "DELETE" );
}
if ( bit & 2) {
result.allows.push( "POST" );
| javascript | {
"resource": ""
} | |
q7946 | train | function ( uri, success, failure, args ) {
var defer = deferred(),
callback = "callback", cbid, s;
if ( external === undefined ) {
if ( global.abaaso === undefined ) {
utility.define( "abaaso.callback", {}, global );
}
external = "abaaso";
}
if ( args instanceof Object && args.callback ... | javascript | {
"resource": ""
} | |
q7947 | train | function ( arg, target, pos ) {
return element.create( "script", | javascript | {
"resource": ""
} | |
q7948 | train | function ( dest, ms ) {
var defer = deferred(),
start = client.scrollPos(),
t = 0;
ms = ( !isNaN( ms ) ? ms : 250 ) / 100;
utility.repeat( function () {
var pos = math.bezier( start[0], start[1], dest[0], dest[1], ++t / 100 );
| javascript | {
"resource": ""
} | |
q7949 | train | function ( arg, media ) {
return element.create( "link", {rel: "stylesheet", type: "text/css", href: arg, | javascript | {
"resource": ""
} | |
q7950 | train | function ( name, domain, secure, path, jar ) {
cookie.set( name, "", "-1s", domain, | javascript | {
"resource": ""
} | |
q7951 | train | function ( jar ) {
var result = {};
if ( jar === undefined ) {
jar = server ? "" : document.cookie;
}
if ( !string.isEmpty( jar ) ) {
array.each( string.explode( jar, ";" ), function ( i ) {
| javascript | {
"resource": ""
} | |
q7952 | train | function ( name, value, offset, domain, secure, path, jar ) {
value = ( value || "" ) + ";";
offset = offset || "";
domain = typeof domain === "string" ? ( " Domain=" + domain + ";" ) : "";
secure = ( secure === true ) ? " secure" : "";
path = typeof path === "string" ? ( " Path=" + pat... | javascript | {
"resource": ""
} | |
q7953 | train | function ( obj, recs, args ) {
utility.genId( obj );
// Decorating observer if not present in prototype chain
if ( typeof obj.fire !== "function" ) {
observer.decorate( obj );
}
// Creating store
obj.data = new DataStore( obj );
| javascript | {
"resource": ""
} | |
q7954 | train | function ( obj, key, value ) {
var target, result;
if ( regex.svg.test( obj.namespaceURI ) ) {
if ( value === undefined ) {
result = obj.getAttributeNS( obj.namespaceURI, key );
if ( result === null || string.isEmpty( result ) ) {
result = undefined;
}
else {
result = utility.coerce( ... | javascript | {
"resource": ""
} | |
q7955 | train | function ( obj ) {
if ( typeof obj.reset === "function" ) {
obj.reset();
}
else if ( obj.value !== | javascript | {
"resource": ""
} | |
q7956 | train | function ( type, args, target, pos ) {
var svg = false,
frag = false,
obj, uid, result;
// Removing potential HTML template formatting
type = type.replace( /\t|\n|\r/g, "" );
if ( target !== undefined ) {
svg = ( target.namespaceURI !== undefined && regex.svg.test( target.namespaceURI ) );
}... | javascript | {
"resource": ""
} | |
q7957 | train | function ( obj, key, value ) {
key = string.toCamelCase( key );
if ( value !== undefined ) {
obj.style[key] = | javascript | {
"resource": ""
} | |
q7958 | train | function ( obj ) {
observer.remove( obj );
if ( obj.parentNode | javascript | {
"resource": ""
} | |
q7959 | train | function ( obj, arg ) {
var result = [];
utility.genId( obj, true );
array.each( string.explode( arg ), function ( i ) {
| javascript | {
"resource": ""
} | |
q7960 | train | function ( arg ) {
var obj = document.createDocumentFragment();
if ( arg ) {
array.each( array.cast( element.create( "div", | javascript | {
"resource": ""
} | |
q7961 | train | function ( obj, arg ) {
var result = element.find( obj, arg );
return ( !isNaN( | javascript | {
"resource": ""
} | |
q7962 | train | function ( obj, arg ) {
if ( arg === undefined ) {
return obj.innerHTML;
}
else { | javascript | {
"resource": ""
} | |
q7963 | train | function ( obj, arg ) {
if ( regex.selector_is.test( arg ) ) {
utility.id( obj );
return ( element.find( obj.parentNode, obj.nodeName.toLowerCase() + arg ).filter( function ( i ) {
return ( i.id === obj.id | javascript | {
"resource": ""
} | |
q7964 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : validate.test( {alphanum | javascript | {
"resource": ""
} | |
q7965 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isDate( | javascript | {
"resource": ""
} | |
q7966 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isDomain( | javascript | {
"resource": ""
} | |
q7967 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isEmail( | javascript | {
"resource": ""
} | |
q7968 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isEmpty( | javascript | {
"resource": ""
} | |
q7969 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isIP( | javascript | {
"resource": ""
} | |
q7970 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isInt( | javascript | {
"resource": ""
} | |
q7971 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isNumber( | javascript | {
"resource": ""
} | |
q7972 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isPhone( | javascript | {
"resource": ""
} | |
q7973 | train | function ( obj ) {
return obj.nodeName === "FORM" ? false : string.isUrl( | javascript | {
"resource": ""
} | |
q7974 | train | function ( obj, arg, add ) {
add = ( add !== false );
arg = string.explode( arg, " " );
if ( add ) {
array.each( arg, function ( i ) {
obj.classList.add( i );
});
}
else {
array.each( arg, function ( i ) {
if ( i !== "*" ) {
obj.classList.remove( i | javascript | {
"resource": ""
} | |
q7975 | train | function ( obj ) {
obj = obj || document.body;
var left, top, right, bottom, height, width;
left = top = 0;
width = obj.offsetWidth;
height = obj.offsetHeight;
if ( obj.offsetParent ) {
top = obj.offsetTop;
left = obj.offsetLeft;
while ( obj = obj.offsetParent ) {
left += obj.offsetL... | javascript | {
"resource": ""
} | |
q7976 | train | function ( obj, child ) {
return obj.childNodes.length | javascript | {
"resource": ""
} | |
q7977 | train | function ( obj, key ) {
var target;
if ( regex.svg.test( obj.namespaceURI ) ) {
obj.removeAttributeNS( obj.namespaceURI, key );
}
else {
if ( obj.nodeName === "SELECT" && key === "selected") | javascript | {
"resource": ""
} | |
q7978 | train | function ( obj, ms ) {
return client.scroll( | javascript | {
"resource": ""
} | |
q7979 | train | function ( obj, string, encode ) {
string = ( string === true );
encode = ( encode !== false );
var children = [],
registry = {},
result;
children = obj.nodeName === "FORM" ? ( obj.elements !== undefined ? array.cast( obj.elements ) : obj.find( "button, input, select, textarea" ) ) : [o... | javascript | {
"resource": ""
} | |
q7980 | train | function ( obj ) {
var parse = function ( arg ) {
return number.parse(arg, 10);
};
return {
height : obj.offsetHeight + parse( obj.style.paddingTop || 0 ) + parse( obj.style.paddingBottom || 0 ) + parse( obj.style.borderTop || 0 ) + parse( obj.style.borderBottom || 0 ),
| javascript | {
"resource": ""
} | |
q7981 | train | function ( obj, args ) {
args = args || {};
utility.iterate( args, function ( v, k ) {
if ( regex.element_update.test( k ) ) {
obj[k] = v;
}
else if ( k === "class" ) {
!string.isEmpty( v ) ? element.klass( obj, v ) : element.klass( obj, "*", false );
}
else if ( k.indexOf( "data-" ) === 0 )... | javascript | {
"resource": ""
} | |
q7982 | train | function ( obj, value ) {
var event = "input",
output;
if ( value === undefined ) {
if ( regex.radio_checkbox.test( obj.type ) ) {
if ( string.isEmpty( obj.name ) ) {
throw new Error( label.error.expectedProperty );
}
array.each( utility.$( "input[name='" + obj.name + "']" ), function ( ... | javascript | {
"resource": ""
} | |
q7983 | train | function ( obj ) {
return obj.nodeName === "FORM" ? validate.test( obj ) : | javascript | {
"resource": ""
} | |
q7984 | train | function ( arg, delimiter, header ) {
delimiter = delimiter || ",";
header = ( header !== false );
var obj = json.decode( arg, true ) || arg,
result = "",
prepare;
// Prepares input based on CSV rules
prepare = function ( input ) {
var output;
if ( input instanceof Array ) {
ou... | javascript | {
"resource": ""
} | |
q7985 | train | function ( arg, silent ) {
try {
return JSON.parse( arg );
}
catch ( e ) {
if ( silent !== true ) {
| javascript | {
"resource": ""
} | |
q7986 | LRU | train | function LRU ( max ) {
this.cache = {};
this.max = max || 1000;
this.first | javascript | {
"resource": ""
} |
q7987 | train | function () {
var a = array.cast( arguments ),
t = a.pop(),
P = array.chunk( a, 2 ),
n = P.length,
c, S0, Q0, Q1, Q2, C0, C1, C2, C3;
if ( n < 2 || n > 4 ) {
throw new Error( label.error.invalidArguments );
}
// Setting variables
c = [];
S0 = 1 - t;
Q0 = math.sqr( S0 );
Q1 ... | javascript | {
"resource": ""
} | |
q7988 | train | function ( a, b ) {
return Math.sqrt( math.sqr( b[0] - a[0] | javascript | {
"resource": ""
} | |
q7989 | train | function ( target, arg ) {
try {
target.postMessage( arg, "*" | javascript | {
"resource": ""
} | |
q7990 | train | function ( fn, state ) {
state = state || "all";
return observer.add( | javascript | {
"resource": ""
} | |
q7991 | train | function ( arg ) {
var type = typeof arg;
if ( type === "object" ) {
var v = document[mouse.view],
x = arg.pageX ? arg.pageX : ( v.scrollLeft + arg.clientX ),
y = arg.pageY ? arg.pageY : ( v.scrollTop + arg.clientY ),
c = false;
if ( mouse.pos.x !== x ) {
c = true;
}
$.mouse... | javascript | {
"resource": ""
} | |
q7992 | train | function ( num1, num2 ) {
if ( isNaN( num1 ) || isNaN( num2 ) | javascript | {
"resource": ""
} | |
q7993 | train | function ( arg, delimiter, every ) {
if ( isNaN( arg ) ) {
throw new Error( label.error.expectedNumber );
}
arg = arg.toString();
delimiter = delimiter || ",";
every = every || 3;
var d = arg.indexOf( "." ) > -1 ? "." + arg.replace( regex.number_format_1, "" ) : "", | javascript | {
"resource": ""
} | |
q7994 | train | function ( arg, direction ) {
arg = number.parse( arg );
if ( direction === undefined || string.isEmpty( direction ) ) {
return number.parse( arg.toFixed( 0 ) );
}
else | javascript | {
"resource": ""
} | |
q7995 | train | function ( obj ) {
var methods = [
["fire", function () { return observer.fire.apply( observer, [this].concat( array.cast( arguments ) ) ); }],
["listeners", function ( event ) { return observer.list(this, event ); }],
["on", function ( event, listener, id, scope, standby ) { return observer.add(... | javascript | {
"resource": ""
} | |
q7996 | train | function ( obj, event ) {
var quit = false,
a = array.remove( array.cast( arguments ), 0, 1 ),
o, s, log, list;
if ( observer.ignore ) {
return obj;
}
o = observer.id( obj );
if ( o === undefined || event === undefined ) {
throw new Error( label.error.invalidArguments );
}
if ( ob... | javascript | {
"resource": ""
} | |
q7997 | train | function ( arg ) {
var id;
if ( arg === global ) {
id = "window";
}
else if ( !server && arg === document ) {
id = "document";
| javascript | {
"resource": ""
} | |
q7998 | train | function ( obj, event, target ) {
var l = target || observer.listeners,
o = observer.id( obj ),
r;
if ( l[o] === undefined && event === undefined ) {
r = {};
}
else if ( l[o] !== undefined && ( event === undefined || string.isEmpty( event ) ) ) {
r = l[o];
| javascript | {
"resource": ""
} | |
q7999 | train | function ( obj, event, fn, id, scope, st ) {
var uuid = id || utility.genId();
scope = scope || obj;
st = st || state.getCurrent();
if ( obj === undefined || event === null || event === undefined || typeof fn !== "function" ) {
throw new Error( label.error.invalidArguments | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.