Git Product home page Git Product logo

clj.js's Introduction

build status clj.js - parse/dump Clojure like you'd do with JSON

This library gives you access to few functions to deal with Clojure sexps.

When used in the browser there will be a global variable called Clojure with the usable functions, on node you have to require 'clj'.

Helpers

A set of functions is dedicated to create objects present in Clojure but not present in JavaScript.

  • .symbol(string) -> this creates a String object set as symbol.
  • .keyword(string) -> this creates a String object set as keyword.
  • .vector(...) -> this creates an Array object set as vector. You can either pass a normal array or the elements of the vector.
  • .list(...) -> this creates an Array object set as list. You can either pass a normal array or the elements of the list.
  • .set(...) -> this creates an Array object set as set. You can either pass a normal array or the elements of the set. The function checks for uniqueness of the elements.
  • .rational(...) -> this creates a Rational object. You can either pass a string with the rational or numerator and denominator.

Another set of functions is dedicated to checking wether an object is a specific Clojure object.

  • .is_symbol(obj)
  • .is_keyword(obj)
  • .is_list(obj)
  • .is_set(obj)
  • .is_vector(obj)
  • .is_rational(obj)

Printing - stringify

stringify(object, options) transforms the passed object to Clojure sexps.

The available options are:

  • keys_are_keywords, when set to true the keys of objects that are strings will automatically be transformed in keywords.
  • alpha, when set to true Date objects will be converted to instants.

Reading - parse

parse(string, options) transforms a string with Clojure sexps to JavaScript objects.

Currently there are no options, it's just reserved for future uses.

clj.js's People

Contributors

meh avatar

Watchers

James Cloos avatar Egon Steiner 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.