This file contains 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
/** | |
* Separate a list into two lists (left and right) using a predicate to detect | |
* items that should be in the left list. The rest go into the right list. | |
* | |
* @param isLeft - predicate to detect items that should be in the left list | |
* | |
* @returns a function that accepts an array and returns a pair of arrays | |
* | |
* @todo - return type [ L[], R[] ] instead of ambiguous type. | |
*/ |
This file contains 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
node_modules | |
.DS_Store |
This file contains 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
# NOTE will not work with make -v 3.81 or lower | |
SHELL = /bin/bash | |
.RECIPEPREFIX = > | |
# run docker as current user so we don't get elm-stuff permissions problems | |
UID ?= $(shell id -u):$(shell id -g) | |
GIT_REPO_ROOT ?= $(PWD) | |
PROJECT_ROOT := $(GIT_REPO_ROOT) |
This file contains 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
node_modules/ |
This file contains 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
export const papply = | |
(f, ...x) => { | |
const arity = f.length | |
const args = x.length | |
// shortcut no-ops for perf | |
if (args === arity) return f(...x) | |
if (args === 0) return f | |
if (args < arity) { |
This file contains 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
// Classic array unfold that works with functions that produce | |
// reasonably-sized output arrays. | |
export const unfoldWith = | |
f => x => | |
_unfold(f, [], x) | |
// Recursive unfold function. Will overflow stack for very, very large unfolds. | |
// f should return null, if done, or return [ curr, next ] values, if not. | |
const _unfold = | |
(f, acc, value) => { |
This file contains 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
// Take a text string containing tokens (of type `${name}`) and return | |
// a function that will replace the tokens with the properties of a given | |
// object. If we need to get much more sophisticated, we should | |
// probably use mustache or similar. | |
// TODO: allow dev to specify a format for each token? | |
export default | |
template => createRenderAll(partition(String(template))) | |
// ------------------------------------------------------------ |
This file contains 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
import _ from "lodash" | |
export const smsMessage = (template, isValidPhone) => { | |
const createMessage = _.template(template) | |
const validate = throwIfInvalidPhone(isValidPhone) | |
return _.compose(validate, createMessage) | |
} | |
const throwIfInvalidPhone = isValidPhone => user => { |
This file contains 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
import _ from "lodash" | |
import { isValidPhone } from "../validation/phone" | |
import template from "./template" | |
import { DbConn } from "../Db" | |
import SmsService from "../SmsService" | |
const createMessage = _.template(template) | |
export const sendSms = userId => { | |
const service = new SmsService() |
NewerOlder