quick tweaks to clamp.

This commit is contained in:
Chris Talkington 2014-01-06 02:33:14 -06:00
parent 4d31ce9d77
commit a606c781a7
2 changed files with 18 additions and 18 deletions

View file

@ -2,7 +2,7 @@ var ZEROS = '0000000000000000000';
var ZERO_OFFSET = '0'.charCodeAt(0);
var USTAR = 'ustar00';
function clamp(index, len, defaultValue) {
var clamp = function(index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue;
index = ~~index; // Coerce to integer.
if (index >= len) return len;
@ -10,7 +10,7 @@ function clamp(index, len, defaultValue) {
index += len;
if (index >= 0) return index;
return 0;
}
};
var toType = function(flag) {
switch (flag) {

View file

@ -4,7 +4,7 @@ var fixtures = require('./fixtures');
var concat = require('concat-stream');
var fs = require('fs');
function clamp(index, len, defaultValue) {
var clamp = function(index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue;
index = ~~index; // Coerce to integer.
if (index >= len) return len;
@ -12,7 +12,7 @@ function clamp(index, len, defaultValue) {
index += len;
if (index >= 0) return index;
return 0;
}
};
test('one-file', function(t) {
t.plan(3);