Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return !leafFolderName.startsWith('.')
})
.map(entry => {
// If this is a scope (folder starts with @), return all
// folders inside it (scoped packages)
if (/@.*$/.test(entry)) {
return getDirectories(entry)
} else {
return entry
}
})
// Remove path from all strings
// e.g. turn bla/bla/node_modules/@babel/core
// into @babel/core
nodeModules = flatten(nodeModules).map((entry: string) =>
getLeafFolderName(entry)
)
return nodeModules
}
console.error(`Failed to find node_modules at ${this.dir}`)
return null
}
}
export function getPropertiesOfObjectAssignOrExtendHelper(
node,
blockScopeNode
) {
// Check all the args and recursively try to get props of identifiers (although they may be imported)
return flatten(
node.arguments.map(arg => {
if (t.isObjectExpression(arg)) {
return arg.properties;
} else if (t.isIdentifier(arg)) {
// Recursive, although props will be empty if arg is an imported object
return getOtherPropertiesOfIdentifier(blockScopeNode, arg.name);
}
})
);
}
export function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
return flatten(
blockScopeNode.body
.map(node => {
if (t.isExpressionStatement(node)) {
// ID = value | ID.key = value | ID.key.nested = value
const { left, right } = node.expression;
if (t.isAssignmentExpression(node.expression)) {
if (t.isIdentifier(left) && left.name === idName) {
// ID = value
if (t.isObjectExpression(right)) {
// ID = {}
return right.properties; // Array
}
} else {
const { object, property: key } = left;
if (t.isIdentifier(object) && object.name === idName) {
// ID.key = value
function encodeNotes(track: Track): Array {
return flatten(track.notes.map(note => encodeNote(note, track.channel))) as unknown as Array;
}
}
}
if (values.length !== valueIndex) {
throw new Error('Value number is greater than the placeholder count.');
}
if (chunkIndex === 0) {
result = sql;
} else if (chunkIndex < sql.length) {
result += sql.slice(chunkIndex);
}
return {
sql: result,
values: arrayFlatten(values)
};
};
route(path, method, opts, ...args){
let handles = flatten(slice.call(args));
for (let i = 0; i < handles.length; i++) {
let handle = handles[i];
if (typeof handle !== 'function') {
let type = toString.call(handle);
let msg = 'Route.' + method + '() requires callback functions but got a ' + type;
throw new Error(msg);
}
let layer = new Layer(path, opts, handle);
layer.method = method;
this.stack.push(layer);
}
return this;
}
}, err => {
log.info('Finished fetching all worklogs')
if (err) {
this.fetching = false
return reject(err)
}
let flatWorklogs = flatten(worklogs)
let orderedWorklogs = orderBy(flatWorklogs, ['created'], ['desc'])
resolve(flatten(orderedWorklogs))
})
})
channel : note.channel ? note.channel : track.channel,
noteNumber : note.midi,
ticks : note.ticks,
velocity : Math.floor(note.velocity * 127)
},
{
type : 'noteOff',
channel : note.channel ? note.channel : track.channel,
noteNumber : note.midi,
ticks : note.ticks + note.durationTicks,
velocity : Math.floor(note.noteOffVelocity * 127)
}
]
})),
//and the control changes
...flatten(controlChanges)
]
})
]