Skip to content

Commit

Permalink
feat: add support for Next.JS edge runtime (#136)
Browse files Browse the repository at this point in the history
* test: add a test for Next.JS middleware edge runtime

* feat: add support for Next.JS edge runtime

* 2.3.0
  • Loading branch information
snyamathi authored Sep 12, 2024
1 parent e9ba8f6 commit 7abffb5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/isA.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
module.exports = function isA(item, constructor) {
if (constructor === Array) {
return Array.isArray(item);
}

if (constructor === Object) {
return item !== null && typeof item === 'object' && Array.isArray(item) !== true;
}

return item && item.constructor === constructor;
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ycb",
"version": "2.2.0",
"version": "2.3.0",
"description": "YCB is a multi-dimensional configuration library that builds bundles from resource files describing a variety of values.",
"author": "Ric Allinson <[email protected]>",
"license": "BSD",
Expand All @@ -16,7 +16,8 @@
"lint": "eslint . && prettier --check .",
"lint:fix": "eslint . --fix && prettier --write .",
"pretest": "npm run lint",
"test": "mocha tests/unit --recursive --reporter spec"
"test": "mocha tests/unit --recursive --reporter spec",
"posttest": "node -r ./tests/edgeRuntime.js ./node_modules/.bin/mocha tests/unit --recursive --reporter spec"
},
"devDependencies": {
"eslint": "^9.0.0",
Expand Down
2 changes: 2 additions & 0 deletions tests/edgeRuntime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
globalThis.Array = new Proxy(Array, {});
globalThis.Object = new Proxy(Object, {});

0 comments on commit 7abffb5

Please sign in to comment.