New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

data.these

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data.these

js implementation of data.these

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

data.these

Build Status Dependencies

This is a javascript adaptation of the haskell package these which provides a data structure containing either a value a or a value b or both, values a and b :

data These a b = This a
               | That b
               | These a b

API

Constructors
var t = These.This(1)
t instanceof These // => true

Creates an instance containing the this value 1.

var t = These.That(2)
t instanceof These // => true

Creates an instance containing the that value 2.

var t = These(1, 2)
t instanceof These // => true

Creates an instance containg the this value 1 and that value 2.

isThis
These.This(1).isThis // => true
These.That(1).isThis // => false
These.These(1).isThis // => false

The isThis property is true for This instances and false otherwise.

isThat
These.This(1).isThat // => false
These.That(1).isThat // => true
These.These(1).isThat // => false

The isThat property is true for That instances and false otherwise.

isThese
These.This(1).isThese // => false
These.That(1).isThese// => false
These.These(1).isThese // => true

The isThese property is true for These instances and false otherwise.

get
These.This('foo').get() // => 'foo'
These.That('bar').get() // => 'bar'
These.These('foo', 'bar') // => { _this: 'foo', _that: 'bar' }

The get function returns the wrapped value(s). In case of These the values are wrapped in an object.

these
These.This(val).these(f, g, h) // => f(val)
These.That(val).these(f, g, h) // => g(val)
These.These(val).these(f, g, h) // => h(val)

The these function accepts 3 functions - one for each case - and applies the correct function to the wrapped value.

fromThese
These.This('today').fromThese('sometime', 'somewhere') // => [ 'today', 'somewhere' ]
These.That('beijing').fromThese('sometime', 'somewhere') // => [ 'sometime', 'beijing' ]
These.These('today', 'beijing').fromThese('sometime', 'somewhere') // => [ 'today', 'beijing' ]

The these function accepts two values as default values and combines them with the value(s) provided by the These instance.

merge
var add = function(x,y) { return x + y };
These.This(1).merge(add) // => 1
These.That(1).merge(add) // => 1
These.These(1,2).merge(add) // => 3

The merge function accepts a binary to combine values from These instances. The wrapped value is returned as-is for This and That.

mapThese

var inc = function(x) { return x + 1 };
var dec = function(x) { return x - 1 };
These.This(1).mapThese(inc, dec) // => This { 2 }
These.That(2).mapThese(inc, dec) // => That { 1 }
These.These(1, 2).mapThese(inc, dec) // => These { 2, 1 }

The mapThese acts as a bi-functor accepting two functions, which are applied accordingly.


fantasy land compatible. validated using fantasy-check

Keywords

FAQs

Package last updated on 23 Feb 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc