Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
scala-like-option
Advanced tools
Lib that exposes option with rich Api like Scala option, option monad lets you handle nulls in javascript in declarative way
Option that covers all API functions from Scala Option monad in javascript for handling null in declarative way
npm install --save scala-like-option
const optionFactory = require('scala-like-option')
var some = optionFactory.Some('some-content');
var transformation = optionFactory.map(content => 'other-content'); // == 'other-content'
var none = optionFactory.Option(null); // option from null == none
var none = optionFactory.None();
var some = optionFactory.Option('some-content'); // Some('some-content')
var some = some.getOrElse('other-content') // 'some-content'
var some = some.fold('empty', c => 'data') // returns 'data'
Returns the item or the elseObject if None
Arguments:
Returns the element or throws NoSuchElementException if was None
Returns current option if Some or the Else if None
Arguments:
Returns the element or null if was None
Return true if None and false if Some
Return false if None and true if Some
Returns different option with the transformer predicate
Arguments:
Return value from supplied function, one for None and one For Some
Arguments:
Returns different option for given transformer
Arguments:
Returns the content if predicate returns true
Arguments:
Returns the content if predicate returns false
Arguments:
Returns the content if predicate returns true
Arguments:
Returns true if give predicate on this element returns true, if None returns always true
Arguments:
Returns true if the element is equal to give parameter, if none returns false
Arguments:
Checks if element exists for given predicate
Arguments:
Execute function with element, do nothing when None
Arguments:
Return array from option, if None it returns empty array
Returns iterator from option, end iterator if none
FAQs
Lib that exposes option with rich Api like Scala option, option monad lets you handle nulls in javascript in declarative way
We found that scala-like-option demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.