Comparing version 0.0.2 to 0.0.3
26
index.js
'use strict'; | ||
var has = Object.prototype.hasOwnProperty | ||
, cookie = require('cookie-monster') | ||
, monster = require('cookie-monster') | ||
, qs = require('querystringify') | ||
, storage = {} | ||
, prefix = '§'; | ||
, prefix = '§' | ||
, cookie; | ||
// | ||
// The export interface of the cookie-monster module is quite odd, if there is | ||
// no `document` in global it will simply not export the `get` and `set` | ||
// methods. Causing this module to fail on `undefined` function calls. Default | ||
// to an empty object when document doesn't exists solves it. | ||
// | ||
cookie = monster('undefined' !== typeof document ? document : {}); | ||
/** | ||
@@ -17,3 +26,3 @@ * Refresh the storage as other users might also be writing against it. | ||
var data = cookie.get('koekje') | ||
var data = cookie.get('koekje') || '' | ||
, length = 0 | ||
@@ -87,2 +96,3 @@ , key; | ||
storage = {}; | ||
cookie.set('koekje', '', { | ||
@@ -103,3 +113,11 @@ expires: new Date(0) | ||
return 'object' === typeof navigator && navigator.cookieEnabled; | ||
}()) | ||
}()), | ||
/** | ||
* Completely re-initiate the storage. | ||
* | ||
* @type {Function} | ||
* @api private | ||
*/ | ||
update: update | ||
}; | ||
@@ -106,0 +124,0 @@ |
{ | ||
"name": "koekje", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A sessionStorage interface for cookies", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha --reporter spec --ui bdd test.js", | ||
"watch": "mocha --watch --reporter spec --ui bdd test.js", | ||
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js", | ||
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js" | ||
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100", | ||
"test": "mocha test.js", | ||
"watch": "mocha --watch test.js", | ||
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js", | ||
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js" | ||
}, | ||
@@ -31,6 +32,6 @@ "repository": { | ||
"devDependencies": { | ||
"assume": "0.0.x", | ||
"assume": "1.3.x", | ||
"istanbul": "0.3.x", | ||
"mocha": "2.0.x", | ||
"pre-commit": "0.0.x" | ||
"mocha": "2.3.x", | ||
"pre-commit": "1.1.x" | ||
}, | ||
@@ -37,0 +38,0 @@ "dependencies": { |
13
test.js
@@ -5,3 +5,4 @@ describe('koekje', function () { | ||
// | ||
// Polyfill | ||
// Needs to be defined **before** we require the module so it doesn't start | ||
// failing. | ||
// | ||
@@ -74,5 +75,13 @@ global.document = { | ||
assume(cs.length).equals(0); | ||
assume(document.cookie).equals('koekje=; expires=Thu Jan 01 1970 01:00:00 GMT+0100 (CET)'); | ||
assume(document.cookie).includes('koekje=; expires=Thu Jan 01 1970'); | ||
}); | ||
}); | ||
describe('#update', function () { | ||
it('works without a cookie', function () { | ||
global.document.cookie = ''; | ||
cs.update(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9540
7
176
1