This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function koi8rToUtf8 ( buf ) { | |
if( buf instanceof ArrayBuffer ) { | |
buf = new Uint8Array ( buf ); | |
} | |
if( ! Array.isArray ( buf ) ) { | |
buf = [ ... buf ]; | |
} | |
const map = new Map ( [ | |
[0x80,0x2500], [0x81,0x2502], [0x82,0x250C], [0x83,0x2510], | |
[0x84,0x2514], [0x85,0x2518], [0x86,0x251C], [0x87,0x2524], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cp1251ToUtf8(buf){ | |
if(buf instanceof ArrayBuffer) buf = new Uint8Array(buf); | |
if(!Array.isArray(buf)) buf = [...buf]; | |
const map = new Map([ | |
[128,1026], [129,1027], [130,8218], [131,1107], | |
[132,8222], [133,8230], [134,8224], [135,8225], | |
[136,8364], [137,8240], [138,1033], [139,8249], | |
[140,1034], [141,1036], [142,1035], [143,1039], | |
[144,1106], [145,8216], [146,8217], [147,8220], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @format */ | |
/** | |
* | |
* The principle of the algorithm is very simple. | |
* | |
* The module exports three functions: | |
* | |
* getTask() | |
* The first function does not need any arguments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createWorker(callable) { | |
const code = `onmessage=${callable.toString()}`; | |
const blob = new Blob([code], { type: 'text/javascript' }); | |
const url = URL.createObjectURL(blob); | |
const worker = new Worker(url); | |
URL.revokeObjectURL(url); | |
return worker; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @format */ | |
/** | |
* Функция отчищает JPEG-картинку от метаданных | |
* | |
* @param {ArrayBuffer} buf буфер с изображением | |
* @returns {Blob|null} | |
*/ | |
function clearJpegMetadata(buf) { | |
if (!(buf instanceof ArrayBuffer)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- @format --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>CodePen - CSS Glitched Text</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" /> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayToBase64(array) { | |
let base64 = ''; | |
const encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
const arrayLength = array.byteLength; | |
const remainder = arrayLength % 3; | |
const mainLength = arrayLength - remainder; | |
let a, b, c, d; | |
let chunk; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @format */ | |
/** | |
* @interface | |
* @name RequestParams | |
* @property {string} url адрес отправки | |
* @property {string} method метод | |
* @property {string} responseType | |
* @property {array} data | |
* @property {object} headers | |
* @property {function} uploadProgress |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function send(method, url, headers = {}, data = null) { | |
return new Promise((resolve, reject) => { | |
console.log(data); | |
const xhr = new XMLHttpRequest(); | |
xhr.onload = () => resolve(xhr); | |
xhr.onerror = error => reject(error); | |
xhr.open(method, url, true); | |
console.log(xhr); | |
Object.entries(headers).forEach(([header, value]) => xhr.setRequestHeader(header, value)); | |
xhr.send(data); |