summaryrefslogtreecommitdiff
path: root/src/defs.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-18 08:13:42 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-18 08:13:42 +1100
commitedafa230fd74d06ec5f292c7ba471c932942a7c1 (patch)
tree49fa933c3efe22318b6df6e12474d0093562f6be /src/defs.js
parent26907ca30bff39eda4eb8fee615ce2a19f8d2fca (diff)
downloadfengari-edafa230fd74d06ec5f292c7ba471c932942a7c1.tar.gz
fengari-edafa230fd74d06ec5f292c7ba471c932942a7c1.tar.bz2
fengari-edafa230fd74d06ec5f292c7ba471c932942a7c1.zip
src/defs.js: Don't use assert, use TypeError
Diffstat (limited to 'src/defs.js')
-rw-r--r--src/defs.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/defs.js b/src/defs.js
index a203db6..80a3906 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -1,6 +1,5 @@
"use strict";
-const assert = require('assert');
const luaconf = require('./luaconf.js');
// To avoid charCodeAt everywhere
@@ -172,7 +171,7 @@ const luastring_eq = function(a, b) {
};
const to_jsstring = function(value, from, to) {
- assert(is_luastring(value), "jsstring expects a Uint8Array");
+ if (!is_luastring(value)) throw new TypeError("to_jsstring expects a Uint8Array");
if (to === void 0) {
to = value.length;
@@ -238,6 +237,7 @@ const uri_allowed = (";,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV
/* utility function to convert a lua string to a js string with uri escaping */
const to_uristring = function(a) {
+ if (!is_luastring(a)) throw new TypeError("to_uristring expects a Uint8Array");
let s = "";
for (let i=0; i<a.length; i++) {
let v = a[i];
@@ -253,7 +253,7 @@ const to_uristring = function(a) {
const to_luastring_cache = {};
const to_luastring = function(str, cache) {
- assert(typeof str === "string", "to_luastring expects a javascript string");
+ if (typeof str !== "string") throw new TypeError("to_luastring expects a javascript string");
if (cache) {
let cached = to_luastring_cache[str];
@@ -301,7 +301,7 @@ const to_luastring = function(str, cache) {
};
const from_userstring = function(str) {
- assert(is_luastring(str), "expects an array of bytes");
+ if (!is_luastring(str)) throw new TypeError("expects an array of bytes");
return str;
};