Skip to content

Commit

Permalink
Merge 32ea3ff into ef8d8a1
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Aug 22, 2018
2 parents ef8d8a1 + 32ea3ff commit 417665f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/check/arbitrary/CharacterArbitrary.ts
Expand Up @@ -5,7 +5,7 @@ import { integer } from './IntegerArbitrary';
/** @hidden */
function CharacterArbitrary(min: number, max: number, mapToCode: (v: number) => number) {
return integer(min, max)
.map(n => String.fromCharCode(mapToCode(n)))
.map(n => StringFromCodePointLimited(mapToCode(n)))
.noBias();
}

Expand Down Expand Up @@ -94,8 +94,6 @@ function unicode(): Arbitrary<string> {
* @see https://tc39.github.io/ecma262/#sec-utf16encoding
*/
function fullUnicode(): Arbitrary<string> {
// Might require a polyfill if String.fromCodePoint is missing
// from the node version or web-browser
// Be aware that 'characters' can have a length greater than 1
// More details on: https://tc39.github.io/ecma262/#sec-utf16encoding
// This unicode builder is able to produce all the UTF-16 characters
Expand All @@ -105,11 +103,7 @@ function fullUnicode(): Arbitrary<string> {
if (v < 0xd800) return v;
return v + gapSize;
}
// Do not call CharacterArbitrary or use fromCodePoint in it
// String.fromCodePoint is unknown for older versions of node
return integer(0x0000, 0x10ffff - gapSize)
.map(n => StringFromCodePointLimited(mapping(n)))
.noBias();
return CharacterArbitrary(0x0000, 0x10ffff - gapSize, mapping);
}

export { char, ascii, char16bits, unicode, fullUnicode, hexa, base64 };

0 comments on commit 417665f

Please sign in to comment.