diff --git a/map/compare.js b/map/compare.js
new file mode 100644
index 0000000..b70c6cb
--- /dev/null
+++ b/map/compare.js
@@ -0,0 +1,19 @@
+/**
+ * Compare two Map objects for equality
+ * @param {Map} map1 - The first map to compare
+ * @param {Map} map2 - The second map to compare
+ * @returns {boolean} - True if the maps are equal, false otherwise
+ */
+export default function mapCompare(map1, map2) {
+ if (map1.size !== map2.size) {
+ return false; // Different sizes, cannot be equal
+ }
+
+ for (const [key, value] of map1.entries()) {
+ if (!map2.has(key) || map2.get(key) !== value) {
+ return false; // Key or value mismatch
+ }
+ }
+
+ return true; // Maps are equal
+}
diff --git a/package.json b/package.json
index b9d1006..de6a33f 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"semantic-release": "semantic-release -d false",
"test": "npm run lint && npm run test:node && npm run test:browser",
"test:browser": "gulp",
- "test:node": "mocha ./test/specs/{array,time,object,string,http}/*.js",
+ "test:node": "mocha ./test/specs/{array,http,map,object,string,time}/*.js",
"test:spawn": "node_modules/.bin/browserstack-runner",
"test:deploy": "npm test && npm run test:spawn",
"test:spawn-local": "env $(cat .env | xargs) npm run test:spawn"
diff --git a/string/isJSON.js b/string/isJSON.js
new file mode 100644
index 0000000..d21e0be
--- /dev/null
+++ b/string/isJSON.js
@@ -0,0 +1,26 @@
+/**
+ * isJSON
+ * Determines whether the input string is a valid JSON string
+ * @param {string} str - String to parse
+ * @returns {boolean} Is JSON string or not
+ *
+ * @example
isJSON
+ * isJSON(null)
+ * // false
+ * isJSON('{"name": "John", "age": 30}')
+ * // true
+ * isJSON('{"name": "John", "age": 30,}')
+ * // false
+ */
+export default function strIsJSON(str) {
+ if (typeof str !== 'string') {
+ return false;
+ }
+ try {
+ JSON.parse(str);
+ return true;
+ }
+ catch {
+ return false;
+ }
+}
diff --git a/test/specs/map/compare.spec.js b/test/specs/map/compare.spec.js
new file mode 100644
index 0000000..4a74082
--- /dev/null
+++ b/test/specs/map/compare.spec.js
@@ -0,0 +1,41 @@
+import mapCompare from '../../../map/compare.js';
+
+describe('map/compare', () => {
+
+ [
+ [
+ [],
+ [],
+ ],
+ [
+ [['a', '1'], ['b', null], [1, 2]],
+ [['a', '1'], ['b', null], [1, 2]],
+ ],
+ ].forEach(([a, b]) => {
+ it(`should compare two maps with values: ${JSON.stringify(a)}`, () => {
+ const map1 = new Map(a);
+ const map2 = new Map(b);
+ const result = mapCompare(map1, map2);
+ expect(result).to.eql(true);
+ });
+ });
+
+ [
+ [
+ [[1, '1']],
+ [],
+ ],
+ [
+ [['a', '1'], ['b', null], [1, 2]],
+ [['a', '1'], ['b', false], [1, 2]],
+ ],
+ ].forEach(([a, b]) => {
+ it(`should reject two maps with differing values: ${JSON.stringify(a)}`, () => {
+ const map1 = new Map(a);
+ const map2 = new Map(b);
+ const result = mapCompare(map1, map2);
+ expect(result).to.eql(false);
+ });
+ });
+
+});
diff --git a/test/specs/string/isJSON.spec.js b/test/specs/string/isJSON.spec.js
new file mode 100644
index 0000000..9e94c2a
--- /dev/null
+++ b/test/specs/string/isJSON.spec.js
@@ -0,0 +1,26 @@
+import isJSON from '../../../string/isJSON.js';
+
+describe('string/isJSON', () => {
+
+ it('should accept a string and return an object', () => {
+
+ const json = {
+ test: 1
+ };
+
+ const str = JSON.stringify(json);
+
+ const test = isJSON(str);
+
+ expect(test).to.eql(true);
+ });
+
+ it('should return undefined if json is invalid', () => {
+
+ // Convert there and back
+
+ const test = isJSON('invalid json');
+
+ expect(test).to.eql(false);
+ });
+});