source: frontend/node_modules/core-js/modules/es.uint8-array.to-hex.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var globalThis = require('../internals/global-this');
4var uncurryThis = require('../internals/function-uncurry-this');
5var anUint8Array = require('../internals/an-uint8-array');
6var notDetached = require('../internals/array-buffer-not-detached');
7
8var numberToString = uncurryThis(1.1.toString);
9var join = uncurryThis([].join);
10var $Array = Array;
11
12var Uint8Array = globalThis.Uint8Array;
13
14var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS = !Uint8Array || !Uint8Array.prototype.toHex || !(function () {
15 try {
16 var target = new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255]);
17 return target.toHex() === 'ffffffffffffffff';
18 } catch (error) {
19 return false;
20 }
21})();
22
23// `Uint8Array.prototype.toHex` method
24// https://tc39.es/ecma262/#sec-uint8array.prototype.tohex
25if (Uint8Array) $({ target: 'Uint8Array', proto: true, forced: INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS }, {
26 toHex: function toHex() {
27 anUint8Array(this);
28 notDetached(this.buffer);
29 var result = $Array(this.length);
30 for (var i = 0, length = this.length; i < length; i++) {
31 var hex = numberToString(this[i], 16);
32 result[i] = hex.length === 1 ? '0' + hex : hex;
33 }
34 return join(result, '');
35 }
36});
Note: See TracBrowser for help on using the repository browser.