Installations
npm install option-monad-ts
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.18.3
NPM Version
6.14.6
Score
70.3
Supply Chain
85.1
Quality
75.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
sdedovic
Download Statistics
Total Downloads
3,733
Last Day
3
Last Week
28
Last Month
46
Last Year
508
GitHub Statistics
1 Stars
14 Commits
3 Watching
2 Branches
2 Contributors
Bundle Size
782.00 B
Minified
400.00 B
Minified + Gzipped
Package Meta Information
Latest Version
0.1.4
Package Id
option-monad-ts@0.1.4
Unpacked Size
12.02 kB
Size
3.82 kB
File Count
6
NPM Version
6.14.6
Node Version
12.18.3
Total Downloads
Cumulative downloads
Total Downloads
3,733
Last day
0%
3
Compared to previous day
Last week
133.3%
28
Compared to previous week
Last month
206.7%
46
Compared to previous month
Last year
-29.1%
508
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
7
Option monad for Typescript
Yet another port of the Scala Option type to TypeScript.
1npm i --save option-monad-ts
Usage
Basic Example
1import { Option, Some, None } from 'option-monad-ts'; 2 3// Create Some 4let n = new Some(3); 5let m = Some.of('four'); 6 7// Create Option 8let c = Option.of(3); 9let d = Option.of(null); 10 11// Validate and use 12n.get(); // 3 13m.get(); // 'four' 14 15c.isDefined(); // true 16d.isDefined(); // false 17 18Some.of(4) 19 .map(_ => _.toString()) 20 .forEach(_ => console.log(_))
Documentation
Option<T>
static of<T>(x: T): Option<T>
An Option factory which creates Some.of(x) if the argument is not null, and None if it is null.
filter(p: (i: T) => boolean): Option<T>
Returns this Option if it is nonempty and applying the predicate p to this Option's value returns true. Otherwise, return None.
flatMap<R>(f: (i: T) => Option<R>): Option<R>
Returns the result of applying f to this Option's value if this Option is nonempty. Returns None if this Option is empty. Slightly different from map in that f is expected to return an Option (which could be None).
forEach<U>(f: (i: T) => U): void
Apply the given procedure f to the option's value, if it is nonempty. Otherwise, do nothing.
get(): T
Returns the option's value. The option must be nonEmpty.
getOrElse(defaultValue: T): T
Returns the option's value if the option is nonempty, otherwise return defaultValue.
isDefined(): boolean
Returns true if the option is an instance of Some, false otherwise.
isEmpty(): boolean
Returns true if the option is None, false otherwise.
map<R>(f: (i: T) => R): Option<R>
Returns a Some containing the result of applying f to this Option's value if this Option is nonempty. Otherwise, return None.
Why another library?
- I thought it would be a good exercise
- I didn't like the API/usage patterns of some existing libraries
- I wanted something as close to the Scala lib as possible, so I ported it trying to keep to its spirit
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/npmpublish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/sdedovic/option-ts/test.yml/master?enable=pin
- Info: 0 out of 8 GitHub-owned GitHubAction dependencies pinned
- Info: 3 out of 3 npmCommand dependencies pinned
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/npmpublish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
30 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2.6
/10
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to option-monad-ts
ts-results
A typescript implementation of Rust's Result and Option objects.
ts-results-es
A typescript implementation of Rust's Result and Option objects.
@mobily/ts-belt
🔧 Fast, modern, and practical utility library for FP in TypeScript.
ts-option-monad
``` npm install ts-option-monad ```