From 612aaff9dec6d62816d0ff68b05c8d83c7f5cfa5 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 2 Apr 2017 11:50:12 +0100 Subject: [PATCH] Node 4 compat --- .babelrc | 11 +++++++++++ .gitignore | 1 + index.js | 4 ++-- package.json | 11 ++++++++--- 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..272e041 --- /dev/null +++ b/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": [ + ["env", { + "loose": true, + "targets": { + "browsers": false, + "node": 4 + } + }] + ] +} diff --git a/.gitignore b/.gitignore index 5c843fd..feec9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ .nyc_output/ coverage/ +node4/ diff --git a/index.js b/index.js index 7873569..2e9c58c 100644 --- a/index.js +++ b/index.js @@ -97,7 +97,7 @@ module.exports = class CachePolicy { // The request method is understood by the cache and defined as being cacheable, and ('GET' === this._method || 'HEAD' === this._method || ('POST' === this._method && this._hasExplicitExpiration())) && // the response status code is understood by the cache, and - understoodStatuses.includes(this._status) && + understoodStatuses.indexOf(this._status) !== -1 && // the "no-store" cache directive does not appear in request or response header fields, and !this._rescc['no-store'] && // the "private" response directive does not appear in the response, if the cache is shared, and @@ -113,7 +113,7 @@ module.exports = class CachePolicy { // contains a public response directive. this._rescc.public || this._rescc['max-age'] || this._rescc['s-maxage'] || // has a status code that is defined as cacheable by default - statusCodeCacheableByDefault.includes(this._status) + statusCodeCacheableByDefault.indexOf(this._status) !== -1 )); } diff --git a/package.json b/package.json index 740a20c..61f9183 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,24 @@ { "name": "http-cache-semantics", - "version": "3.7.1", + "version": "3.7.3", "description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies", - "main": "index.js", "repository": "https://github.com/pornel/http-cache-semantics.git", + "main": "node4/index.js", "scripts": { - "test": "mocha" + "compile": "babel -d node4/ index.js; babel -d node4/test test", + "prepublish": "npm run compile", + "test": "npm run compile; mocha node4/test" }, "files": [ + "node4/index.js", "index.js", "test" ], "author": "Kornel LesiƄski (https://kornel.ski/)", "license": "BSD-2-Clause", "devDependencies": { + "babel-cli": "^6.24.0", + "babel-preset-env": "^1.3.2", "mocha": "^3.2.0" } }