Skip to content

Commit

Permalink
ES export
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Jun 15, 2020
1 parent 5b71d82 commit 6990011
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> **This fork can be imported (by a browser) as an ES6 module:**
```js
import msgpack from "https://cdn.jsdelivr.net/gh/fonsp/msgpack-lite/dist/msgpack-es.min.mjs"

msgpack.encode("hello future")
```

# msgpack-lite [![npm version](https://badge.fury.io/js/msgpack-lite.svg)](http://badge.fury.io/js/msgpack-lite) [![Build Status](https://travis-ci.org/kawanet/msgpack-lite.svg?branch=master)](https://travis-ci.org/kawanet/msgpack-lite)

Fast Pure JavaScript MessagePack Encoder and Decoder
Expand Down
8 changes: 8 additions & 0 deletions dist/create-es.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
original = read("./msgpack.min.js", String)

bad = """!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.msgpack=t()}}"""
good = """const msgpack = ((silly_function) => silly_function())"""

exporter = """\nexport default msgpack;"""

write("./msgpack-es.min.mjs", replace(original, bad => good) * exporter)
Loading

0 comments on commit 6990011

Please sign in to comment.