_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q52800 | startLine | train | function startLine (e) {
e.preventDefault();
strokes = that.strokes;
sketching = true;
that.undos = [];
var cursor = getCursorRelativeToCanvas(e);
| javascript | {
"resource": ""
} |
q52801 | resolveFilename | train | function resolveFilename(fileName, cwd = process.cwd()) {
try {
const parent = new Module();
// eslint-disable-next-line no-underscore-dangle
parent.paths = Module._nodeModulePaths(cwd);
// eslint-disable-next-line no-underscore-dangle
return Module._resolveFilename(fileName, parent);
} | javascript | {
"resource": ""
} |
q52802 | handleError | train | function handleError(err) {
let errMsg = err;
if (err instanceof Object) {
errMsg = err.message || err.error || JSON.stringify(err);
}
printColumns(chalk.red('Error: ' + errMsg));
printColumns(
chalk.white( | javascript | {
"resource": ""
} |
q52803 | printColumns | train | function printColumns(heading, data) {
const columns = columnify(data, {});
const spacer = EOL + EOL;
process.stdout.write(heading);
process.stdout.write(spacer);
| javascript | {
"resource": ""
} |
q52804 | getUserRules | train | function getUserRules(cosmiconfig) {
const userConfig = cosmiconfig.config;
const configPath = cosmiconfig.filepath;
return (
Promise.resolve()
// Handle `extends`
.then(() => {
// If `extends` is defined, use stylelint's extends resolver
if (!_.isEmpty(userConfig.extends)) {
... | javascript | {
"resource": ""
} |
q52805 | findDeprecatedStylelintRules | train | function findDeprecatedStylelintRules() {
if (!argv.deprecated && !argv.unused) {
return Promise.resolve();
}
const isDeprecatedPromises = _.map(rules.stylelintAll, isDDeprecated);
return Promise.all(isDeprecatedPromises).then(rulesIsDeprecated => {
rules.stylelintDeprecated = _.filter(
rules.st... | javascript | {
"resource": ""
} |
q52806 | printUserCurrent | train | function printUserCurrent() {
if (!argv.current) {
return;
}
const heading = chalk.blue.underline('CURRENT: Currently configured user rules:');
const rulesToPrint = _.map(rules.userRulesNames, rule => {
return {
| javascript | {
"resource": ""
} |
q52807 | printAllAvailable | train | function printAllAvailable() {
if (!argv.available) {
return;
}
const heading = chalk.blue.underline('AVAILABLE: All available stylelint rules:');
const rulesToPrint = _.map(rules.stylelintAll, rule => {
return {
| javascript | {
"resource": ""
} |
q52808 | printConfiguredUnavailable | train | function printConfiguredUnavailable() {
if (!argv.invalid) {
return;
}
const configuredUnavailable = _.difference(rules.userRulesNames, rules.stylelintAll);
if (!configuredUnavailable.length) {
return;
}
const heading = chalk.red.underline('INVALID: Configured rules | javascript | {
"resource": ""
} |
q52809 | printUserDeprecated | train | function printUserDeprecated() {
if (!argv.deprecated) {
return;
}
const userDeprecated = _.intersection(rules.stylelintDeprecated, rules.userRulesNames);
if (!userDeprecated.length) {
return;
}
const heading = chalk.red.underline('DEPRECATED: Configured rules that are deprecated:');
const rule... | javascript | {
"resource": ""
} |
q52810 | printUserUnused | train | function printUserUnused() {
if (!argv.unused) {
return;
}
const userUnconfigured = _.difference(rules.stylelintNoDeprecated, rules.userRulesNames);
let heading;
if (!userUnconfigured.length) {
heading = chalk.green('All rules are up-to-date!');
printColumns(heading);
return;
}
const r... | javascript | {
"resource": ""
} |
q52811 | printTimingAndExit | train | function printTimingAndExit(startTime) {
const execTime = time() - startTime;
| javascript | {
"resource": ""
} |
q52812 | resolveModule | train | function resolveModule(module) {
debug("resolveModule", module);
const presetName = module;
if (path.isAbsolute(presetName)) {
return [getPresetName(module), module];
}
try {
// Try the naive way | javascript | {
"resource": ""
} |
q52813 | getPresetName | train | function getPresetName(file) {
const packageJson = findUp.sync("package.json", { cwd: path.dirname(file) });
if (packageJson) | javascript | {
"resource": ""
} |
q52814 | getOverrides | train | function getOverrides() {
const configPath = path.join(process.cwd(), "crafty.config.js");
if (fs.existsSync(configPath)) {
return require(configPath);
| javascript | {
"resource": ""
} |
q52815 | sortFiles | train | function sortFiles(files) {
const modules = [];
const assets = [];
let isAssets = false;
for (var i in files) {
const row = files[i];
if (row[0] == "size" && row[2] == "asset") {
isAssets = true;
}
if (row[0] == "size" || row[0] == "") {
continue;
}
if (isAssets) {
... | javascript | {
"resource": ""
} |
q52816 | updateMouse | train | function updateMouse(e) {
input.mouse.clientX = e.clientX;
input.mouse.clientY = e.clientY;
input.mouse.buttons = e.buttons;
if (e.type === 'mouseleave') | javascript | {
"resource": ""
} |
q52817 | updateHybridMouse | train | function updateHybridMouse(e) {
if (input.touch.recentTouch | javascript | {
"resource": ""
} |
q52818 | handleNotifyNext | train | function handleNotifyNext(e) {
if (notifyOfNextSubs[e.type].length === 0) return;
e.persist = blankFunction;
const reNotifyOfNext = [];
const reNotifyOfNextIDs = {};
notifyOfNextSubs[e.type].forEach(sub => {
if (sub.callback(e) === 'reNotifyOfNext') {
| javascript | {
"resource": ""
} |
q52819 | setupEvent | train | function setupEvent(element, eType, handler, capture) {
notifyOfNextSubs[eType] = [];
subsIDs[eType] = {};
element.addEventListener(
eType,
handler,
passiveEventSupport
? {
capture,
// | javascript | {
"resource": ""
} |
q52820 | exists | train | function exists(fileOrDir) {
let stats;
try {
stats = statSync(fileOrDir); | javascript | {
"resource": ""
} |
q52821 | findFileLocation | train | function findFileLocation(file) {
let location = './';
while (true) {
if (exists(location + file)) {
break;
} else if (exists(location + 'package.json') || location === '/') {
// Assumption is that reaching the app root folder or the system '/' marks the end of the search
throw new Error(`... | javascript | {
"resource": ""
} |
q52822 | drawLoop | train | function drawLoop () {
ctx.clearRect(0, 0, canvas.width, canvas.height)
var centerX = canvas.width / 2
var centerY = canvas.height / 2
// draw circle
ctx.beginPath()
ctx.arc(centerX, centerY, 100, 0, 2 * Math.PI, false)
ctx.fillStyle = 'yellow' | javascript | {
"resource": ""
} |
q52823 | ToggleAnimation | train | function ToggleAnimation (AppState) {
var state = AppState.get()
if (
state.currentAnimation[0] === animationDictionary.bend[0] &&
state.currentAnimation[1] === animationDictionary.bend[1]
) {
| javascript | {
"resource": ""
} |
q52824 | compactXML | train | function compactXML (res, xml) {
var txt = Object.keys(xml.attributes).length === 0 && xml.children.length === 0
var r = {}
if (!res[xml.name]) res[xml.name] = []
if (txt) {
r = xml.content || ''
} else {
r.$ = xml.attributes
r._ = xml.content || | javascript | {
"resource": ""
} |
q52825 | parseJoints | train | function parseJoints (node, parentJointName, accumulator) {
accumulator = accumulator || {}
node.forEach(function (joint) {
accumulator[joint.$.sid] = accumulator[joint.$.sid] || {}
// The bind pose of the matrix. We don't make use of this right now, but you would
// use it to render a model in bind pos... | javascript | {
"resource": ""
} |
q52826 | createSandbox | train | function createSandbox(filename, socket) {
var self = new EventEmitter;
var listeners = new WeakMap;
self.addEventListener = function (type, listener) {
if (!listeners.has(listener)) {
var facade = function (event) {
if (!event.canceled) listener.apply(this, arguments);
};
listeners.... | javascript | {
"resource": ""
} |
q52827 | error | train | function error(socket, err) {
socket.emit(SECRET + ':error', {
message: err.message,
| javascript | {
"resource": ""
} |
q52828 | findPluginPath | train | function findPluginPath(command) {
if (command && /^\w+$/.test(command)) {
try {
return resolve.sync('nowa-' + command, {
paths: moduleDirs
});
} catch | javascript | {
"resource": ""
} |
q52829 | loadDefaultOpts | train | function loadDefaultOpts(startDir, configFile) {
try {
return require(path.join(startDir, configFile)).options || {};
} catch (e) {
var dir = path.dirname(startDir);
| javascript | {
"resource": ""
} |
q52830 | explainSync | train | function explainSync (options) {
options = new JsdocOptions(options)
const ExplainSync | javascript | {
"resource": ""
} |
q52831 | explain | train | function explain (options) {
options = new JsdocOptions(options)
const Explain | javascript | {
"resource": ""
} |
q52832 | renderSync | train | function renderSync (options) {
options = new JsdocOptions(options)
const RenderSync = require('./lib/render-sync')
| javascript | {
"resource": ""
} |
q52833 | addEvent | train | function addEvent(el, e, callback, capture) {
if (el.addEventListener) {
el.addEventListener(e, callback, capture || false);
}
else
| javascript | {
"resource": ""
} |
q52834 | hasClass | train | function hasClass(el, className) {
if (!el || !className) {
| javascript | {
"resource": ""
} |
q52835 | removeClass | train | function removeClass(el, className) {
if (!el || !className) {
return;
}
| javascript | {
"resource": ""
} |
q52836 | getAttr | train | function getAttr(obj, attr) {
if (!obj || !isset(obj)) {
return false;
}
var ret;
if (obj.getAttribute) {
ret = obj.getAttribute(attr);
}
else
if (obj.getAttributeNode) | javascript | {
"resource": ""
} |
q52837 | clckHlpr | train | function clckHlpr(i) {
addEvent(i, 'click', function (e) {
stopPropagation(e);
preventDefault(e);
currGroup = getAttr(i, _const_dataattr + '-group') || false;
| javascript | {
"resource": ""
} |
q52838 | getByGroup | train | function getByGroup(group) {
var arr = [];
for (var i = 0; i < CTX.thumbnails.length; i++) {
if (getAttr(CTX.thumbnails[i], _const_dataattr | javascript | {
"resource": ""
} |
q52839 | getPos | train | function getPos(thumbnail, group) {
var arr = getByGroup(group);
for (var i = 0; i < arr.length; i++) {
// compare elements
if (getAttr(thumbnail, 'src') === getAttr(arr[i], 'src') &&
getAttr(thumbnail, _const_dataattr + '-index') === getAttr(arr[i], _const_dataattr | javascript | {
"resource": ""
} |
q52840 | preload | train | function preload() {
if (!currGroup) {
return;
}
var prev = new Image();
var next = new Image();
var pos = getPos(currThumbnail, currGroup);
if (pos === (currImages.length - 1)) {
// last image in group, preload first image and the one before
prev.src = getAttr(currImages[currI... | javascript | {
"resource": ""
} |
q52841 | startAnimation | train | function startAnimation() {
if (isIE8) {
return;
}
// stop any already running animations
stopAnimation();
var fnc = function () {
addClass(CTX.box, _const_class_prefix + '-loading');
if (!isIE9 && typeof CTX.opt.loadingAnimation === 'number') {
var index = 0;
anima... | javascript | {
"resource": ""
} |
q52842 | stopAnimation | train | function stopAnimation() {
if (isIE8) {
return;
}
// hide animation-element
removeClass(CTX.box, _const_class_prefix + '-loading');
// stop animation
if (!isIE9 && typeof CTX.opt.loadingAnimation !== 'string' && CTX.opt.loadingAnimation) {
clearInterval(animationInt);
| javascript | {
"resource": ""
} |
q52843 | initControls | train | function initControls() {
if (!nextBtn) {
// create & append next-btn
nextBtn = document.createElement('span');
addClass(nextBtn, _const_class_prefix + '-next');
// add custom images
if (CTX.opt.nextImg) {
var nextBtnImg = document.createElement('img');
nextBtnIm... | javascript | {
"resource": ""
} |
q52844 | repositionControls | train | function repositionControls() {
if (CTX.opt.responsive && nextBtn && prevBtn) {
var btnTop = (getHeight() / 2) - (nextBtn.offsetHeight / 2);
| javascript | {
"resource": ""
} |
q52845 | resolveSrcString | train | function resolveSrcString(srcProperty) {
if (Array.isArray(srcProperty)) {
// handle multiple tag replacement
return Promise.all(srcProperty.map(function (item) {
return resolveSrcString(item);
}));
} else if (isStream(srcProperty)) {
return new Promise(function (reso... | javascript | {
"resource": ""
} |
q52846 | type | train | function type(value) {
let valueType = typeof value;
if (Array.isArray(value)) {
valueType = 'array';
} else if (value instanceof Date) {
valueType = 'date';
| javascript | {
"resource": ""
} |
q52847 | Template | train | function Template(fn, parameters) {
// Paul Brewer Dec 2017 add deduplication call, use only key property to eliminate
Object.assign(fn, { | javascript | {
"resource": ""
} |
q52848 | parseObject | train | function parseObject(object) {
const children = Object.keys(object).map(key => ({
keyTemplate: parseString(key),
valueTemplate: parse(object[key])
}));
const templateParameters = children.reduce(
(parameters, child) =>
parameters.concat(child.valueTemplate.parameters, child.keyTemplate.parameter... | javascript | {
"resource": ""
} |
q52849 | parseArray | train | function parseArray(array) {
const templates = array.map(parse);
const templateParameters = templates.reduce(
(parameters, template) => parameters.concat(template.parameters),
[]
);
const templateFn = context => | javascript | {
"resource": ""
} |
q52850 | asBuffer | train | function asBuffer(data, encoding) {
let result = data;
if (!isNullOrUndefined(result)) {
if ('object' !== typeof result) {
// handle as string
encoding = normalizeString(encoding);
if (!encoding) {
| javascript | {
"resource": ""
} |
q52851 | createSimplePromiseCompletedAction | train | function createSimplePromiseCompletedAction(resolve, reject) {
return (err, result) => {
if (err) {
if (reject) {
reject(err);
}
| javascript | {
"resource": ""
} |
q52852 | normalizeString | train | function normalizeString(val, normalizer) {
if (!normalizer) {
normalizer = (str) | javascript | {
"resource": ""
} |
q52853 | readSocket | train | function readSocket(socket, numberOfBytes) {
return new Promise((resolve, reject) => {
let completed = createSimplePromiseCompletedAction(resolve, reject);
try {
let buff = socket.read(numberOfBytes);
if (null === buff) {
socket.once('readable', function... | javascript | {
"resource": ""
} |
q52854 | listen | train | function listen(port, cb) {
return new Promise((resolve, reject) => {
let completed = ssocket_helpers.createSimplePromiseCompletedAction(resolve, reject);
try {
let serverToClient;
let server = Net.createServer((connectionWithClient) => {
try {
... | javascript | {
"resource": ""
} |
q52855 | read | train | async function read(filename, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = await normalizePath(base, filename)
opts.filename = filename | javascript | {
"resource": ""
} |
q52856 | write | train | async function write(filename, object, options = undefined) {
const {encoding, flag, ...opts} = normalizeOptions(options)
if (!isNumber(filename)) {
filename = toAbsolute(base, filename)
| javascript | {
"resource": ""
} |
q52857 | exposeBundles | train | function exposeBundles(b){
b.add("./" + packageConfig.main, {expose: packageConfig.name });
if(packageConfig.sniper !== undefined && packageConfig.sniper.exposed !== undefined){
| javascript | {
"resource": ""
} |
q52858 | mkdirSync | train | function mkdirSync(root, mode) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk;
if (path.isAbsolute(root) === true) { // build from absolute path
chunk = chunks.shift(); // remove "/" or C:/
if (!chunk) { // add... | javascript | {
"resource": ""
} |
q52859 | rmdir | train | function rmdir(root, callback) {
if (typeof root !== 'string') {
throw new Error('missing root');
} else if (typeof callback !== 'function') {
throw new Error('missing callback');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
| javascript | {
"resource": ""
} |
q52860 | rmdirSync | train | function rmdirSync(root) {
if (typeof root !== 'string') {
throw new Error('missing root');
}
var chunks = root.split(path.sep); // split in chunks
var chunk = path.resolve(root); // build absolute path
// remove "/" from head and tail
| javascript | {
"resource": ""
} |
q52861 | mkdirSyncRecursive | train | function mkdirSyncRecursive(root, chunks, mode) {
var chunk = chunks.shift();
if (!chunk) {
return;
}
var root = path.join(root, chunk);
if (fs.existsSync(root) === true) { // already done
return mkdirSyncRecursive(root, chunks, mode); | javascript | {
"resource": ""
} |
q52862 | rmdirRecursive | train | function rmdirRecursive(root, chunks, callback) {
var chunk = chunks.pop();
if (!chunk) {
return callback(null);
}
var pathname = path.join(root, '..'); // backtrack
return fs.exists(root, function(exists) {
| javascript | {
"resource": ""
} |
q52863 | rmdirSyncRecursive | train | function rmdirSyncRecursive(root, chunks) {
var chunk = chunks.pop();
if (!chunk) {
return;
}
var pathname = path.join(root, '..'); // backtrack
if (fs.existsSync(root) === false) { // already done
return rmdirSyncRecursive(root, chunks); | javascript | {
"resource": ""
} |
q52864 | interval | train | function interval(prop) {
// create a function that will use the intervals to check the group by property
return function(intervals) {
// create custom labels to use for the resulting object keys
var labels = intervals.reduce(function(acc, val, i) {
var min = val;
var max = (intervals[i + 1] &... | javascript | {
"resource": ""
} |
q52865 | inferSiderbars | train | function inferSiderbars () {
// You will need to update this config when directory was added or removed.
const sidebars = [
// { title: 'JavaScript', dirname: 'javascript' },
// { title: 'CSS', dirname: 'css' },
]
return sidebars.map(({ title, dirname }) => {
const dirpath = path.resolve(__dirname, ... | javascript | {
"resource": ""
} |
q52866 | getBuildingConfigs | train | function getBuildingConfigs (target) {
return target.map(({ dirname, name, version, entry, outDir, styleFilename }) => {
return formats.map(format => {
| javascript | {
"resource": ""
} |
q52867 | save | train | function save(str) {
let result = {};
console.log('Writing data...');
str.split(/\r?\n/g)
.filter(line => line.length && line[0] !== '#')
.forEach(line => {
if (line.split(';').length < 2) return;
let [ src, dst ] = line.split(';').slice(0, 2).map(s => s.trim());
src = String.fromCod... | javascript | {
"resource": ""
} |
q52868 | restartProcessing | train | function restartProcessing (q) {
logger('restartProcessing')
setTimeout(function | javascript | {
"resource": ""
} |
q52869 | unicodeStringToTypedArray | train | function unicodeStringToTypedArray(s) {
var escstr = encodeURIComponent(s);
var binstr = escstr.replace(/%([0-9A-F]{2})/g, function(match, p1) {
| javascript | {
"resource": ""
} |
q52870 | typedArrayToUnicodeString | train | function typedArrayToUnicodeString(ua) {
var binstr = Array.prototype.map.call(ua, function (ch) {
return String.fromCharCode(ch);
}).join('');
var escstr = binstr.replace(/(.)/g, function (m, p) {
var code = p.charCodeAt(p).toString(16).toUpperCase(); | javascript | {
"resource": ""
} |
q52871 | setup | train | function setup(config, options) {
const rule = config.module.rule("svg"); // Find the svg rule
/*
* Let's use the file loader option defaults for the svg loader again. Otherwise
* we'll have to set our own and it's no longer consistent with the changing
* vue-cli.
*/
const fileLoaderOptions = rule.us... | javascript | {
"resource": ""
} |
q52872 | parseResourceQuery | train | function parseResourceQuery(options) {
const query = {};
for (option in options) {
if (!options[option].resourceQuery) continue; // Skip if no query
query[option] = options[option].resourceQuery; // Get the query
| javascript | {
"resource": ""
} |
q52873 | slideTo | train | function slideTo(newPos, immediate) {
// Align items
if (itemNav && dragging.released) {
var tempRel = getRelatives(newPos),
isDetached = newPos > pos.start && newPos < pos.end;
if (centeredNav) {
if (isDetached) {
... | javascript | {
"resource": ""
} |
q52874 | render | train | function render() {
// If first render call, wait for next animationFrame
if (!renderID) {
renderID = rAF(render);
if (dragging.released) {
trigger('moveStart');
}
return;
}
// ... | javascript | {
"resource": ""
} |
q52875 | syncScrollbar | train | function syncScrollbar() {
if ($handle) {
hPos.cur = pos.start === pos.end ? 0 : (((!dragging.released && dragging.source === 'handle') ? pos.dest : pos.cur) - pos.start) / (pos.end - pos.start) * hPos.end;
hPos.cur = within(Math.round(hPos.cur), hPos.start, hPos.end);
... | javascript | {
"resource": ""
} |
q52876 | syncPagesbar | train | function syncPagesbar() {
if ($pages[0] && last.page !== rel.activePage) {
last.page = rel.activePage;
| javascript | {
"resource": ""
} |
q52877 | to | train | function to(location, item, immediate) {
// Optional arguments logic
if (typeof item === 'boolean') {
immediate = item;
item = undefined;
}
if (item === undefined) {
slideTo(pos[location]);
} else {
... | javascript | {
"resource": ""
} |
q52878 | getIndex | train | function getIndex(item) {
return isNumber(item) ? | javascript | {
"resource": ""
} |
q52879 | getRelatives | train | function getRelatives(slideePos) {
slideePos = within(isNumber(slideePos) ? slideePos : pos.dest, pos.start, pos.end);
var relatives = {},
centerOffset = forceCenteredNav ? 0 : frameSize / 2;
// Determine active page
if (!parallax) {
... | javascript | {
"resource": ""
} |
q52880 | updateNavButtonsState | train | function updateNavButtonsState() {
// Item navigation
if (itemNav) {
var isFirst = rel.activeItem === 0,
isLast = rel.activeItem >= items.length - 1,
itemsButtonState = isFirst ? 'first' : isLast ? 'last' : 'middle';
... | javascript | {
"resource": ""
} |
q52881 | handleToSlidee | train | function handleToSlidee(handlePos) {
return Math.round(within(handlePos, | javascript | {
"resource": ""
} |
q52882 | dragInit | train | function dragInit(event) {
var isTouch = event.type === 'touchstart',
source = event.data.source,
isSlidee = source === 'slidee';
// Ignore other than left mouse button
if (isTouch || event.which <= 1) {
stopDefault(event);
... | javascript | {
"resource": ""
} |
q52883 | dragHandler | train | function dragHandler(event) {
dragging.released = event.type === 'mouseup' || event.type === 'touchend';
dragging.path = within(
(dragging.touch ? event.originalEvent[dragging.released ? 'changedTouches' : 'touches'][0] : event)[o.horizontal ? 'pageX' : 'pageY'] - dragging... | javascript | {
"resource": ""
} |
q52884 | trigger | train | function trigger(name, arg1, arg2, arg3, arg4) {
// Common arguments for events
switch (name) {
case 'active':
arg2 = arg1;
arg1 = $items;
break;
case 'activePage':
arg2 = ar... | javascript | {
"resource": ""
} |
q52885 | stopDefault | train | function stopDefault(event, noBubbles) {
event = event || w.event;
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
if (noBubbles) {
| javascript | {
"resource": ""
} |
q52886 | shouldReplace | train | function shouldReplace(svg, cssPath, newCssContent) {
try {
fs.accessSync(svg.path, fs.constants ? fs.constants.R_OK : fs.R_OK);
fs.accessSync(cssPath, fs.constants ? fs.constants.R_OK : fs.R_OK);
} catch(e) {
return true;
}
const oldSvg = fs.readFileSync(svg.path).toString();
const newSvg = svg.conten... | javascript | {
"resource": ""
} |
q52887 | train | function(expr, msg, negatedMsg, expected, showDiff){
var msg = this.negate ? negatedMsg : msg
, ok = this.negate ? !expr : expr
, obj = this.obj;
if (ok) return;
| javascript | {
"resource": ""
} | |
q52888 | train | function(val, desc){
this.assert(
eql(val, this.obj)
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + | javascript | {
"resource": ""
} | |
q52889 | train | function(val, desc){
this.assert(
val.valueOf() === this.obj
, function(){ return 'expected ' + this.inspect + ' to equal | javascript | {
"resource": ""
} | |
q52890 | train | function(type, desc){
this.assert(
type == typeof this.obj
, function(){ return 'expected ' + this.inspect + ' | javascript | {
"resource": ""
} | |
q52891 | train | function(constructor, desc){
var name = constructor.name;
this.assert(
this.obj instanceof constructor
, function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name + (desc ? " | " + desc : "") }
| javascript | {
"resource": ""
} | |
q52892 | train | function(n, desc){
this.assert(
this.obj > n
, function(){ return 'expected ' + this.inspect + ' to be | javascript | {
"resource": ""
} | |
q52893 | train | function(regexp, desc){
this.assert(
regexp.exec(this.obj)
, function(){ return 'expected ' + this.inspect + ' | javascript | {
"resource": ""
} | |
q52894 | train | function(n, desc){
this.obj.should.have.property('length');
var len = this.obj.length;
this.assert(
n == len
, function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (desc ? " | " + desc : "") }
| javascript | {
"resource": ""
} | |
q52895 | train | function(name, val, desc){
if (this.negate && undefined !== val) {
if (undefined === this.obj[name]) {
throw new Error(this.inspect + ' has no property ' + i(name) + (desc ? " | " + desc : ""));
}
} else {
this.assert(
undefined ... | javascript | {
"resource": ""
} | |
q52896 | train | function(name, desc){
this.assert(
this.obj.hasOwnProperty(name)
, function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) + (desc ? " | " + desc : "") }
, function(){ return 'expected ' + this.inspect + ' to | javascript | {
"resource": ""
} | |
q52897 | train | function(obj, desc){
this.assert(
this.obj.some(function(item) { return eql(obj, item); })
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (desc ? " | " + desc : "") }
, function(){ | javascript | {
"resource": ""
} | |
q52898 | train | function(obj){
console.warn('should.contain() is deprecated, use should.include()');
this.obj.should.be.an.instanceof(Array);
this.assert(
~this.obj.indexOf(obj)
, function(){ return 'expected ' + this.inspect + ' to contain | javascript | {
"resource": ""
} | |
q52899 | train | function(field, val){
this.obj.should
.have.property('headers').and
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.