JezK
Edit File: snapshot_cache.js
// Generated by CoffeeScript 2.7.0 (function() { Turbolinks.SnapshotCache = (function() { var keyForLocation; class SnapshotCache { constructor(size) { this.size = size; this.keys = []; this.snapshots = {}; } has(location) { var key; key = keyForLocation(location); return key in this.snapshots; } get(location) { var snapshot; if (!this.has(location)) { return; } snapshot = this.read(location); this.touch(location); return snapshot; } put(location, snapshot) { this.write(location, snapshot); this.touch(location); return snapshot; } // Private read(location) { var key; key = keyForLocation(location); return this.snapshots[key]; } write(location, snapshot) { var key; key = keyForLocation(location); return this.snapshots[key] = snapshot; } touch(location) { var index, key; key = keyForLocation(location); index = this.keys.indexOf(key); if (index > -1) { this.keys.splice(index, 1); } this.keys.unshift(key); return this.trim(); } trim() { var i, key, len, ref, results; ref = this.keys.splice(this.size); results = []; for (i = 0, len = ref.length; i < len; i++) { key = ref[i]; results.push(delete this.snapshots[key]); } return results; } }; keyForLocation = function(location) { return Turbolinks.Location.wrap(location).toCacheKey(); }; return SnapshotCache; }).call(this); }).call(this);