Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: convert to ESM #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Example

```html
<div id="test"></div>
<script type="text/javascript" src="renderjson.js"></script>
<script>
<script type="module">
import renderjson from "./renderjson.mjs"
document.getElementById("test").appendChild(
renderjson({ hello: [1,2,3,4], there: { a:1, b:2, c:["hello", null] } })
);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "renderjson",
"version": "1.4.0",
"description": "Render JSON into collapsible HTML",
"main": "renderjson.js",
"exports": "./renderjson.mjs",
"repository": {
"type": "git",
"url": "git+https://github.com/caldwell/renderjson.git"
},
"type": "module",
"keywords": [
"json",
"html"
Expand Down
5 changes: 1 addition & 4 deletions renderjson.js → renderjson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
// .object.syntax ("{", "}")
// .array.syntax ("[", "]")

var module, window, define, renderjson=(function() {
export default (function() {
var themetext = function(/* [class, text]+ */) {
var spans = [];
while (arguments.length)
Expand Down Expand Up @@ -211,6 +211,3 @@ var module, window, define, renderjson=(function() {
renderjson.set_collapse_msg(function(len) { return len + " item" + (len==1 ? "" : "s") })
return renderjson;
})();

if (define) define({renderjson:renderjson})
else (module||{}).exports = (window||{}).renderjson = renderjson;
4 changes: 2 additions & 2 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ <h1></h1>

<div id="dest"></div>

<script type="text/javascript" src="renderjson.js"></script>
<script>
<script type="module">
import renderjson from "./renderjson.mjs"
document.getElementById("dest").appendChild(
renderjson//.set_show_by_default(true)
//.set_show_to_level(2)
Expand Down