2.2.34 • Published 1 year ago

@kollorg/aliquid-vel-molestias v2.2.34

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

option

deno land deno doc GitHub release (latest by date) codecov License

test NPM standard-readme compliant semantic-release: angular

Minimum option type port of Rust.

Table of Contents

Background

This project provides minimum option features. They are designed to be optimized in tree-shaking.

One of the existing challenges in the JavaScript/TypeScript community is tree-shaking. Due to the dynamic nature of the language, tree-shaking can only be used in limited situations. That is, tree-shaking cannot do anything about unused class methods or properties.

The only solution to this is separation into top-level functions. It is very unfortunate but true that no other method exists.

Having said that, a future proposal could solve this.

Install

deno.land:

import * as mod from "https://deno.land/x/optio/mod.ts";

npm:

npm i @kollorg/aliquid-vel-molestias

Usage

Type Option represents an optional value.

Every Option is either Some and contains a value, or None, and does not.

import {
  expect,
  None,
  type Option,
  Some,
} from "https://deno.land/x/optio/mod.ts";

function divide(numerator: number, denominator: number): Option<number> {
  if (!denominator) return None;

  return Some(numerator / denominator);
}

const opt = divide(100, 0);
expect(opt, "divide by 0");

All operators for Option are separated from prototype.

Feature

The pipeline operator will linearize the nesting.

import { map, type Option, match } from "https://deno.land/x/optio/mod.ts";

declare const option: Option<unknown>;
declare const mapper: (value: unknown) => unknown

const result = map(option, mapper)
  |> map(%, mapper)
  |> match(%, {
    Some: mapper,
    None:mapper
  })

proposal extensions allows for successive function adaptations, as in the Fluent API.

import { map, type Option, match } from "https://deno.land/x/optio/mod.ts";

declare const option: Option<unknown>;
declare const mapper: (value: unknown) => unknown

const result = option
  ::map(mapper)
  ::map(mapper)
  ::match({
    Some: mapper,
    None: mapper
  })

API

See deno doc for all APIs.

Acknowledgements

Contributing

See contribution.

License

MIT © 2023 Tomoki Miyauchi

bufferspopmotionappopenautoprefixercharsetObject.entrieseventEmittermrudroprm -freveryPush@@toStringTagfpsIteratorbyteweblazybundlertestpropnopecolortypedarraysObservableregular expressionsfastifycsscopykoreanrmdirfunctionxdg-openJSONextensionreadformflagInt32ArraycoloursetPrototypeOfframervariablesiteratorjoiUint16ArraytrimRightregular expressionscheme-validationredux-toolkitdependenciesObject.fromEntriesES2018randomvalidationsettercurlworkflowtoobjectArray.prototype.findLastremovemetadataaccessibilityArray.prototype.flattenReactiveXcolumnroute53columnssafeECMAScript 2016ECMAScript 2021Symbol.toStringTaglanguagepackage.jsonparsechildframeworkinspectprogressperformantES2023shrinkwrapArray.prototype.flatUint32Arraylogargparseimmutableextendmake dirpatchES5promisepackageformatstyle3dhelpersjsdomconcurrencypropertiesnegativeproxywordbreakarrayhas-ownECMAScript 5fullsomejscompareprocessminimalmapreducegetPrototypeOf[[Prototype]]higher-orderes-shimsES2021ansijavascriptimportexportfast-deep-copyprotolintbinddotenvpromiseses2018YAMLwebsitemodulewalkingassertionMapcjkpropertyvesttaskrfc4122launchsequenceeventDispatchercacheeslintconfigbddloggingwhatwgcharacterswhichclass-validatorplugincompilerCSStyped arrayfastArray.prototype.includesbatchstringES2020ajvinternal slotroutingglobalsshimawesomesaucedescriptorxhrargumentsposeincludesObject.assignspringes8parentfoldersymbolstc39quotefullwidthwritetesterworkerfunctionseventscheckgesturesWebSocketscallfull-widthexecutablefilearktypeshamstartformattingfixed-widthiterationvarsbreakenvironmentpositivegroupresolveargsObject.definePropertysearchmakees2015ES3prettyECMAScript 7hasOwnhookformmkdirp-0chaigenericsartES6io-tsbannerTypeBoxtoolkitReactiveExtensionslookajaxrequestairbnbES2017typegetoptelasticachedirectorypackagesgetOwnPropertyDescriptorroutereuseautoscalingspinnerguidmkdirInt16ArrayenderObject.keyswordwrapreadablestreamhttpsinstallertraversebrowserlistexpressiondeletekeysmodulestouchshebangRFC-6455esgetterstructuredClonelinewrapzeroprivate datatypedphonemocha
1.1.29

1 year ago

1.1.28

1 year ago

1.1.30

1 year ago

2.2.33

1 year ago

2.2.34

1 year ago

2.2.31

1 year ago

2.2.32

1 year ago

2.2.30

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.2.30

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

1.1.14

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.13

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago