Socket
Socket
Sign inDemoInstall

@dashkite/bake

Package Overview
Dependencies
3
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dashkite/bake

Universal JavaScript Encoding Transformations Toolkit


Version published
Weekly downloads
8
increased by700%
Maintainers
2
Install size
416 kB
Created
Weekly downloads
 

Readme

Source

bake

Universal JavaScript Encoding Transformations Toolkit

"bake" (pronounced "bah-keh") is the romaji representation of a Japanese word meaning "change" or "tranform". This name is also a playful reference to mojibake, describing character encoding failures that result in unintended transformations.

Installation

npm i @dashkite/bake

Usage

bake is designed around standard JavaScript interfaces, so you can use it freely in the browser or Node.js environments. And while DashKite writes with CoffeeScript, and that's what you'll see in examples, bake is published as transpiled JavaScript.

import { convert } from "@dashkite/bake"

string = "I choose to see the beauty."

message = convert from: "utf8", to: "base64", string

# mesage is as follows
# SSBjaG9vc2UgdG8gc2VlIHRoZSBiZWF1dHku

API

convert

convert (specification, data) -> transformedData

convert accepts a specification and some data to work with. It will read the from and to properties of the specification and output transformedData for you, if it knows how.

The specification is an obect with the properties:

  • from: The starting format of data
  • to: The desired format of transformedData

Available Formats

  • base16 / hex
  • base36
  • base64
  • base64url / safe-base64
  • bytes
  • json
  • utf8
  • uri

Format Notes

  • base64url / safe-base64 is based on RFC 4648's "base64url" mapping.
  • base36 is less common than base64 and base16, but it's a useful format. Like base64, this format has the advantage of compact expression, but base36 is always URL-safe and uses only lower-case, making it attractive for identifiers.
  • bytes refers to an instance of Uint8Array
  • json refers to JSON string encoding as applied to UTF8 strings. Do not use this to generally stringify data structures.
  • uri refers to encodeURI as appied to UTF8 strings.

Keywords

FAQs

Last updated on 11 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc