UNPKG

everyutil

Version:

A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.

17 lines (16 loc) 526 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.binaryEncode = void 0; /** * Converts a string to its binary representation (8 bits per character). * * Example: binaryEncode("A") → "01000001" * * @author @dailker * @param {string} str - The input string. * @returns {string} The binary-encoded string. */ function binaryEncode(str) { return str.split('').map(c => c.charCodeAt(0).toString(2).padStart(8, '0')).join(''); } exports.binaryEncode = binaryEncode;