Sha256: 8080d2e44eba21ab06abd3b7d03dd18fe93033737ace10a1d963222335960413

Contents?: true

Size: 839 Bytes

Versions: 112

Compression:

Stored size: 839 Bytes

Contents

'use strict';

var GetIntrinsic = require('get-intrinsic');

var $TypeError = GetIntrinsic('%TypeError%');

var callBound = require('call-bind/callBound');

var $charCodeAt = callBound('String.prototype.charCodeAt');
var $numberToString = callBound('Number.prototype.toString');
var $toLowerCase = callBound('String.prototype.toLowerCase');

var StringPad = require('./StringPad');

// https://262.ecma-international.org/11.0/#sec-unicodeescape

module.exports = function UnicodeEscape(C) {
	if (typeof C !== 'string' || C.length !== 1) {
		throw new $TypeError('Assertion failed: `C` must be a single code unit');
	}
	var n = $charCodeAt(C, 0);
	if (n > 0xFFFF) {
		throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF');
	}

	return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start');
};

Version data entries

112 entries across 30 versions & 4 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/es-abstract/2022/UnicodeEscape.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2023/UnicodeEscape.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2021/UnicodeEscape.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2020/UnicodeEscape.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2022/UnicodeEscape.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2020/UnicodeEscape.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2023/UnicodeEscape.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2021/UnicodeEscape.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2021/UnicodeEscape.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2022/UnicodeEscape.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2020/UnicodeEscape.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2023/UnicodeEscape.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2022/UnicodeEscape.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2020/UnicodeEscape.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2021/UnicodeEscape.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2023/UnicodeEscape.js
immosquare-cleaner-0.1.28 node_modules/es-abstract/2020/UnicodeEscape.js
immosquare-cleaner-0.1.28 node_modules/es-abstract/2021/UnicodeEscape.js
immosquare-cleaner-0.1.28 node_modules/es-abstract/2022/UnicodeEscape.js
immosquare-cleaner-0.1.28 node_modules/es-abstract/2023/UnicodeEscape.js