tough-cookie-file-store
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -170,2 +170,6 @@ 'use strict'; | ||
FileCookieStore.prototype.isEmpty = function (){ | ||
return isEmptyObject(this.idx); | ||
} | ||
function saveToFile(filePath, data, cb) { | ||
@@ -202,2 +206,11 @@ var dataJson = JSON.stringify(data); | ||
cb(dataJson); | ||
} | ||
function isEmptyObject(obj) { | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
{ | ||
"name": "tough-cookie-file-store", | ||
"description": "Another file store for tough-cookie module", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Ivan Marban", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/ivanmarban/tough-cookie-file-store", |
# tough-cookie-file-store | ||
[![NPM](https://nodei.co/npm/tough-cookie-file-store.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/tough-cookie-file-store/) | ||
Another file store for tough-cookie module. | ||
@@ -13,10 +16,19 @@ | ||
``` js | ||
var FileCookieStore = require('tough-cookie-file-store'); | ||
var cookieStore = require('tough-cookie-file-store'); | ||
var CookieJar = require('tough-cookie').CookieJar; | ||
var jar = new CookieJar(new FileCookieStore('./cookie.json')); | ||
var jar = new CookieJar(new cookieStore('./cookie.json')); | ||
/* check if cookie is expired */ | ||
var cookieStore = require('tough-cookie-filestore'); | ||
/* check if cookie is empty or expired */ | ||
var cookieStore = require('tough-cookie-file-store'); | ||
var cookieInstance = new cookieStore('./cookie.json'); | ||
cookieInstance.isExpired() // will return True if the cookies is expired | ||
cookieInstance.isExpired() // will return True if the cookie is expired | ||
cookieInstance.isEmpty() // will return True is cookie is empty | ||
/* request example */ | ||
var cookieStore = require('tough-cookie-file-store'); | ||
var j = request.jar(new cookieStore('./cookie.json')); | ||
request = request.defaults({ jar : j }) | ||
request('http://www.google.com', function() { | ||
request('http://images.google.com') | ||
}) | ||
``` | ||
@@ -39,2 +51,2 @@ | ||
[4]: https://github.com/vladh | ||
[5]: https://github.com/zhzehong | ||
[5]: https://github.com/zhzehong |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10153
192
51