Skip to content

Commit

Permalink
Make lib browser-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
alex996 committed Aug 31, 2020
1 parent 1903112 commit b77412d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions value-or-json.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const assert = require("assert");

function valueOrJson(arg) {
assert.strictEqual(arguments.length, 1);
if (arguments.length !== 1) {
throw new Error("Expected one argument but got ' + arguments.length");
}

if (needsStringify(arg)) {
return JSON.stringify(arg);
Expand Down
3 changes: 1 addition & 2 deletions value-or-json.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"use strict";

const valueOrJson = require("./value-or-json");
const assert = require("assert");
const test = require("ava");

test("fail on no args", t => {
t.throws(() => {
valueOrJson();
}, { instanceOf: assert.AssertionError });
})
});

test("string", t => {
Expand Down

0 comments on commit b77412d

Please sign in to comment.