GithubHelp home page GithubHelp logo

clojure-land / bytes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nuid/bytes

0.0 1.0 0.0 73 KB

Cross-platform byte (de)serialization and conversion.

License: Apache License 2.0

Shell 3.07% Clojure 96.93%

bytes's Introduction

nuid.bytes

Cross-platform byte (de)serialization and conversion.

Requirements

jvm, node + npm, clj, shadow-cljs

From Clojure and ClojureScript

tools.deps:

{nuid/bytes {:git/url "https://github.com/nuid/bytes" :sha "..."}}

usage:

$ clj # or shadow-cljs node-repl
=> (require '[nuid.bytes :as bytes])
=> (def b (bytes/from "🐴"))            ;; defaults to utf8
=> (bytes/str b)                        ;; => "🐴"
=> (bytes/str b :utf16le)               ;; => "鿰뒐"
=> (def b2 (bytes/from "🐴" :utf16le))
=> (bytes/str b2 :utf16le)              ;; => "🐴"

Notes

Because this library exists as a common interface over exception facilities, it may only be useful as a functional API to the underlying facilities in the host platform. The below is included just in case.

From JavaScript

In JavaScript, this library relies upon and mimics a subset of the Buffer API in both node and the browser

node:

$ shadow-cljs release node
$ node
> var B = require('./target/node/nuid_bytes');
> var b = B.from("🐴");
> B.toString(b);
> B.toString(b, "utf16le");

browser:

$ shadow-cljs release browser
## go use ./target/browser/nuid_bytes.js in a browser script

From Java

In Java, this library relies on the String and Charset classes. To call nuid.bytes from Java or other JVM languages, use one of the recommended interop strategies (var/IFn or uberjar/aot). Doing so may require modifications or additions to the API for convenience.

From CLR

Coming soon.

Notes

The purpose of nuid.bytes and sibling nuid libraries is to abstract over platform-specific differences and provide a common interface to fundamental dependencies. This allows us to express dependent logic once in pure Clojure(Script), and use it from each of the host platforms (Java, JavaScript, CLR). Along with tools.deps, this approach yields the code-sharing, circular-dependency avoidance, and local development benefits of a monorepo, with the modularity and orthogonality of an isolated library.

Licensing

Apache v2.0 or MIT

Contributing

Install git-hooks and fire away. Make sure not to get bitten by externs if modifying npm dependencies.

formatting:

$ clojure -A:cljfmt            # check
$ clojure -A:cljfmt:cljfmt/fix # fix

dependencies:

## check
$ npm outdated 
$ clojure -A:depot

## update
$ npm upgrade -s
$ clojure -A:depot:depot/update

bytes's People

Contributors

usernolan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.