Skip to content

Commit

Permalink
truncatenumber -> boundedNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
aaylward committed Jun 21, 2013
1 parent 1774e90 commit 98a5be8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions coffee/src/humanize.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ timeFormats = [
result += "..." if array.length > length

# Truncates a number to an upper bound.
@Humanize.truncateNumber = (num, bound, ending) ->
bound ?= 100
ending ?= "+"
@Humanize.boundedNumber = (num, bound=100, ending='+') ->
result = null

if isFinite(num) and isFinite(bound)
Expand Down
4 changes: 2 additions & 2 deletions coffee/test/test_humanize.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ describe 'Truncating objects to shorter versions', ->
expect(Humanize.truncate(objs.str, 14, '...kidding')).toEqual('abcd...kidding')

it 'should truncate a number to an upper bound', ->
expect(Humanize.truncateNumber(objs.num, 500)).toEqual('500+')
expect(Humanize.boundedNumber(objs.num, 500)).toEqual('500+')

it 'should not trucate things that are too short', ->
expect(Humanize.truncate(objs.str, objs.str.length + 1)).toEqual(objs.str)
expect(Humanize.truncateNumber(objs.num, objs.num + 1)).toEqual("#{objs.num}")
expect(Humanize.boundedNumber(objs.num, objs.num + 1)).toEqual("#{objs.num}")

describe 'Converting a list to a readable, oxford commafied string', ->
items = ['apple', 'orange', 'banana', 'pear', 'pineapple']
Expand Down
2 changes: 1 addition & 1 deletion public/dist/humanize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/src/humanize.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/test/test_humanize.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@
return expect(Humanize.truncate(objs.str, 14, '...kidding')).toEqual('abcd...kidding');
});
it('should truncate a number to an upper bound', function() {
return expect(Humanize.truncateNumber(objs.num, 500)).toEqual('500+');
return expect(Humanize.boundedNumber(objs.num, 500)).toEqual('500+');
});
return it('should not trucate things that are too short', function() {
expect(Humanize.truncate(objs.str, objs.str.length + 1)).toEqual(objs.str);
return expect(Humanize.truncateNumber(objs.num, objs.num + 1)).toEqual("" + objs.num);
return expect(Humanize.boundedNumber(objs.num, objs.num + 1)).toEqual("" + objs.num);
});
});

Expand Down

0 comments on commit 98a5be8

Please sign in to comment.