Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.get('/', echoHeaders);
const instance = got.extend({
handlers: [
async (options, next) => {
const result = await next(options);
// @ts-ignore Manual tests
result.modified = true;
return result;
}
]
});
const promise = instance('');
t.true(is.function_(promise.cancel));
// @ts-ignore Manual tests
t.true((await promise).modified);
});
export function findScripts(
scriptPath: string,
config: ResolvedDebugAgentConfig,
fileStats: ScanStats,
logger: consoleLogLevel.Logger
): string[] {
// (path: string, knownFiles: string[], resolved: string[]) => string[]
const resolved = resolveScripts(scriptPath, config, fileStats);
if (config.pathResolver) {
if (!is.function_(config.pathResolver)) {
logger.warn(
`The 'pathResolver' config must be a function. Continuing ` +
`with the agent's default behavior.`
);
return resolved;
}
const knownFiles = Object.keys(fileStats);
const calculatedPaths = config.pathResolver(
scriptPath,
knownFiles,
resolved
);
if (calculatedPaths === undefined) {
return resolved;
}
rcl(this: StackEnv, a) {
const r = this.dict.get(a);
if (typeof r === 'undefined') {
return null;
}
if (USE_STRICT && is.function_(r)) { // carefull pushing functions to stack, watch immutability
return new Action(r);
}
return r instanceof Action ? new Just(r) : r;
},
headers.accept = 'application/json';
}
if (options.decompress && is.undefined(headers['accept-encoding'])) {
headers['accept-encoding'] = supportsBrotli ? 'gzip, deflate, br' : 'gzip, deflate';
}
// Validate URL
if (options.url.protocol !== 'http:' && options.url.protocol !== 'https:') {
throw new UnsupportedProtocolError(options);
}
decodeURI(options.url.toString());
// Normalize request function
if (!is.function_(options.request)) {
options.request = options.url.protocol === 'https:' ? https.request : http.request;
}
// UNIX sockets
if (options.url.hostname === 'unix') {
const matches = /(?.+?):(?
test('check for pipe method', withServer, (t, server, got) => {
server.get('/', defaultHandler);
const stream = got.stream('');
t.true(is.function_(stream.pipe));
t.true(is.function_(stream.on('foobar', () => {}).pipe));
stream.destroy();
});
export default (body: unknown): body is FormData => is.nodeStream(body) && is.function_((body as FormData).getBoundary);
get: (target, name) => {
if (name === 'trailers' || name === 'rawTrailers') {
return [];
}
const value = (target as any)[name];
return is.function_(value) ? value.bind(target) : value;
}
});