cacheability
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -0,1 +1,13 @@ | ||
#### 2.0.5 (2019-07-31) | ||
##### Chores | ||
* **dependencies|files:** upgrade dependencies and files ([#14](https://github.com/bad-batch/cacheability/pull/14)) ([63f29792](https://github.com/bad-batch/cacheability/commit/63f29792e7ce35abaa5f9d7a3378099e1238e300)) | ||
##### Bug Fixes | ||
* **readme:** | ||
* fix broken badge ([73224319](https://github.com/bad-batch/cacheability/commit/73224319ae8f9ec55950f42fa6a624829621e896)) | ||
* update badge url ([e94d7931](https://github.com/bad-batch/cacheability/commit/e94d79318bf825d5d34e80e499a903927d1278a2)) | ||
#### 2.0.4 (2018-07-13) | ||
@@ -2,0 +14,0 @@ |
@@ -1,2 +0,2 @@ | ||
export { Cacheability as default } from "./cacheability"; | ||
import"core-js/modules/es7.object.get-own-property-descriptors";import"core-js/modules/es6.symbol";import"core-js/modules/es6.object.keys";import"core-js/modules/web.dom.iterable";import"core-js/modules/es6.array.iterator";import"core-js/modules/es6.object.to-string";import"core-js/modules/es7.object.values";import"core-js/modules/es6.number.constructor";import e from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es6.regexp.match";import"core-js/modules/es6.regexp.split";import t from"@babel/runtime/helpers/classCallCheck";import r from"@babel/runtime/helpers/createClass";import a from"@babel/runtime/helpers/defineProperty";import o from"lodash/kebabCase";import s from"lodash/isString";import n from"lodash/isPlainObject";import c from"lodash/isNumber";import i from"lodash/isBoolean";import l from"lodash/camelCase";import"isomorphic-fetch";function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}var m=function(){function m(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,m),a(this,"metadata",void 0);var r=e.cacheControl,o=e.headers,s=e.metadata;this.metadata=r?m._setMetadata({cacheControl:m._parseCacheControl(r)}):o?m._setMetadata(m._parseHeaders(o)):s?m._validateMetadata(s):m._setDefaultMetadata()}return r(m,null,[{key:"_getDirectives",value:function(e){return e.split(", ")}},{key:"_parseCacheControl",value:function(t){var r={};return s(t)&&t.length?(m._getDirectives(t).forEach(function(t){if(t.match(/=/)){var a=t.split("="),o=e(a,2),s=o[0],n=o[1];r[l(s)]=Number(n)}else r[l(t)]=!0}),r):r}},{key:"_parseHeaders",value:function(e){var t={};return e instanceof Headers?m._headerKeys.forEach(function(r){var a=e.get(r);if(a){var o=l(r);t[o]=a}}):n(e)&&(t=e),{cacheControl:m._parseCacheControl(t.cacheControl),etag:t.etag}}},{key:"_setDefaultMetadata",value:function(){return{cacheControl:{},ttl:1/0}}},{key:"_setMetadata",value:function(e){var t=e.cacheControl;return{cacheControl:t,etag:e.etag,ttl:m._setTTL(t)}}},{key:"_setTTL",value:function(e){var t=e.maxAge,r=e.noCache,a=e.noStore,o=e.sMaxage;if(r||a)return 0;var s=o||t;if(!c(s))return 1/0;var n=1e3*s;return Date.now()+n}},{key:"_validateMetadata",value:function(e){if(!n(e))return this._setDefaultMetadata();var t=e.cacheControl,r=e.etag,a=e.ttl;return{cacheControl:n(t)?t:{},etag:s(r)?r:void 0,ttl:c(a)?a:1/0}}}]),r(m,[{key:"checkTTL",value:function(){return this.metadata.ttl>Date.now()}},{key:"printCacheControl",value:function(){if(!Object.values(this.metadata.cacheControl).length)return"";var e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(r,!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(r).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},this.metadata.cacheControl);if(e.sMaxage||e.maxAge){var t=this.checkTTL()?Math.round((this.metadata.ttl-Date.now())/1e3):0;e.sMaxage&&(e.sMaxage=t),e.maxAge&&(e.maxAge=t)}var r=[];return Object.keys(e).forEach(function(t){i(e[t])?r.push(o(t)):r.push("".concat(o(t),"=").concat(e[t]))}),r.join(", ")}}]),m}();a(m,"_headerKeys",["cache-control","etag"]);export default m; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
require("core-js/modules/es6.symbol"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
require("core-js/modules/web.dom.iterable"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Cacheability = void 0; | ||
require("core-js/modules/es7.object.values"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
var _kebabCase2 = _interopRequireDefault(require("lodash/kebabCase")); | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
var _isString2 = _interopRequireDefault(require("lodash/isString")); | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject")); | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber")); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean")); | ||
var _camelCase2 = _interopRequireDefault(require("lodash/camelCase")); | ||
require("isomorphic-fetch"); | ||
const lodash_1 = require("lodash"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Cacheability { | ||
constructor(args = {}) { | ||
const cacheControl = args.cacheControl, | ||
headers = args.headers, | ||
metadata = args.metadata; | ||
if (cacheControl) { | ||
this.metadata = Cacheability._setMetadata({ | ||
cacheControl: Cacheability._parseCacheControl(cacheControl) | ||
}); | ||
} else if (headers) { | ||
this.metadata = Cacheability._setMetadata(Cacheability._parseHeaders(headers)); | ||
} else if (metadata) { | ||
this.metadata = Cacheability._validateMetadata(metadata); | ||
} else { | ||
this.metadata = Cacheability._setDefaultMetadata(); | ||
} | ||
} | ||
static _getDirectives(cacheControl) { | ||
@@ -50,3 +37,3 @@ return cacheControl.split(", "); | ||
const obj = {}; | ||
if (!lodash_1.isString(cacheControl) || !cacheControl.length) return obj; | ||
if (!(0, _isString2.default)(cacheControl) || !cacheControl.length) return obj; | ||
@@ -57,12 +44,8 @@ const directives = Cacheability._getDirectives(cacheControl); | ||
if (dir.match(/=/)) { | ||
const _dir$split = dir.split("="), | ||
_dir$split2 = _slicedToArray(_dir$split, 2), | ||
key = _dir$split2[0], | ||
value = _dir$split2[1]; | ||
obj[lodash_1.camelCase(key)] = Number(value); | ||
const [key, value] = dir.split("="); | ||
obj[(0, _camelCase2.default)(key)] = Number(value); | ||
return; | ||
} | ||
obj[lodash_1.camelCase(dir)] = true; | ||
obj[(0, _camelCase2.default)(dir)] = true; | ||
}); | ||
@@ -79,6 +62,6 @@ return obj; | ||
if (!headerValue) return; | ||
const metadataKey = lodash_1.camelCase(key); | ||
const metadataKey = (0, _camelCase2.default)(key); | ||
parsed[metadataKey] = headerValue; | ||
}); | ||
} else if (lodash_1.isPlainObject(headers)) { | ||
} else if ((0, _isPlainObject2.default)(headers)) { | ||
parsed = headers; | ||
@@ -119,3 +102,3 @@ } | ||
const sec = sMaxage || maxAge; | ||
if (!lodash_1.isNumber(sec)) return Infinity; | ||
if (!(0, _isNumber2.default)(sec)) return Infinity; | ||
const ms = sec * 1000; | ||
@@ -126,13 +109,36 @@ return Date.now() + ms; | ||
static _validateMetadata(metadata) { | ||
if (!lodash_1.isPlainObject(metadata)) return this._setDefaultMetadata(); | ||
const cacheControl = metadata.cacheControl, | ||
etag = metadata.etag, | ||
ttl = metadata.ttl; | ||
if (!(0, _isPlainObject2.default)(metadata)) return this._setDefaultMetadata(); | ||
const { | ||
cacheControl, | ||
etag, | ||
ttl | ||
} = metadata; | ||
return { | ||
cacheControl: lodash_1.isPlainObject(cacheControl) ? cacheControl : {}, | ||
etag: lodash_1.isString(etag) ? etag : undefined, | ||
ttl: lodash_1.isNumber(ttl) ? ttl : Infinity | ||
cacheControl: (0, _isPlainObject2.default)(cacheControl) ? cacheControl : {}, | ||
etag: (0, _isString2.default)(etag) ? etag : undefined, | ||
ttl: (0, _isNumber2.default)(ttl) ? ttl : Infinity | ||
}; | ||
} | ||
constructor(args = {}) { | ||
(0, _defineProperty2.default)(this, "metadata", void 0); | ||
const { | ||
cacheControl, | ||
headers, | ||
metadata | ||
} = args; | ||
if (cacheControl) { | ||
this.metadata = Cacheability._setMetadata({ | ||
cacheControl: Cacheability._parseCacheControl(cacheControl) | ||
}); | ||
} else if (headers) { | ||
this.metadata = Cacheability._setMetadata(Cacheability._parseHeaders(headers)); | ||
} else if (metadata) { | ||
this.metadata = Cacheability._validateMetadata(metadata); | ||
} else { | ||
this.metadata = Cacheability._setDefaultMetadata(); | ||
} | ||
} | ||
checkTTL() { | ||
@@ -144,4 +150,5 @@ return this.metadata.ttl > Date.now(); | ||
if (!Object.values(this.metadata.cacheControl).length) return ""; | ||
const cacheControl = Object.assign({}, this.metadata.cacheControl); | ||
const cacheControl = _objectSpread({}, this.metadata.cacheControl); | ||
if (cacheControl.sMaxage || cacheControl.maxAge) { | ||
@@ -155,8 +162,8 @@ const maxAge = this.checkTTL() ? Math.round((this.metadata.ttl - Date.now()) / 1000) : 0; | ||
Object.keys(cacheControl).forEach(key => { | ||
if (lodash_1.isBoolean(cacheControl[key])) { | ||
directives.push(lodash_1.kebabCase(key)); | ||
if ((0, _isBoolean2.default)(cacheControl[key])) { | ||
directives.push((0, _kebabCase2.default)(key)); | ||
return; | ||
} | ||
directives.push(`${lodash_1.kebabCase(key)}=${cacheControl[key]}`); | ||
directives.push(`${(0, _kebabCase2.default)(key)}=${cacheControl[key]}`); | ||
}); | ||
@@ -168,4 +175,3 @@ return directives.join(", "); | ||
Cacheability._headerKeys = ["cache-control", "etag"]; | ||
exports.Cacheability = Cacheability; | ||
//# sourceMappingURL=index.js.map | ||
(0, _defineProperty2.default)(Cacheability, "_headerKeys", ["cache-control", "etag"]); |
@@ -6,6 +6,23 @@ "use strict"; | ||
}); | ||
var _exportNames = {}; | ||
Object.defineProperty(exports, "default", { | ||
enumerable: true, | ||
get: function () { | ||
return _cacheability.Cacheability; | ||
} | ||
}); | ||
var cacheability_1 = require("./cacheability"); | ||
var _cacheability = require("./cacheability"); | ||
exports.default = cacheability_1.Cacheability; | ||
//# sourceMappingURL=index.js.map | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _types[key]; | ||
} | ||
}); | ||
}); |
@@ -1,4 +0,2 @@ | ||
import "core-js/modules/es6.symbol"; | ||
import "core-js/modules/web.dom.iterable"; | ||
import "core-js/modules/es7.object.values"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _kebabCase from "lodash/kebabCase"; | ||
@@ -11,30 +9,8 @@ import _isString from "lodash/isString"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import "isomorphic-fetch"; | ||
export class Cacheability { | ||
constructor(args = {}) { | ||
const cacheControl = args.cacheControl, | ||
headers = args.headers, | ||
metadata = args.metadata; | ||
if (cacheControl) { | ||
this.metadata = Cacheability._setMetadata({ | ||
cacheControl: Cacheability._parseCacheControl(cacheControl) | ||
}); | ||
} else if (headers) { | ||
this.metadata = Cacheability._setMetadata(Cacheability._parseHeaders(headers)); | ||
} else if (metadata) { | ||
this.metadata = Cacheability._validateMetadata(metadata); | ||
} else { | ||
this.metadata = Cacheability._setDefaultMetadata(); | ||
} | ||
} | ||
static _getDirectives(cacheControl) { | ||
@@ -52,7 +28,3 @@ return cacheControl.split(", "); | ||
if (dir.match(/=/)) { | ||
const _dir$split = dir.split("="), | ||
_dir$split2 = _slicedToArray(_dir$split, 2), | ||
key = _dir$split2[0], | ||
value = _dir$split2[1]; | ||
const [key, value] = dir.split("="); | ||
obj[_camelCase(key)] = Number(value); | ||
@@ -122,5 +94,7 @@ return; | ||
if (!_isPlainObject(metadata)) return this._setDefaultMetadata(); | ||
const cacheControl = metadata.cacheControl, | ||
etag = metadata.etag, | ||
ttl = metadata.ttl; | ||
const { | ||
cacheControl, | ||
etag, | ||
ttl | ||
} = metadata; | ||
return { | ||
@@ -133,2 +107,24 @@ cacheControl: _isPlainObject(cacheControl) ? cacheControl : {}, | ||
constructor(args = {}) { | ||
_defineProperty(this, "metadata", void 0); | ||
const { | ||
cacheControl, | ||
headers, | ||
metadata | ||
} = args; | ||
if (cacheControl) { | ||
this.metadata = Cacheability._setMetadata({ | ||
cacheControl: Cacheability._parseCacheControl(cacheControl) | ||
}); | ||
} else if (headers) { | ||
this.metadata = Cacheability._setMetadata(Cacheability._parseHeaders(headers)); | ||
} else if (metadata) { | ||
this.metadata = Cacheability._validateMetadata(metadata); | ||
} else { | ||
this.metadata = Cacheability._setDefaultMetadata(); | ||
} | ||
} | ||
checkTTL() { | ||
@@ -140,4 +136,5 @@ return this.metadata.ttl > Date.now(); | ||
if (!Object.values(this.metadata.cacheControl).length) return ""; | ||
const cacheControl = Object.assign({}, this.metadata.cacheControl); | ||
const cacheControl = _objectSpread({}, this.metadata.cacheControl); | ||
if (cacheControl.sMaxage || cacheControl.maxAge) { | ||
@@ -162,3 +159,3 @@ const maxAge = this.checkTTL() ? Math.round((this.metadata.ttl - Date.now()) / 1000) : 0; | ||
} | ||
Cacheability._headerKeys = ["cache-control", "etag"]; | ||
//# sourceMappingURL=index.js.map | ||
_defineProperty(Cacheability, "_headerKeys", ["cache-control", "etag"]); |
export { Cacheability as default } from "./cacheability"; | ||
//# sourceMappingURL=index.js.map | ||
export * from "./types"; |
import "isomorphic-fetch"; | ||
import { CacheabilityArgs, Metadata } from "../types"; | ||
/** | ||
* A utility class to parse, store and print http cache headers. | ||
* | ||
* ```typescript | ||
* import Cacheability from "cacheability"; | ||
* | ||
* const headers = new Headers({ | ||
* "cache-control": "public, max-age=60", | ||
* "content-type": "application/json", | ||
* "etag": "33a64df551425fcc55e4d42a148795d9f25f89d4", | ||
* }); | ||
* | ||
* const cacheability = new Cacheability({ headers }); | ||
* | ||
* const { cacheControl, etag, ttl } = cacheability.metadata; | ||
* // cacheControl is { maxAge: 60, public: true } | ||
* // etag is 33a64df551425fcc55e4d42a148795d9f25f89d4 | ||
* // ttl is 1516060712991 if Date.now is 1516060501948 | ||
* ``` | ||
*/ | ||
export declare class Cacheability { | ||
@@ -12,7 +32,44 @@ private static _headerKeys; | ||
private static _validateMetadata; | ||
/** | ||
* The property holds the Cacheability instance's parsed cache | ||
* headers data, including cache control directives, etag, and | ||
* a derived TTL timestamp. | ||
*/ | ||
readonly metadata: Metadata; | ||
constructor(args?: CacheabilityArgs); | ||
/** | ||
* The method checks whether the TTL timestamp stored in the Cacheability | ||
* instance is still valid, by comparing it to the current timestamp. | ||
* | ||
* ```typescript | ||
* const cacheability = new Cacheability({ cacheControl: "public, max-age=3" }); | ||
* | ||
* // One second elapses... | ||
* | ||
* const isValid = cacheability.checkTTL(); | ||
* // isValid is true | ||
* | ||
* // Three seconds elapse... | ||
* | ||
* const isStillValid = cacheability.checkTTL(); | ||
* // isStillValid is false | ||
* ``` | ||
*/ | ||
checkTTL(): boolean; | ||
/** | ||
* The method prints a cache-control header field value based on | ||
* the Cacheability instance's metadata. The max-age and/or s-maxage | ||
* are derived from the TTL stored in the metadata. | ||
* | ||
* ```typescript | ||
* const cacheability = new Cacheability({ cacheControl: "public, max-age=60, s-maxage=60" }); | ||
* | ||
* // Five seconds elapse... | ||
* | ||
* const cacheControl = cacheability.printCacheControl(); | ||
* // cacheControl is "public, max-age=55, s-maxage=55" | ||
* ``` | ||
*/ | ||
printCacheControl(): string; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
export { Cacheability as default } from "./cacheability"; | ||
export { CacheabilityArgs, CacheControl, Metadata, } from "./types"; | ||
export * from "./types"; | ||
//# sourceMappingURL=index.d.ts.map |
export interface CacheabilityArgs { | ||
cacheControl?: string; | ||
headers?: Headers | CacheHeaders; | ||
metadata?: Metadata; | ||
cacheControl?: string; | ||
headers?: Headers | CacheHeaders; | ||
metadata?: Metadata; | ||
} | ||
export interface CacheHeaders { | ||
cacheControl?: string; | ||
etag?: string; | ||
cacheControl?: string; | ||
etag?: string; | ||
} | ||
export interface CacheControl { | ||
maxAge?: number; | ||
noCache?: boolean; | ||
noStore?: boolean; | ||
sMaxage?: number; | ||
[key: string]: string | number | boolean; | ||
maxAge?: number; | ||
noCache?: boolean; | ||
noStore?: boolean; | ||
sMaxage?: number; | ||
[key: string]: string | number | boolean | undefined; | ||
} | ||
/** @hidden */ | ||
export type HeaderKeys = Array<"cache-control" | "etag">; | ||
/** @private */ | ||
export declare type HeaderKeys = Array<"cache-control" | "etag">; | ||
export interface Metadata { | ||
cacheControl: CacheControl; | ||
etag?: string; | ||
ttl: number; | ||
cacheControl: CacheControl; | ||
etag?: string; | ||
ttl: number; | ||
} | ||
/** @hidden */ | ||
/** @private */ | ||
export interface ParsedCacheHeaders { | ||
cacheControl: CacheControl; | ||
etag?: string; | ||
cacheControl: CacheControl; | ||
etag?: string; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
145
package.json
{ | ||
"name": "cacheability", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "A utility class to parse, store and print http cache headers.", | ||
@@ -15,2 +15,5 @@ "author": "Dylan Aubrey <dylanaubrey@gmail.com>", | ||
}, | ||
"engines": { | ||
"node": "^10.16.0" | ||
}, | ||
"main": "lib/main/index.js", | ||
@@ -29,33 +32,25 @@ "module": "lib/module/index.js", | ||
"scripts": { | ||
"analyze:bundle": "webpack-bundle-analyzer \"bundle/stats.json\" \"lib/umd\" --mode static --report \"bundle/report.html\" --no-open", | ||
"build": "yarn run clean && yarn run test && yarn run compile && yarn run analyze:bundle && yarn run document", | ||
"clean": "gulp clean", | ||
"compile": "yarn run compile:main && yarn run compile:types && yarn run compile:module && yarn run compile:browser && yarn run compile:umd", | ||
"compile:browser": "cross-env BABEL_ENV=browser gulp browser", | ||
"compile:main": "cross-env BABEL_ENV=main gulp main", | ||
"compile:module": "cross-env BABEL_ENV=module gulp module", | ||
"compile:types": "gulp types", | ||
"compile:umd": "cross-env BABEL_ENV=browser webpack", | ||
"build": "yarn run clean:libs && yarn run compile", | ||
"clean": "yarn run clean:packages && yarn run clean:libs && yarn run clean:docs && yarn run clean:node_modules", | ||
"clean:docs": "del-cli ./docs", | ||
"clean:libs": "del-cli ./lib", | ||
"clean:node_modules": "del-cli ./node_modules", | ||
"compile": "concurrently npm:compile:*", | ||
"compile:browser": "cross-env BABEL_ENV=web rollup -c ./rollup.config.js", | ||
"compile:main": "cross-env BABEL_ENV=main babel ./src --out-dir ./lib/main --extensions \".ts\" --config-file ./babel.config.js", | ||
"compile:module": "cross-env BABEL_ENV=module babel ./src --out-dir ./lib/module --extensions \".ts\" --config-file ./babel.config.js", | ||
"compile:types": "tsc --declaration --declarationMap --emitDeclarationOnly", | ||
"cutoff": "cutoff", | ||
"cutoff:post-version": "yarn run document", | ||
"debug:web": "cross-env BABEL_ENV=debug karma start --no-single-run --browsers", | ||
"document": "gulp document", | ||
"lint": "yarn run tslint && yarn run markdownLint", | ||
"markdownLint": "markdownlint README.md", | ||
"cutoff:post-version": "yarn run compile && yarn run docs", | ||
"docs": "typedoc --includes ./src --out ./docs --options ./typedoc.js", | ||
"init": "yarn && yarn run compile", | ||
"lint": "tslint --project ./tsconfig.json", | ||
"publish-cutoff": "publish-cutoff", | ||
"test": "yarn run lint && yarn run type-check && yarn run test:web && yarn run test:node", | ||
"test:node": "cross-env TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./tsconfig.test.json\" nyc mocha --opts \"./mocha.opts\"", | ||
"test:web": "cross-env BABEL_ENV=browser karma start --single-run --browsers ChromeHeadless --reporters mocha,coverage-istanbul", | ||
"tslint": "gulp tslint", | ||
"type-check": "gulp type-check" | ||
"test": "jest --logHeapUsage", | ||
"type-check": "tsc --noEmit", | ||
"wipe": "del-cli ./yarn.lock ./node_modules" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn run test" | ||
} | ||
}, | ||
"dependencies": { | ||
"@babel/polyfill": "7.0.0-beta.44" | ||
}, | ||
"peerDependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"core-js": "^2.0", | ||
"isomorphic-fetch": "^2.2.1", | ||
@@ -65,57 +60,57 @@ "lodash": "^4.17.5" | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.44", | ||
"@babel/preset-env": "7.0.0-beta.44", | ||
"@babel/preset-stage-0": "7.0.0-beta.44", | ||
"@types/chai": "^4.1.4", | ||
"@types/isomorphic-fetch": "^0.0.34", | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-decorators": "^7.4.4", | ||
"@babel/plugin-proposal-export-default-from": "^7.5.2", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2", | ||
"@babel/plugin-proposal-function-sent": "^7.5.0", | ||
"@babel/plugin-proposal-json-strings": "^7.2.0", | ||
"@babel/plugin-proposal-numeric-separator": "^7.2.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.2.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0", | ||
"@babel/plugin-syntax-import-meta": "^7.2.0", | ||
"@babel/plugin-transform-runtime": "^7.5.5", | ||
"@babel/polyfill": "^7.4.4", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@babel/register": "7.5.5", | ||
"@babel/runtime": "^7.5.5", | ||
"@types/isomorphic-fetch": "^0.0.35", | ||
"@types/jest": "^24.0.15", | ||
"@types/lodash": "^4.14.110", | ||
"@types/mocha": "^5.2.4", | ||
"@types/node": "^10.5.1", | ||
"awesome-typescript-loader": "^5.2.0", | ||
"babel-eslint": "^8.2.5", | ||
"@types/node": "^12.6.8", | ||
"babel-eslint": "^10.0.2", | ||
"babel-plugin-lodash": "^3.3.4", | ||
"chai": "^4.0.2", | ||
"codecov": "^3.0.0", | ||
"concurrently": "^4.1.1", | ||
"core-js": "^2.6.8", | ||
"cross-env": "^5.2.0", | ||
"cutoff": "^0.0.15", | ||
"del": "^3.0.0", | ||
"eslint": "^5.0.1", | ||
"eslint-config-airbnb": "^17.0.0", | ||
"eslint-plugin-import": "^2.13.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.10.0", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^8.0.0-beta.0", | ||
"gulp-sourcemaps": "^2.6.2", | ||
"gulp-tslint": "^8.1.2", | ||
"gulp-typedoc": "^2.2.0", | ||
"gulp-typescript": "^5.0.0-alpha.2", | ||
"husky": "1.0.0-rc.8", | ||
"cutoff": "^0.2.7", | ||
"del-cli": "^2.0.0", | ||
"eslint": "^6.1.0", | ||
"eslint-config-airbnb": "^17.1.1", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-react": "^7.14.3", | ||
"fs-extra": "^8.1.0", | ||
"husky": "3.0.2", | ||
"isomorphic-fetch": "^2.2.1", | ||
"istanbul-instrumenter-loader": "^3.0.0", | ||
"karma": "^2.0.4", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage-istanbul-reporter": "^2.0.1", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^3.0.0", | ||
"jest": "^24.8.0", | ||
"lodash": "^4.17.5", | ||
"lodash-webpack-plugin": "^0.11.4", | ||
"markdownlint-cli": "^0.10.0", | ||
"merge-stream": "^1.0.1", | ||
"mocha": "^5.1.0", | ||
"nyc": "^12.0.2", | ||
"source-map-loader": "^0.2.3", | ||
"source-map-support": "^0.5.0", | ||
"ts-node": "^7.0.0", | ||
"markdownlint-cli": "^0.17.0", | ||
"rollup": "^1.17.0", | ||
"rollup-plugin-analyzer": "^3.1.2", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-commonjs": "^10.0.1", | ||
"rollup-plugin-json": "^4.0.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^5.1.1", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.8.0", | ||
"typedoc": "^0.11.1", | ||
"typescript": "^2.9.2", | ||
"uglifyjs-webpack-plugin": "^1.2.7", | ||
"webpack": "^4.14.0", | ||
"webpack-bundle-analyzer": "^2.9.1", | ||
"webpack-cli": "^3.0.8" | ||
"type-fest": "^0.6.0", | ||
"typedoc": "^0.15.0", | ||
"typedoc-plugin-markdown": "^2.1.0", | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -5,9 +5,6 @@ # cacheability | ||
[![Build Status](https://travis-ci.org/bad-batch/cacheability.svg?branch=master)](https://travis-ci.org/bad-batch/cacheability) | ||
[![codecov](https://codecov.io/gh/bad-batch/cacheability/branch/master/graph/badge.svg)](https://codecov.io/gh/bad-batch/cacheability) | ||
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=sonarqube%3Acacheability&metric=alert_status)](https://sonarcloud.io/dashboard?id=sonarqube%3Acacheability) | ||
[![Build Status](https://travis-ci.org/badbatch/cacheability.svg?branch=master)](https://travis-ci.org/badbatch/cacheability) | ||
[![codecov](https://codecov.io/gh/badbatch/cacheability/branch/master/graph/badge.svg)](https://codecov.io/gh/badbatch/cacheability) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) | ||
[![npm version](https://badge.fury.io/js/cacheability.svg)](https://badge.fury.io/js/cacheability) | ||
[![dependencies Status](https://david-dm.org/bad-batch/cacheability/status.svg)](https://david-dm.org/bad-batch/cacheability) | ||
[![devDependencies Status](https://david-dm.org/bad-batch/cacheability/dev-status.svg)](https://david-dm.org/bad-batch/cacheability?type=dev) | ||
@@ -22,3 +19,3 @@ ## Installation | ||
### Initialisation | ||
### Initialization | ||
@@ -96,2 +93,2 @@ The constructor takes either a Headers instance, object literal of header key/values, cache-control header field value | ||
Cacheability is [MIT Licensed](LICENSE). | ||
Cacheability is [MIT Licensed](LICENSE). |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
22
46301
4
544
92
2
1
+ Added@babel/runtime@7.26.7(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removed@babel/polyfill@7.0.0-beta.44
- Removed@babel/polyfill@7.0.0-beta.44(transitive)
- Removedregenerator-runtime@0.11.1(transitive)