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

Make lib browser-friendly #4

Merged
merged 1 commit into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions value-or-json.js
@@ -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
@@ -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