Skip to content

Commit

Permalink
add ord and chr functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed May 25, 2022
1 parent e06c932 commit d824ba7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/prefix.js
Expand Up @@ -407,6 +407,27 @@ async function mergeSort(array, fn = defaultSortFn) {
return array;
}

// STD library
function $_ord(x) {
const type = typeof x;
if (type !== 'string') {
throw new Error(`ord: Invalid argument, expected string got ${type}`);
}
const len = [...x].length;
if (len > 1) {
throw new Error('ord: argument need to be string of length 1');
}
return x.codePointAt(0);
}

function $_chr(x) {
const type = typeof x;
if (type !== 'number') {
throw new Error(`chr: Invalid argument, expected number got ${type}`);
}
return String.fromCodePoint(x);
}

var cookie, argv, gaiman, $$__m;
try {
if (is_node()) {
Expand Down

0 comments on commit d824ba7

Please sign in to comment.