Comparing version 0.0.5 to 0.0.6
0.0.6 / 2016-05-11 | ||
================== | ||
* fix test for node 6.0.0 | ||
* fix package for regexps | ||
0.0.5 / 2016-01-22 | ||
@@ -3,0 +9,0 @@ ================== |
11
index.js
@@ -16,3 +16,3 @@ /** | ||
var rdate = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/; | ||
var rregexp = /^\/|\/([gimy]*)$/g; | ||
var rregexp = /^\/([^\/]+)\/([gimy]*)$/; | ||
@@ -113,5 +113,8 @@ /** | ||
function stor(str) { | ||
var i = str.lastIndexOf('/'); | ||
var flags = str.slice(i + 1); | ||
return new RegExp(str.slice(1, i), flags); | ||
var m = str.match(rregexp) | ||
try { | ||
return new RegExp(m[1], m[2]) | ||
} catch (e) { | ||
return str | ||
} | ||
} | ||
@@ -118,0 +121,0 @@ |
{ | ||
"name": "superjson", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "extends JSON.stringify and JSON.parse to support additional JS types (Dates, RegExps, Functions, etc.)", | ||
@@ -12,3 +12,3 @@ "keywords": [], | ||
"dependencies": { | ||
"acorn": "^0.11.0", | ||
"acorn": "^3.1.0", | ||
"component-type": "^1.1.0", | ||
@@ -15,0 +15,0 @@ "json3": "^3.3.2" |
21
test.js
@@ -23,8 +23,9 @@ /** | ||
it('it should stringify undefined values', function() { | ||
var str = json.parse('["undefined"]') | ||
assert.deepEqual(str, [undefined]) | ||
it('it should parse undefined arrays', function() { | ||
var str = json.parse('["undefined", 1]') | ||
assert.equal(str[0], undefined) | ||
assert.equal(str[1], 1) | ||
}) | ||
it('should parse undefined values', function() { | ||
it('should parse undefined objects', function() { | ||
var obj = json.parse('{ "name": "undefined" }') | ||
@@ -50,2 +51,14 @@ assert.equal(typeof obj.name, 'undefined') | ||
}) | ||
it('should ignore regexp-like expressions', function() { | ||
assert.equal(json.parse('/hi'), '/hi') | ||
}) | ||
it('should handle regexp', function() { | ||
assert.equal(json.parse('/^^hi/g').source, '^^hi') | ||
}) | ||
it('should handle regexp errors', function() { | ||
assert.equal(json.parse('/[\\\]/'), '/[\\]/') | ||
}) | ||
}) |
7516
178
+ Addedacorn@3.3.0(transitive)
- Removedacorn@0.11.0(transitive)
Updatedacorn@^3.1.0