35
68%
MIT
Simple reimplementation of classnames in ReasonML

re-classnames

npm version build status license

Simple reimplementation of classnames in ReasonML.

Installation

# yarn
yarn add re-classnames

# or npm
npm install --save re-classnames

Then add it to bsconfig.json:

"bs-dependencies": [
  "re-classnames"
]

Usage

Cn.make

  • RE
  • ML
Cn.make(["one", "two"]) /* => "one two" */
let _ = Cn.make ["one"; "two"]

Cn.ifTrue

  • RE
  • ML
Cn.make(["one", "two"->Cn.ifTrue(true)]) /* => "one two" */
Cn.make(["one", "two"->Cn.ifTrue(false)]) /* => "one" */
964: syntax error, consider adding a `;' before

Cn.ifSome

  • RE
  • ML
Cn.make(["one", "two"->Cn.ifSome(Some("thing"))]) /* => "one two" */
Cn.make(["one", "two"->Cn.ifSome(None)]) /* => "one" */
964: syntax error, consider adding a `;' before

Cn.mapSome

  • RE
  • ML
type t =
  | One
  | Two
  | Tree;

Cn.make([
  "one",
  Cn.mapSome(
    Some(Two),
    fun
    | One => "one"
    | Two => "two"
    | Tree => "three",
  )
]) /* => "one two" */

Cn.make([
  "one",
  Cn.mapSome(
    None,
    fun
    | One => "one"
    | Two => "two"
    | Tree => "three",
  )
]) /* => "one" */
2310: syntax error, consider adding a `;' before

Cn.unpack

  • RE
  • ML
Cn.make(["one", Some("two")->Cn.unpack]) /* => "one two" */
Cn.make(["one", None->Cn.unpack]) /* => "one" */
964: syntax error, consider adding a `;' before

License

It's MIT.