Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
win32._makeLong = function(path) {
// Note: this will *probably* throw somewhere.
if (!util.isString(path))
return path;
if (!path) {
return '';
}
var resolvedPath = win32.resolve(path);
if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
// path is local filesystem path, which needs to be converted
// to long UNC path.
return '\\\\?\\' + resolvedPath;
} else if (/^\\\\[^?.]/.test(resolvedPath)) {
// path is network UNC path, which needs to be converted
// to long UNC path.
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (!util.isString(path)) {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(shims.filter(resolvedPath.split('/'), function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
function writeOrBuffer(stream, chunk, callback) {
var state = stream._writableState;
if (util.isString(chunk)) {
chunk = new Buffer(chunk);
}
/*
if (!state.ready || state.writing || state.buffer.length > 0) {
// stream not yet ready or there is pending request to write.
// push this request into write queue.
// state.buffer.push(new WriteReq(chunk, callback));
} else {
// here means there is no pending data. write out.
// doWrite(stream, chunk, callback);
}
*/
doWrite(stream, chunk, callback);
}
export const dismissableLabelPropType = (props, propName, componentName) => {
if (props.dismissable && (!props[propName] || !isString(props[propName]))) {
return new Error(
`Invalid prop \`${propName}\` with value \`${
props[propName]
}\` supplied to \`${componentName}\`.`,
); // eslint-disable-line max-len
}
return false;
};
export default {
Server.prototype.listen = function() {
var self = this;
var args = normalizeListenArgs(arguments);
var options = args[0];
var callback = args[1];
var port = options.port;
var host = util.isString(options.host) ? options.host : '0.0.0.0';
var backlog = util.isNumber(options.backlog) ? options.backlog : 511;
if (!util.isNumber(port)) {
throw new Error('invalid argument - need port number');
}
// register listening event listener.
if (util.isFunction(callback)) {
self.once('listening', callback);
}
// Create server handle.
if (!self._handle) {
self._handle = createTCP();
}
function isPipeName(s) {
return util.isString(s) && toNumber(s) === false;
}
function toBuf(str, encoding) {
encoding = encoding || 'binary';
if (util.isString(str)) {
if (encoding === 'buffer')
encoding = 'binary';
str = new Buffer(str, encoding);
}
return str;
}
exports._toBuf = toBuf;
export function isTag(data): data is ITag {
if (!isObject(data)) return false;
if (!isString(data.name)) return false;
if (!isObject(data.resources)) return false;
return true;
}
/**
export async function decrypt(
v3Keystore: KeyStore | string,
password: string,
nonStrict: boolean = false,
): Promise {
if (!isString(password)) {
throw new Error('No password given.');
}
const json = !isString(v3Keystore) ? v3Keystore : JSON.parse(nonStrict ? v3Keystore.toLowerCase() : v3Keystore);
if (json.version !== 3) {
throw new Error('Not a valid V3 wallet');
}
let derivedKey;
if (json.crypto.kdf === 'scrypt') {
const { n, r, p, dklen, salt } = json.crypto.kdfparams;
derivedKey = await scrypt(Buffer.from(password), Buffer.from(salt, 'hex'), n, r, p, dklen);
} else if (json.crypto.kdf === 'pbkdf2') {
const { prf, c, dklen, salt } = json.crypto.kdfparams;
if (prf !== 'hmac-sha256') {
throw new Error('Unsupported parameters to PBKDF2');
function runActivity(fileName, options) {
const wf = requireCwd('@tsdi/activities');
let config;
if (options.config && isString(options.config)) {
config = requireCwd(options.config);
}
config = config || {};
if (isBoolean(options.debug)) {
config.debug = options.debug;
}
let md = requireCwd(fileName);
let activites = Object.values(md);
if (activites.some(v => wf.isAcitvityClass(v))) {
wf.Workflow.sequence(...activites.filter(v => wf.isAcitvityClass(v)));
}
}