Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getRenderContent(entityClassInstance) {
const content = entityClassInstance.render();
// console.log('renderContent');
// console.log(content);
if (isNil(content)) return [];
return isArray(content) ? content : [content];
}
const checkOrderbook = async function(name) {
// console.log('+-+-+-+')
try {
var data = await global.CHECKSTOCK[name].fetchOrderBook(global.CHECKSYMBOLS[name].symbols[0])
// console.log(data)
var isObject = _.isPlainObject(data)
var isArray = _.isArray(data.bids)
var isNumber = _.isNumber(data.bids[0][0])
if (isObject && isArray && isNumber) {
global.CHECKCCXT[name]['orderbook'] = 'ok'
} else {
global.CHECKCCXT[name]['orderbook'] = 'ok, but strange shema'
}
} catch(err) {
global.CHECKCCXT[name]['orderbook'] = serializeError(err).message
}
}
getAll: function(mixed, falsy) {
// Note that this will not get all matched.
// Will only get the first match of each array item.
if (!_.isArray(mixed))
mixed = [mixed];
var models = [];
var i = 0;
var exist;
for (; i < mixed.length; i++) {
exist = this.get(mixed[i]);
if (exist || falsy) {
models.push(exist);
}
}
return models;
},
remove: function(mixed, silent) {
// Null or undefined should be flexible and allow any value.
if (properties.type === null || properties.type === undefined) {
properties.type = 'any';
// Convert object representation of type to lowercase string.
// String is converted to 'string', Number to 'number', etc.
} else if (properties.type.name) {
properties.type = properties.type.name;
}
if (_.isString(properties.type)) {
properties.type = properties.type.toLowerCase();
}
// index: [Type] or index: [] is translated to index: {type: Array, arrayType: Type}
if (_.isArray(properties.type)) {
if (_.size(properties.type)) {
// Properties will be normalized when array is initialized.
properties.arrayType = properties.type[0];
}
properties.type = 'array';
}
// index: {} or index: SchemaObject is translated to index: {type: Object, objectType: Type}
// SchemaObject factory is initialized when raw schema is provided.
if (!_.isString(properties.type)) {
if (_.isFunction(properties.type)) {
properties.objectType = properties.type;
properties.type = 'object';
} else if (properties.type === {}) {
properties.type = 'object';
} else if (_.isObject(properties.type) && _.size(properties.type)) {
export default (data, key, settings) => {
let isMultiple = settings.options && settings.options.multiple
let value = data[ key ]
let returnValue = value
if (lodash.isString(value) && isMultiple) {
returnValue = [ value ]
} else if (lodash.isArray(value) && !isMultiple) {
returnValue = value[ 0 ]
} else if (lodash.isObject(value) && !lodash.isArray(value)) {
// Note: isObject(['test']) returns true!
if (!value.ids && !value.urls && value.id) {
returnValue = value
} else {
if (isMultiple) {
returnValue = value.urls
} else if (value.urls && value.urls.length) {
returnValue = value.urls[ 0 ]
} else {
returnValue = value
}
}
}
box: string;
isLive: boolean;
kernels: UserKernelsConfig;
preset: {
flv?: IVideoKernelConstructor;
hls?: IVideoKernelConstructor;
mp4?: IVideoKernelConstructor;
};
src: string;
}) {
const { kernels, preset } = config;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production' && isEmpty(kernels) && !isEmpty(preset)) { chimeeLog.warn('preset will be deprecated in next major version, please use kernels instead.'); }
const presetConfig: { [key: string]: SingleKernelConfig } = {};
let newPreset: UserKernelsConstructorMap = {};
if (isArray(kernels)) {
// SKC means SingleKernelConfig
newPreset = (kernels as (Array< SupportedKernelType | SingleKernelConfig >)).reduce((kernels: UserKernelsConstructorMap, keyOrSKC: SupportedKernelType | SingleKernelConfig) => {
// if it is a string key, it means the kernel has been pre installed.
if (isString(keyOrSKC)) {
if (!isSupportedKernelType(keyOrSKC)) {
throw new Error(`We have not support ${keyOrSKC} kernel type`);
}
const kernelFn = kernelsSet[keyOrSKC];
if (!isFunction(kernelFn)) {
chimeeLog.warn(`You have not installed kernel for ${keyOrSKC}.`);
return kernels;
}
kernels[keyOrSKC] = kernelFn;
return kernels;
}
// if it is a SingleKernelConfig, it means user may pass in some config here
function getValueString (key, value) {
if (_.isFunction(value)) {
return '[Function]';
}
if (key === 'pageArray' && !_.isArray(value)) {
return `'Waiting for data'`;
}
return JSON.stringify(value);
}
log.debug('Current applications available:');
private getIdsFromBody(body: any, path: string): string[] {
if (!path) {
return [];
}
if (isArray(body)) {
const ids: string[] = [];
body.forEach(item => ids.push(...this.getIdsFromBody(item, path)));
return ids;
}
const field = path.substr(0, path.indexOf('.') > 0 ? path.indexOf('.') : path.length);
const value = body[field];
if (!value) {
return [];
}
if (isObject(value)) {
return this.getIdsFromBody(value, path.substr((path.indexOf('.') > 0 ? path.indexOf('.') : path.length) + 1));
}
return [ value ];
}
export function weight (matrix, weightCol) {
if (!isArray(matrix)) {
throw new TypeError('matrix should be of type array')
}
if (!isString(weightCol)) {
throw new TypeError('Invalid argument passed to weight. Expects a column name')
}
if (!matrix[0].hasOwnProperty(weightCol)) {
throw new ReferenceError(`Column '${weightCol}' not found in matrix`)
}
return matrix.reduce((result, item) => {
const weight = parseInt(item[weightCol])
if (!isInteger(weight)) {
throw new TypeError('Specified weight value is not an integer')
}
for (let i = 0; i < weight; i++) {
result.push(item)
}
validate: function(model) {
var value = model.property_value.coordinates;
var valid = _.isArray(value) && value.length === 2;
if (!valid) return valid;
for(var i=0; i