Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content => {
logger.success(`Found a compatible content for ${mediaTypes}`);
// a httpContent for a provided mediaType exists
return pipe(
helpers.negotiateByPartialOptionsAndHttpContent(
{
code,
dynamic,
exampleKey,
},
content
),
E.map(contentNegotiationResult => ({
headers: headers || [],
...contentNegotiationResult,
mediaType:
contentNegotiationResult.mediaType === '*/*' ? 'text/plain' : contentNegotiationResult.mediaType,
}))
);
}
)
it("chains scoped computations", () => {
const result = pipe(
right(10),
into("x"),
bind("y", ({ x }) => right(x - 5)),
map(({ x, y }) => x - y),
)
expect(result).toEqual(right(5))
})
function deserializeAndValidate(content: IMediaTypeContent, schema: JSONSchema, target: string) {
const encodings = get(content, 'encodings', []);
const encodedUriParams = splitUriParams(target);
return pipe(
validateAgainstReservedCharacters(encodedUriParams, encodings),
E.map(decodeUriEntities),
E.map(decodedUriEntities => deserializeFormBody(schema, encodings, decodedUriEntities)),
E.chain(deserialised =>
pipe(
validateAgainstSchema(deserialised, schema, true),
E.fromOption(() => deserialised),
E.swap
)
)
);
}
!isInternal(annotation) &&
initializer !== undefined &&
vs.isExported() &&
ast.TypeGuards.isFunctionLikeDeclaration(initializer)
)
}
}
return false
})
const variableDeclarations = traverse(exportedVariableDeclarations, parseFunctionVariableDeclaration)
const monoidFunc = E.getValidationMonoid(monoidFailure, A.getMonoid())
return pipe(
monoidFunc.concat(functionDeclarations, variableDeclarations),
E.map(funcs => funcs.sort(byName.compare))
)
}
export function getInterfaces(sourceFile: ast.SourceFile): Parser> {
const exportedInterfaceDeclarations = sourceFile.getInterfaces().filter(id => id.isExported())
return pipe(
traverse(exportedInterfaceDeclarations, parseInterfaceDeclaration),
E.map(interfaces => interfaces.sort(byName.compare))
)
}
endTime,
bucketDuration,
COMPOSITE_AGGREGATION_BATCH_SIZE,
afterLatestBatchKey
)
);
if (mlModelPlotResponse._shards.total === 0) {
throw new NoLogRateResultsIndexError(
`Failed to find ml result index for job ${logRateJobId}.`
);
}
const { after_key: afterKey, buckets: latestBatchBuckets } = pipe(
logRateModelPlotResponseRT.decode(mlModelPlotResponse),
map(response => response.aggregations.timestamp_data_set_buckets),
fold(throwErrors(createPlainError), identity)
);
mlModelPlotBuckets = [...mlModelPlotBuckets, ...latestBatchBuckets];
afterLatestBatchKey = afterKey;
if (latestBatchBuckets.length < COMPOSITE_AGGREGATION_BATCH_SIZE) {
break;
}
}
return mlModelPlotBuckets.reduce<
Array<{
dataSets: Array<{
analysisBucketCount: number;
anomalies: Array<{
const convertSavedObjectToSavedPinnedEvent = (
savedObject: unknown,
timelineVersion?: string | undefined | null
): PinnedEventSavedObject =>
pipe(
PinnedEventSavedObjectRuntimeType.decode(savedObject),
map(savedPinnedEvent => ({
pinnedEventId: savedPinnedEvent.id,
version: savedPinnedEvent.version,
timelineVersion,
...savedPinnedEvent.attributes,
})),
fold(errors => {
throw new Error(failure(errors).join('\n'));
}, identity)
);
function parseToggleAction(msg: Monitor): Either]> {
const getId = pipe(
msg.payload.id,
E.fromNullable('TOGGLE_ACTION message has some bad payload...'),
E.map(x => x)
)
const parseState = pipe(
E.parseJSON(msg.state, E.toError),
E.bimap(e => e.message, u => u as LiftedState)
)
return sequenceTEither(getId, parseState)
}
const annotation = getAnnotation(vs.getJsDocs())
const initializer = vd.getInitializer()
return (
!isInternal(annotation) &&
initializer !== undefined &&
vs.isExported() &&
!ast.TypeGuards.isFunctionLikeDeclaration(initializer)
)
}
}
return false
})
return pipe(
traverse(exportedVariableDeclarations, parseConstantVariableDeclaration),
E.map(constants => constants.sort(byName.compare))
)
}