grandfatherson
Advanced tools
Comparing version 0.1.3 to 1.0.0
## [1.0.0] - 2016-10-18 | ||
### Incompatible Changes | ||
* Renamed `to_keep` to `toKeep` and `to_delete` to `toDelete` to be consistent with JavaScript conventions. The original "snake-cased" names came from the original Python project. | ||
## [0.1.3] - 2016-10-14 | ||
@@ -3,0 +9,0 @@ |
12
index.js
@@ -9,3 +9,3 @@ | ||
function to_keep (datetimes, options) { | ||
function toKeep (datetimes, options) { | ||
@@ -59,3 +59,3 @@ _.defaults(options, { | ||
// Return a set of datetimes that should be deleted, out of 'datetimes` | ||
function to_delete(datetimes, options) { | ||
function toDelete(datetimes, options) { | ||
@@ -65,3 +65,3 @@ // We can't just a function like _.difference, because moment objects can't be compared that simply | ||
var seenSurvivors = {}; | ||
to_keep(datetimes, options).map(function (dt) { | ||
toKeep(datetimes, options).map(function (dt) { | ||
seenSurvivors[dt.toISOString()] = true; | ||
@@ -72,3 +72,3 @@ }) | ||
// The dates to delete are the ones not returned by to_keep | ||
// The dates to delete are the ones not returned by toKeep | ||
return _.filter(datetimes, function (dt) { return !seenSurvivors[ dt.toISOString() ] }); | ||
@@ -79,4 +79,4 @@ | ||
module.exports = { | ||
to_keep : to_keep, | ||
to_delete : to_delete | ||
toKeep : toKeep, | ||
toDelete : toDelete | ||
}; |
{ | ||
"name": "grandfatherson", | ||
"version": "0.1.3", | ||
"version": "1.0.0", | ||
"keywords": ["backup", "rotation", "algorithm", "snapshots" ], | ||
@@ -5,0 +5,0 @@ "description": "Grandfather Father Son algorithm, useful for backup rotation", |
@@ -1,4 +0,4 @@ | ||
# Grandfatherson | ||
# grandfatherson | ||
GrandFatherSon is a backup rotation calculator that implements the | ||
grandfatherson is a backup rotation calculator that implements the | ||
[grandfather-father-son rotation scheme](http://en.wikipedia.org/wiki/Backup_rotation_scheme#Grandfather-father-son_backup). | ||
@@ -16,3 +16,3 @@ | ||
var dates_to_delete = gfs.to_delete(datetimes, { | ||
var datesToDelete = gfs.toDelete(datetimes, { | ||
days : 7, | ||
@@ -29,6 +29,6 @@ weeks : 4, | ||
### to_delete(datetimes, options) | ||
### toDelete(datetimes, options) | ||
```javascript | ||
var condemed = gfs.to_delete(allDaysin1999, { | ||
var condemed = gfs.toDelete(allDaysin1999, { | ||
days:7, | ||
@@ -52,7 +52,7 @@ weeks:4, | ||
You provide details of dates you want to keep and `to_delete` returns a filtered list of the dates with dates-to-keep removed. The values in the returned array are moment objects sorted from oldest to newest. | ||
You provide details of dates you want to keep and `toDelete` returns a filtered list of the dates with dates-to-keep removed. The values in the returned array are moment objects sorted from oldest to newest. | ||
### to_keep(datetimes, options) | ||
### toKeep(datetimes, options) | ||
The same as `to_delete` above, but returning the array of dates to keep instead of the dates to delete. | ||
The same as `toDelete` above, but returning the array of dates to keep instead of the dates to delete. | ||
@@ -75,3 +75,3 @@ ## How it works | ||
Here you can see the backups that we would calculate *to_keep*. If you used *to_delete* instead, the result | ||
Here you can see the backups that we would calculate *toKeep*. If you used *toDelete* instead, the result | ||
be all the dates in 1999 expect these dates. | ||
@@ -82,3 +82,3 @@ | ||
var survivors = to_keep(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:moment.utc('1999-12-31')}) | ||
var survivors = toKeep(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:moment.utc('1999-12-31')}) | ||
@@ -85,0 +85,0 @@ // The result be as follows. |
@@ -37,7 +37,7 @@ "use strict" | ||
describe('to_keep', function () { | ||
var to_keep = gfs.to_keep; | ||
describe('toKeep', function () { | ||
var toKeep = gfs.toKeep; | ||
// Simulate it being the last day of the year | ||
var survivors = to_keep(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:lastDayof1999}) | ||
var survivors = toKeep(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:lastDayof1999}) | ||
@@ -65,10 +65,10 @@ var expectedDates = [ | ||
describe('to_delete', function () { | ||
var to_delete = gfs.to_delete; | ||
describe('toDelete', function () { | ||
var toDelete = gfs.toDelete; | ||
// Simulate it being the last day of the year | ||
var condemned = to_delete(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:lastDayof1999}) | ||
var condemned = toDelete(allDaysin1999, {days:7, weeks:4, months:3, firstweekday:SATURDAY, now:lastDayof1999}) | ||
it("should return the original set missing the ones that to_keep would return", function () { | ||
it("should return the original set missing the ones that toKeep would return", function () { | ||
expect(allDaysin1999).to.have.length(365); | ||
@@ -75,0 +75,0 @@ // We see above that 13 records were kept and we know there are 365 days in the year |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
41459
1