Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function stringify (key, holder, gap) {
let value = holder[key]
// If the value has a toJSON method, call it to obtain a replacement value.
if (isObject(value) && isFunction(value.toJSON)) {
value = value.toJSON(key)
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (isFunction(replacer)) {
value = replacer.call(holder, key, value)
}
switch (typeof value) {
case 'string':
return quote(value)
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return Number.isFinite(value) ? String(value) : STR_NULL
set hooks (hooks) {
if (!isObject(hooks)) {
throw error('INVALID_HOOKS', hooks)
}
// - Duplicately set hooks
// - Set hooks after get
if (this[HOOKS]) {
throw error('ERR_SET_HOOKS')
}
// TODO: check hooks
// adds default hooks
this[HOOKS] = this[EXTEND_HOOKS](hooks)
}
var schemas;
assert.ok(thing.isObject(options), 'Expected options to be an object.');
assert.ok(thing.isObject(options.api), 'Expected an api definition.');
if ('basedir' in options) {
assert.ok(thing.isString(options.basedir), 'Expected basedir to be a string.');
assert.ok(options.basedir.length, 'Expected basedir to be a non-empty string.');
}
if ('schemas' in options) {
assert.ok(thing.isArray(options.schemas), 'Expected schemas option to be an array.');
}
if ('handlers' in options) {
assert.ok(thing.isString(options.handlers) || thing.isObject(options.handlers), 'Expected handlers to be a string or an object.');
assert.ok(!thing.isString(options.handlers) || options.handlers.length, 'Expected handlers to be a non-empty string.');
}
options.basedir = options.basedir || path.dirname(caller());
schemas = {
'#': swaggerSchema
};
// Map and validate API against schemas
if (thing.isArray(options.schemas)) {
options.schemas.forEach(function (schema) {
assert.ok(thing.isObject(schema), 'Expected schema option to be an object.');
assert.ok(thing.isString(schema.name), 'Expected schema name to be a string.');
assert.ok(schema.name && schema.name !== '#', 'Schema name can not be base schema.');
assert.ok(thing.isString(schema.schema) || thing.isObject(schema.schema), 'Expected schema to to an object.');
assign (target, source, keys) {
if (!isObject(target)) {
throw new TypeError('Cannot convert undefined or null to object')
}
if (!isObject(source)) {
return target
}
if (keys === UNDEFINED) {
keys = Object.keys(source)
} else if (!isArray(keys)) {
throw new TypeError('keys must be array or undefined')
}
return assign(target, source, keys)
},
constructor (options) {
super(options, {
sandboxEnvironment: new AsyncParallelHook(['sandbox', 'caviarOptions'])
})
const {
env = {},
stdio = 'inherit',
preset,
configFile
} = options
this[IS_SANDBOX] = true
if (!isObject(env)) {
throw error('INVALID_ENV', env)
}
this._env = env
this._stdio = stdio
this._preset = preset
this._configFile = configFile
}
exports.deepClone = exports.deepCopy = function deepClone(src) {
var dest = src;
if (thing.isObject(src)) {
dest = Array.isArray(src) ? [] : Object.create(Object.getPrototypeOf(src));
Object.getOwnPropertyNames(src).forEach(function (prop) {
var descriptor = Object.getOwnPropertyDescriptor(src, prop);
descriptor.value = deepClone(descriptor.value);
Object.defineProperty(dest, prop, descriptor);
});
}
return dest;
};
var Twitter = module.exports = function (keys, param1, param2) {
var self = this;
var objectMode = true;
var options = {};
if (utils.isBoolean(param1)) {
objectMode = param1;
}
if (utils.isObject(param1)) {
options = param1;
}
if (utils.isObject(param2)) {
options = param2;
}
this.connection = new Connection(keys, options);
this.streamEndpoint = 'statuses/filter';
this.streamParams = null;
Readable.call(this, {objectMode: objectMode});
this.connection.on('data', function (obj) {
if (!self.push(objectMode ? obj : JSON.stringify(obj))) {
self.connection.destroy();
}
});
const checkPlugin = plugin => {
if (isObject(plugin) && isFunction(plugin.apply)) {
return plugin
}
throw error('CONFIG_LOADER_INVALID_PLUGIN')
}
constructor (options) {
if (!isObject(options)) {
throw error('INVALID_OPTIONS', options)
}
const {
cwd
} = options
if (!isString(cwd)) {
throw error('INVALID_CWD', cwd)
}
this._cwd = cwd
this._paths = null
this._chain = []
}
function swaggerize(options) {
var schemas;
assert.ok(thing.isObject(options), 'Expected options to be an object.');
assert.ok(thing.isObject(options.api), 'Expected an api definition.');
if ('basedir' in options) {
assert.ok(thing.isString(options.basedir), 'Expected basedir to be a string.');
assert.ok(options.basedir.length, 'Expected basedir to be a non-empty string.');
}
if ('schemas' in options) {
assert.ok(thing.isArray(options.schemas), 'Expected schemas option to be an array.');
}
if ('handlers' in options) {
assert.ok(thing.isString(options.handlers) || thing.isObject(options.handlers), 'Expected handlers to be a string or an object.');
assert.ok(!thing.isString(options.handlers) || options.handlers.length, 'Expected handlers to be a non-empty string.');
}