xod-func-tools
Advanced tools
Comparing version 0.24.0 to 0.30.0
@@ -13,4 +13,7 @@ { | ||
"bs-dependencies": [], | ||
"warnings": { | ||
"error" : "+a" | ||
}, | ||
"namespace": true, | ||
"refmt": 3 | ||
} |
@@ -189,3 +189,3 @@ 'use strict'; | ||
var maybeProp = exports.maybeProp = (0, _types.def)('maybeProp :: String -> StrMap a -> Maybe a', R.compose(_ramdaFantasy.Maybe, R.prop)); | ||
var maybeProp = exports.maybeProp = (0, _types.def)('maybeProp :: String -> Object -> Maybe a', R.compose(_ramdaFantasy.Maybe, R.prop)); | ||
@@ -192,0 +192,0 @@ var maybePath = exports.maybePath = (0, _types.def)('maybePath :: [String] -> Object -> Maybe a', R.compose(_ramdaFantasy.Maybe, R.path)); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.unquote = exports.enquote = undefined; | ||
exports.cppEscape = exports.unicodeCharsToUnicodeSequence = exports.unquote = exports.enquote = undefined; | ||
@@ -22,2 +22,24 @@ var _ramda = require('ramda'); | ||
var unquote = exports.unquote = (0, _types.def)('unquote :: String -> String', _ramda2.default.when(_ramda2.default.test(/^".*"$/), _ramda2.default.pipe(_ramda2.default.init, _ramda2.default.tail))); | ||
/** | ||
* Converts String with unicode characters into String with | ||
* unicode sequences. | ||
* E.G. | ||
* "> Hello β π¬ ΠΠΈΡ!" -> "U003E Hello U23c5Ud83d U041cU0438U0440!" | ||
*/ | ||
var unicodeCharsToUnicodeSequence = exports.unicodeCharsToUnicodeSequence = (0, _types.def)('unicodeCharsToUnicodeSequence :: String -> String', _ramda2.default.compose(_ramda2.default.join(''), _ramda2.default.reduce(function (acc, char) { | ||
var isValidCppChar = _ramda2.default.test(/[0-9a-zA-Z_]/, char); | ||
var charCode = char.charCodeAt(0); | ||
var escape = charCode.toString(16); | ||
return _ramda2.default.append(isValidCppChar ? char : 'U' + ('0000' + escape).slice(-4).toUpperCase(), acc); | ||
}, []), _ramda2.default.split(''))); | ||
/** | ||
* Escape non-C++ friendly characters: | ||
* - Space (" ") -> "_" | ||
* - Minus ("-") -> "_" | ||
* - Custom unicode ("Ξ΄") -> Unicode sequence ("U03B4") | ||
* - Custom rare unicode ("π") -> "U1F640" | ||
*/ | ||
var cppEscape = exports.cppEscape = (0, _types.def)('cppEscape :: String -> String', _ramda2.default.compose(unicodeCharsToUnicodeSequence, _ramda2.default.replace(/(\s|-)+/g, '_'), _ramda2.default.trim)); | ||
//# sourceMappingURL=strings.js.map |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.def = exports.env = exports.$Either = exports.$Maybe = exports.Stanza = exports.$Promise = exports.Pair = exports.Map = exports.AliasType = exports.OneOfType = exports.Model = exports.EnumType = exports.BinaryType = exports.UnaryType = exports.NullaryType = exports.hasOneOfType = exports.hasType = undefined; | ||
exports.def = exports.env = exports.$Either = exports.$Maybe = exports.Stanza = exports.$Promise = exports.Pair = exports.Map = exports.ExtendedModel = exports.AliasType = exports.OneOfType = exports.Model = exports.EnumType = exports.BinaryType = exports.UnaryType = exports.NullaryType = exports.hasOneOfType = exports.hasType = undefined; | ||
@@ -114,2 +114,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
// EnxtendedModel :: String -> String -> String -> Type -> StrMap Type -> Type | ||
var ExtendedModel = exports.ExtendedModel = R.curry(function (packageName, docUrl, typeName, baseModel, schema) { | ||
return NullaryType(packageName, docUrl, typeName, R.both(hasType(baseModel), hasType(_sanctuaryDef2.default.RecordType(schema)))); | ||
}); | ||
//----------------------------------------------------------------------------- | ||
@@ -116,0 +121,0 @@ // |
{ | ||
"name": "xod-func-tools", | ||
"version": "0.24.0", | ||
"version": "0.30.0", | ||
"description": "", | ||
@@ -11,3 +11,5 @@ "keywords": [], | ||
"doc": "documentation build --format html --output doc --sort-order alpha src/", | ||
"build": "babel src/ -d dist/ --source-maps", | ||
"build:js": "babel src/ -d dist/ --source-maps", | ||
"build:re": "bsb -make-world", | ||
"build": "yarn build:re && yarn build:js", | ||
"clean:dist": "rimraf ./dist ./lib ./src/**/*.bs.js", | ||
@@ -25,5 +27,10 @@ "dev": "yarn run build --watch", | ||
"devDependencies": { | ||
"bs-platform": "^3.1.5", | ||
"bs-platform": "5.0.0", | ||
"chai": "^4.1.2" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"src", | ||
"bsconfig.json" | ||
] | ||
} |
@@ -5,4 +5,2 @@ # xod-func-tools | ||
The package provides utility functions to facilitate functional programming | ||
style used across the XOD project packages and complement libraries like | ||
Ramda and Ramda Fantasy. | ||
The package provides utility functions to facilitate functional programming style used across the XOD project packages and complement libraries like Ramda and Ramda Fantasy. |
@@ -214,3 +214,3 @@ import * as R from 'ramda'; | ||
export const maybeProp = def( | ||
'maybeProp :: String -> StrMap a -> Maybe a', | ||
'maybeProp :: String -> Object -> Maybe a', | ||
R.compose(Maybe, R.prop) | ||
@@ -217,0 +217,0 @@ ); |
@@ -10,1 +10,36 @@ import R from 'ramda'; | ||
); | ||
/** | ||
* Converts String with unicode characters into String with | ||
* unicode sequences. | ||
* E.G. | ||
* "> Hello β π¬ ΠΠΈΡ!" -> "U003E Hello U23c5Ud83d U041cU0438U0440!" | ||
*/ | ||
export const unicodeCharsToUnicodeSequence = def( | ||
'unicodeCharsToUnicodeSequence :: String -> String', | ||
R.compose( | ||
R.join(''), | ||
R.reduce((acc, char) => { | ||
const isValidCppChar = R.test(/[0-9a-zA-Z_]/, char); | ||
const charCode = char.charCodeAt(0); | ||
const escape = charCode.toString(16); | ||
return R.append( | ||
isValidCppChar ? char : `U${`0000${escape}`.slice(-4).toUpperCase()}`, | ||
acc | ||
); | ||
}, []), | ||
R.split('') | ||
) | ||
); | ||
/** | ||
* Escape non-C++ friendly characters: | ||
* - Space (" ") -> "_" | ||
* - Minus ("-") -> "_" | ||
* - Custom unicode ("Ξ΄") -> Unicode sequence ("U03B4") | ||
* - Custom rare unicode ("π") -> "U1F640" | ||
*/ | ||
export const cppEscape = def( | ||
'cppEscape :: String -> String', | ||
R.compose(unicodeCharsToUnicodeSequence, R.replace(/(\s|-)+/g, '_'), R.trim) | ||
); |
@@ -114,2 +114,13 @@ import * as R from 'ramda'; | ||
// EnxtendedModel :: String -> String -> String -> Type -> StrMap Type -> Type | ||
export const ExtendedModel = R.curry( | ||
(packageName, docUrl, typeName, baseModel, schema) => | ||
NullaryType( | ||
packageName, | ||
docUrl, | ||
typeName, | ||
R.both(hasType(baseModel), hasType($.RecordType(schema))) | ||
) | ||
); | ||
//----------------------------------------------------------------------------- | ||
@@ -116,0 +127,0 @@ // |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
165350
67
1881
6