Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
op: Ops,
callback: (r: E.Either>) => void
): () => void {
switch (op._tag) {
case "error":
callback(E.left(op.e));
// this will never be called
/* istanbul ignore next */
// tslint:disable-next-line: no-empty
return () => {};
case "complete":
callback(E.right(O.none));
// tslint:disable-next-line: no-empty
return () => {};
case "offer":
callback(E.right(O.some(op.a)));
// tslint:disable-next-line: no-empty
return () => {};
}
}
it('JSONFromString', () => {
const T = JSONFromString
assert.deepEqual(T.decode('{}'), right({}))
assert.deepEqual(T.decode('[]'), right([]))
assert.deepEqual(T.decode('"s"'), right('s'))
assert.deepEqual(T.decode('1'), right(1))
assert.deepEqual(T.decode('true'), right(true))
assert.deepEqual(T.decode('null'), right(null))
assert.deepEqual(T.decode('{"name":"Giulio"}'), right({ name: 'Giulio' }))
assert.deepEqual(PathReporter.report(T.decode(null)), ['Invalid value null supplied to : JSONFromString'])
assert.deepEqual(PathReporter.report(T.decode('')), ['Invalid value "" supplied to : JSONFromString'])
})
})
it('reverseGet', () => {
const T = TypePrismIso.reverseGet('NumberFromString', prism, t.number.is)
assert.deepEqual(T.decode('0'), right(0))
assert.deepEqual(T.decode('10'), right(10))
assert.deepEqual(T.decode('-1'), right(-1))
assert.deepEqual(T.decode('11'), right(11))
assert.deepEqual(T.decode('5.5'), right(5.5))
assert.deepEqual(T.decode('-5.5'), right(-5.5))
assert.deepEqual(PathReporter.report(T.decode('a')), ['Invalid value "a" supplied to : NumberFromString'])
assert.deepEqual(PathReporter.report(T.decode('2a')), ['Invalid value "2a" supplied to : NumberFromString'])
assert.deepEqual(PathReporter.report(T.decode('2.a')), ['Invalid value "2.a" supplied to : NumberFromString'])
})
})
function validate (values: UserInput): Either {
const errors = {} as UserInputError;
(['name', 'password', 'recoveryPhrase'] as (keyof UserInput)[])
.filter((key) => !values[key])
.forEach((key) => {
errors[key] = `Field "${key}" cannot be empty`;
});
if (values.recoveryPhrase.split(' ').length !== 12) {
errors.recoveryPhrase = 'Invalid phrase. Please check it and try again.';
}
return Object.keys(errors).length ? left(errors) : right(values);
}
(waiting) => {
const [next, queue] = waiting.dequeue();
if (next) {
return [next.fill(a), left(queue)];
}
return [IO.void(), right(Dequeue.of(a))];
},
(available) => [IO.void(), right(available.enqueue(a))]
poption.map(([next, q]) =>
[makeTicket(io.pure(next), io.unit), right(q) as State<a>] as const),
getOrElse(() => [</a>
);
}
matches = matches.filter(match => !!match.serverMatch && match.serverMatch !== MatchType.NOMATCH);
if (!matches.length) {
return left(
ProblemJsonError.fromTemplate(
NO_SERVER_MATCHED_ERROR,
`The server url ${requestBaseUrl} hasn't been matched with any of the provided servers`
)
);
}
}
return right(disambiguateMatches(matches));
};
blobService.getBlobToText(containerName, blobName, (err, result, __) => {
if (err) {
return resolve(left>(err));
} else {
return resolve(right>(fromNullable(result)));
}
});
});
return (await promiseToEither(prom)).chain(r => {
if (r === null)
return(left(`Cannot find cached (${namespace}.${key})`))
return right(r).map(({data}) => data) as Either
})
}
(allExtrinsicData: any) => right(allExtrinsicData)
);