56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { bench, describe } from 'vitest';
|
|
import { STANDARD } from '../helpers/bench-options.js';
|
|
import {
|
|
some,
|
|
none,
|
|
OxSome,
|
|
OxNone,
|
|
O,
|
|
pipe,
|
|
} from '../helpers/imports.js';
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// toNullable — Some path
|
|
// ---------------------------------------------------------------------------
|
|
|
|
describe('Option.toNullable — Some', () => {
|
|
const nm = some(42);
|
|
const ox = OxSome(42);
|
|
const fp = O.some(42);
|
|
|
|
bench('native-monad', () => { nm.toNullable(); }, STANDARD);
|
|
bench('oxide.ts', () => { ox.into(); }, STANDARD);
|
|
bench('fp-ts', () => { pipe(fp, O.toNullable); }, STANDARD);
|
|
});
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// toNullable — None path
|
|
// ---------------------------------------------------------------------------
|
|
|
|
describe('Option.toNullable — None', () => {
|
|
const nm = none();
|
|
const ox = OxNone;
|
|
const fp = O.none;
|
|
|
|
bench('native-monad', () => { nm.toNullable(); }, STANDARD);
|
|
bench('oxide.ts', () => { ox.into(); }, STANDARD);
|
|
bench('fp-ts', () => { pipe(fp, O.toNullable); }, STANDARD);
|
|
});
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// toString
|
|
// ---------------------------------------------------------------------------
|
|
|
|
describe('Option.toString — Some', () => {
|
|
const nm = some(42);
|
|
|
|
bench('native-monad', () => { nm.toString(); }, STANDARD);
|
|
// Most other libraries don't have toString
|
|
});
|
|
|
|
describe('Option.toString — None', () => {
|
|
const nm = none();
|
|
|
|
bench('native-monad', () => { nm.toString(); }, STANDARD);
|
|
});
|