This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Factory | |
var encrypterFactory = function(config) { | |
var encrypter = eval('new Encrypt' + config.algorithm.toUpperCase()); | |
if (typeof encrypter.encrypt !== 'function') { | |
throw new Error(encrypter.constructor.name + ' must implement the `encrypt` method!'); | |
} | |
return encrypter; | |
}; | |
// Implementations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from https://gist.github.com/Igor1201/5036401727a9c178193b1e0688e1eb3c | |
set -eo pipefail | |
export ANDROID_HOME="/usr/local/share/android-sdk" | |
export PATH="$PATH:$ANDROID_HOME/tools/bin" | |
# set variables | |
ANDROID_SDK_URL="https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip" | |
ANDROID_SDK_SHA="4a81754a760fce88cba74d69c364b05b31c53d57b26f9f82355c61d5fe4b9df9" |
"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType
The following write-up is intended as an introduction into using phantom types in ReasonML.
Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let str = ReasonReact.string; | |
let url = "http://localhost:3000/users"; | |
type user = { | |
id: int, | |
name: string, | |
}; | |
type state = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const {dirname, isAbsolute, join, resolve} = require('path'); | |
const {existsSync} = require('fs'); | |
const {PassThrough} = require('stream'); | |
const inspectWithKind = require('inspect-with-kind'); | |
const npmCliDir = require('npm-cli-dir'); | |
const optional = require('optional'); | |
const resolveFromNpm = require('resolve-from-npm'); |