Comparing version 1.3.0 to 1.4.0
@@ -66,5 +66,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.geheugen = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
value: function reset() { | ||
this.dependants.forEach(function (dependant) { | ||
return dependant.reset(); | ||
}); | ||
this.resetDependants(); | ||
@@ -75,2 +73,9 @@ this.onReset(); | ||
} | ||
}, { | ||
key: "resetDependants", | ||
value: function resetDependants() { | ||
this.dependants.forEach(function (dependant) { | ||
return dependant.reset(); | ||
}); | ||
} | ||
}]); | ||
@@ -77,0 +82,0 @@ |
@@ -65,5 +65,3 @@ "use strict"; | ||
value: function reset() { | ||
this.dependants.forEach(function (dependant) { | ||
return dependant.reset(); | ||
}); | ||
this.resetDependants(); | ||
@@ -74,2 +72,9 @@ this.onReset(); | ||
} | ||
}, { | ||
key: "resetDependants", | ||
value: function resetDependants() { | ||
this.dependants.forEach(function (dependant) { | ||
return dependant.reset(); | ||
}); | ||
} | ||
}]); | ||
@@ -76,0 +81,0 @@ |
{ | ||
"name": "geheugen", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A memoisation toolkit", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -160,2 +160,6 @@ # geheugen | ||
##### resetDependants() | ||
Reset all memos that have specified this memo as a dependency. | ||
#### properties | ||
@@ -162,0 +166,0 @@ |
@@ -42,3 +42,3 @@ export class Memo { | ||
reset() { | ||
this.dependants.forEach(dependant => dependant.reset()); | ||
this.resetDependants(); | ||
@@ -49,2 +49,6 @@ this.onReset(); | ||
} | ||
resetDependants() { | ||
this.dependants.forEach(dependant => dependant.reset()); | ||
} | ||
} |
@@ -228,2 +228,24 @@ import sinon from 'sinon'; | ||
}); | ||
describe('resetDependants()', () => { | ||
it('should reset the dependants', () => { | ||
// Given | ||
let memo = new Memo(); | ||
let dependants = [ 1, 2, 3 ].map(n => { | ||
let dependant = new Memo({ dependencies: [ memo ] }); | ||
sinon.spy(dependant, 'reset'); | ||
return dependant; | ||
}); | ||
// When | ||
memo.resetDependants(); | ||
// Then | ||
dependants.forEach(dependant => { | ||
expect(dependant.reset).to.have.been.called; | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36506
435
205
14