@spare/bracket
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -11,3 +11,3 @@ 'use strict'; | ||
const anglebr = x => '<' + x + '>'; | ||
const br = (x, mode = enumBrackets.BRK) => { | ||
const br = (x, mode) => { | ||
if (mode === enumBrackets.PAR) return parenth(x); | ||
@@ -20,2 +20,21 @@ if (mode === enumBrackets.BRK) return bracket(x); | ||
const SelectBr = mode => { | ||
if (mode === enumBrackets.PAR) return parenth; | ||
if (mode === enumBrackets.BRK) return bracket; | ||
if (mode === enumBrackets.BRC) return brace; | ||
if (mode === enumBrackets.ANBR) return anglebr; | ||
return null; | ||
}; | ||
const Br = (read, mode) => { | ||
const br = SelectBr(mode); | ||
if (!mode) return read; | ||
if (!read) return br; | ||
return x => { | ||
var _ref, _x; | ||
return _ref = (_x = x, read(_x)), br(_ref); | ||
}; | ||
}; | ||
exports.Br = Br; | ||
exports.anglebr = anglebr; | ||
@@ -22,0 +41,0 @@ exports.br = br; |
@@ -1,2 +0,2 @@ | ||
import { BRK, PAR, BRC, ANBR } from '@spare/enum-brackets'; | ||
import { PAR, BRK, BRC, ANBR } from '@spare/enum-brackets'; | ||
@@ -7,3 +7,3 @@ const parenth = x => '(' + x + ')'; | ||
const anglebr = x => '<' + x + '>'; | ||
const br = (x, mode = BRK) => { | ||
const br = (x, mode) => { | ||
if (mode === PAR) return parenth(x); | ||
@@ -16,2 +16,20 @@ if (mode === BRK) return bracket(x); | ||
export { anglebr, br, brace, bracket, parenth }; | ||
const SelectBr = mode => { | ||
if (mode === PAR) return parenth; | ||
if (mode === BRK) return bracket; | ||
if (mode === BRC) return brace; | ||
if (mode === ANBR) return anglebr; | ||
return null; | ||
}; | ||
const Br = (read, mode) => { | ||
const br = SelectBr(mode); | ||
if (!mode) return read; | ||
if (!read) return br; | ||
return x => { | ||
var _ref, _x; | ||
return _ref = (_x = x, read(_x)), br(_ref); | ||
}; | ||
}; | ||
export { Br, anglebr, br, brace, bracket, parenth }; |
{ | ||
"name": "@spare/bracket", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Add parenthesis/bracket/brace/angle-bracket to string", | ||
@@ -18,3 +18,3 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@spare/enum-brackets": "^0.3.1" | ||
"@spare/enum-brackets": "^0.3.2" | ||
}, | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/spare#readme", | ||
"gitHead": "122450f91d790a6bbec4c9bb57463a9b3e368153" | ||
"gitHead": "70612d85879c19830da8aee6142f78c984a42c68" | ||
} |
5600
65
Updated@spare/enum-brackets@^0.3.2