Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,29 @@ | ||
v1.1.2 | ||
===== | ||
### API Changes ### | ||
- Added Array#findIndex. | ||
- Added Array#sample. | ||
- Added String#compare. | ||
- Added Number#compare. | ||
- Added Date#compare. | ||
- Fixed issue with floats not properly being recognized in the query string. | ||
- Fixed issue with Object.isEmpty on non-object types and null. | ||
- Fixed issue with arrayEach not allowing negative start indexes. | ||
- Fixed issue with Array#reduce not recognizing 0 as a starting value. | ||
- Fixed issue with Array#add not allowing negative indexes. | ||
- Fixed issue with Number.random not recognizing upper limit of 0. | ||
- Fixed issue with String#dasherize not working on single camel cased letters. | ||
- Fixed issue with String#assign not working on an empty string or other falsy value. | ||
- Fixed issues with French and German date months not being correct. | ||
- Fixed Function#after not calling the method immediately when num is 0. | ||
### Internal Changes ### | ||
- Refactored Array#reduce and Array#reduceRight to use the same internal method. | ||
- Refactored String#camelize to be smaller. | ||
- Refactored checkMonthTraversal to be more robust in a variety of situations. | ||
v1.1.1 | ||
@@ -2,0 +30,0 @@ ===== |
@@ -0,1 +1,3 @@ | ||
Object.SugarMethods = {}; | ||
Array.prototype.any = function() {}; | ||
@@ -2,0 +4,0 @@ Array.prototype.clone = function() {}; |
@@ -119,3 +119,3 @@ | ||
hasPlural: true, | ||
months: ['janvier','février|fevrier','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre'], | ||
months: ['janvier','février|fevrier','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre|decembre'], | ||
weekdays: ['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'], | ||
@@ -149,3 +149,3 @@ units: ['milliseconde:|s','seconde:|s','minute:|s','heure:|s','jour:|s','semaine:|s','mois','an:|s|née|nee'], | ||
futureRelativeFormat: 1, | ||
months: ['Januar','Februar','März|Marz','April','Mai','Juni','Juli','August','September','November','Dezember'], | ||
months: ['Januar','Februar','März|Marz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'], | ||
weekdays: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], | ||
@@ -152,0 +152,0 @@ units: ['Millisekunde:|n','Sekunde:|n','Minute:|n','Stunde:|n','Tag:|en','Woche:|n','Monat:|en','Jahr:|en'], |
{ | ||
"name": "sugar", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A Javascript library for working with native objects.", | ||
@@ -5,0 +5,0 @@ "keywords": ["functional", "utility", "ender"], |
@@ -54,1 +54,11 @@ Sugar | ||
If you do add a custom format for your locale, please consider forking and adding it to the repo! This especially includes the addition of new locales, but also new formats or tweaks to existing locales. Not everything can be added to the main package, but I would like to have as many languages/formats as possible available. When adding a locale contribution, the most important thing is to add unit tests that assert the correct format. These unit tests are found at `unit_tests/environments/sugar/date_LOCALE.js`. Simply add or adjust the formats for the locale (the more tests, the better!) and issue me a pull request -- I will update the code to add these locales/formats. Have a look at other unit tests files for an example of the unit testing format. | ||
Contributing Lib Comparisons | ||
============================ | ||
Lib comparisons to various other libraries can be seen at http://sugarjs.com/libs. This is one of the areas where contributions are most welcome, as I don't have extensive knowledge of many different libraries, and there is so much to cover. To contribute simply find or create the appropriate lib name in `docs/libs`, and follow the format provided. This will be an ongoing process, and I will push changes here out to the site every so often. | ||
Other Contributions | ||
=================== | ||
For other contributions, please add well formed unit tests in the sugar environment at `unit_tests/environments/sugar/MODULE.js`. Unit tests can be run directly in the browser from `unit_tests/sugar.html`, and should all be passing in all major browsers (Webkit,Mozilla,Opera, and IE6+). Node.js unit tests should also be passing and can be run in the console with `unit_tests/node.sh`. Also of note is `unit_tests/prototype.html`, however depending on various circumstances not all tests may be passing, so it's good to do a before/after. Mootools can be ignored for the time being. |
@@ -11,6 +11,26 @@ test('Dates | German', function () { | ||
dateEqual(Date.create('2011'), new Date(2011, 0), 'Date#create | German | year'); | ||
dateEqual(Date.create('Mai'), new Date(now.getFullYear(), 4), 'Date#create | German | month'); | ||
dateEqual(Date.create('Januar'), new Date(now.getFullYear(), 0), 'Date#create | German | January'); | ||
dateEqual(Date.create('Februar'), new Date(now.getFullYear(), 1), 'Date#create | German | February'); | ||
dateEqual(Date.create('Marz'), new Date(now.getFullYear(), 2), 'Date#create | German | March'); | ||
dateEqual(Date.create('März'), new Date(now.getFullYear(), 2), 'Date#create | German | March'); | ||
dateEqual(Date.create('April'), new Date(now.getFullYear(), 3), 'Date#create | German | April'); | ||
dateEqual(Date.create('Mai'), new Date(now.getFullYear(), 4), 'Date#create | German | May'); | ||
dateEqual(Date.create('Juni'), new Date(now.getFullYear(), 5), 'Date#create | German | June'); | ||
dateEqual(Date.create('Juli'), new Date(now.getFullYear(), 6), 'Date#create | German | July'); | ||
dateEqual(Date.create('August'), new Date(now.getFullYear(), 7), 'Date#create | German | August'); | ||
dateEqual(Date.create('September'), new Date(now.getFullYear(), 8), 'Date#create | German | September'); | ||
dateEqual(Date.create('Oktober'), new Date(now.getFullYear(), 9), 'Date#create | German | October'); | ||
dateEqual(Date.create('November'), new Date(now.getFullYear(), 10), 'Date#create | German | November'); | ||
dateEqual(Date.create('Dezember'), new Date(now.getFullYear(), 11), 'Date#create | German | December'); | ||
dateEqual(Date.create('Sonntag'), getDateWithWeekdayAndOffset(0), 'Date#create | German | Sunday'); | ||
dateEqual(Date.create('Montag'), getDateWithWeekdayAndOffset(1), 'Date#create | German | Monday'); | ||
dateEqual(Date.create('Dienstag'), getDateWithWeekdayAndOffset(2), 'Date#create | German | Tuesday'); | ||
dateEqual(Date.create('Mittwoch'), getDateWithWeekdayAndOffset(3), 'Date#create | German | Wednesday'); | ||
dateEqual(Date.create('Donnerstag'), getDateWithWeekdayAndOffset(4), 'Date#create | German | Thursday'); | ||
dateEqual(Date.create('Freitag'), getDateWithWeekdayAndOffset(5), 'Date#create | German | Friday'); | ||
dateEqual(Date.create('Samstag'), getDateWithWeekdayAndOffset(6), 'Date#create | German | Saturday'); | ||
dateEqual(Date.create('einer Millisekunde vorher'), getRelativeDate(null, null, null, null, null, null,-1), 'Date#create | German | one millisecond ago'); | ||
@@ -17,0 +37,0 @@ dateEqual(Date.create('eine Sekunde vorher'), getRelativeDate(null, null, null, null, null, -1), 'Date#create | German | one second ago'); |
@@ -12,4 +12,25 @@ test('Dates | French', function () { | ||
dateEqual(Date.create('2011'), new Date(2011, 0), 'Date#create | French | year'); | ||
dateEqual(Date.create('mai'), new Date(now.getFullYear(), 4), 'Date#create | French | month'); | ||
dateEqual(Date.create('janvier'), new Date(now.getFullYear(), 0), 'Date#create | French | January'); | ||
dateEqual(Date.create('février'), new Date(now.getFullYear(), 1), 'Date#create | French | February'); | ||
dateEqual(Date.create('fevrier'), new Date(now.getFullYear(), 1), 'Date#create | French | February'); | ||
dateEqual(Date.create('mars'), new Date(now.getFullYear(), 2), 'Date#create | French | March'); | ||
dateEqual(Date.create('avril'), new Date(now.getFullYear(), 3), 'Date#create | French | April'); | ||
dateEqual(Date.create('mai'), new Date(now.getFullYear(), 4), 'Date#create | French | May'); | ||
dateEqual(Date.create('juin'), new Date(now.getFullYear(), 5), 'Date#create | French | June'); | ||
dateEqual(Date.create('juillet'), new Date(now.getFullYear(), 6), 'Date#create | French | July'); | ||
dateEqual(Date.create('août'), new Date(now.getFullYear(), 7), 'Date#create | French | August'); | ||
dateEqual(Date.create('septembre'), new Date(now.getFullYear(), 8), 'Date#create | French | September'); | ||
dateEqual(Date.create('octobre'), new Date(now.getFullYear(), 9), 'Date#create | French | October'); | ||
dateEqual(Date.create('novembre'), new Date(now.getFullYear(), 10), 'Date#create | French | November'); | ||
dateEqual(Date.create('décembre'), new Date(now.getFullYear(), 11), 'Date#create | French | December'); | ||
dateEqual(Date.create('decembre'), new Date(now.getFullYear(), 11), 'Date#create | French | December'); | ||
dateEqual(Date.create('dimanche'), getDateWithWeekdayAndOffset(0), 'Date#create | French | Sunday'); | ||
dateEqual(Date.create('lundi'), getDateWithWeekdayAndOffset(1), 'Date#create | French | Monday'); | ||
dateEqual(Date.create('mardi'), getDateWithWeekdayAndOffset(2), 'Date#create | French | Tuesday'); | ||
dateEqual(Date.create('mercredi'), getDateWithWeekdayAndOffset(3), 'Date#create | French | Wednesday'); | ||
dateEqual(Date.create('jeudi'), getDateWithWeekdayAndOffset(4), 'Date#create | French | Thursday'); | ||
dateEqual(Date.create('vendredi'), getDateWithWeekdayAndOffset(5), 'Date#create | French | Friday'); | ||
dateEqual(Date.create('samedi'), getDateWithWeekdayAndOffset(6), 'Date#create | French | Saturday'); | ||
@@ -16,0 +37,0 @@ |
@@ -515,6 +515,6 @@ | ||
result = arr.reduce(function(prev, el, i, o){ | ||
equal(prev, previous[count], 'Array#filter | first argument is the prev value'); | ||
equal(el, current[count], 'Array#filter | second argument is element'); | ||
equal(i, count + 1, 'Array#filter | third argument is index'); | ||
equal(o, arr, 'Array#filter | fourth argument is the array'); | ||
equal(prev, previous[count], 'Array#reduce | first argument is the prev value'); | ||
equal(el, current[count], 'Array#reduce | second argument is element'); | ||
equal(i, count + 1, 'Array#reduce | third argument is index'); | ||
equal(o, arr, 'Array#reduce | fourth argument is the array'); | ||
count++; | ||
@@ -555,2 +555,3 @@ return prev + el; | ||
equal([1,2,3].reduce(function(a, n){ return a + n; }, 0), 6, 'Array#reduce | can handle initial value of 0'); | ||
@@ -576,6 +577,6 @@ | ||
result = arr.reduceRight(function(prev, el, i, o){ | ||
equal(prev, previous[count], 'Array#filter | first argument is the prev value'); | ||
equal(el, current[count], 'Array#filter | second argument is element'); | ||
equal(i, 1 - count, 'Array#filter | third argument is index'); | ||
equal(o, arr, 'Array#filter | fourth argument is the array'); | ||
equal(prev, previous[count], 'Array#reduceRight | first argument is the prev value'); | ||
equal(el, current[count], 'Array#reduceRight | second argument is element'); | ||
equal(i, 1 - count, 'Array#reduceRight | third argument is index'); | ||
equal(o, arr, 'Array#reduceRight | fourth argument is the array'); | ||
count++; | ||
@@ -616,3 +617,6 @@ return prev + el; | ||
equal([1,2,3].reduceRight(function(a, n){ return a + n; }, 0), 6, 'Array#reduceRight | can handle initial value of 0'); | ||
// Polyfills can be run on objects that inherit from Arrays | ||
@@ -619,0 +623,0 @@ |
@@ -214,3 +214,6 @@ test('Function', function () { | ||
var fn, ret, counter = 0, i = 1; | ||
fn = (function() { | ||
var expectedArguments = [[[1,'bop'],[2,'bop'],[3,'bop'],[4,'bop'],[5,'bop']],[[6,'bop'],[7,'bop'],[8,'bop'],[9,'bop'],[10,'bop']]]; | ||
fn = (function(args) { | ||
equal(args, expectedArguments[counter], 'Function#after | collects arguments called'); | ||
equal(!!args[0].slice, true, 'Function#after | arguments are converted to actual arrays'); | ||
counter++; | ||
@@ -220,3 +223,3 @@ return 'hooha'; | ||
while(i <= 10) { | ||
ret = fn(); | ||
ret = fn(i, 'bop'); | ||
equal(ret, (i % 5 == 0 ? 'hooha' : undefined), 'Function#after | collects return value as well'); | ||
@@ -228,3 +231,10 @@ i++; | ||
async(function() { | ||
var fn, counter = 0; | ||
var fn = (function(args) { counter++; }).after(0); | ||
equal(counter, 1, 'Function#after | 0 should fire the function immediately'); | ||
equal(typeof fn, 'function', 'Function#after | 0 should still return a function'); | ||
}); | ||
// Function#once | ||
@@ -231,0 +241,0 @@ |
@@ -20,4 +20,11 @@ | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal(Number.random(0, 0), 0, 'Number.random | 0 should always remain 0'); | ||
equal((4).toNumber(), 4, 'Number#toNumber | 4 is 4'); | ||
@@ -465,5 +472,28 @@ equal((10000).toNumber(), 10000, 'Number#toNumber | 10000 is 10000'); | ||
// Number#compare | ||
// dateEqual(Date.create('Monday'), getDateWithWeekdayAndOffset(1), 'Date#create | Fuzzy Dates | Monday'); | ||
equal((0).compare(0), 0, 'Number#compare | 0 is equal to 0'); | ||
equal((0).compare(-1), 1, 'Number#compare | 0 is greater than -1'); | ||
equal((0).compare(1), -1, 'Number#compare | 0 is less than 1'); | ||
equal((1).compare(1), 0, 'Number#compare | 1 is equal to 1'); | ||
equal((1).compare(2), -1, 'Number#compare | 1 is less than 2'); | ||
equal((1).compare(0), 1, 'Number#compare | 1 is greater than than 0'); | ||
equal((5).compare(15), -10, 'Number#compare | 5 is less than than 15'); | ||
equal((15).compare(5), 10, 'Number#compare | 15 is greater than than 5'); | ||
equal((0).compare('0'), 0, 'Number#compare | strings are coerced | 0 is equal to 0'); | ||
equal((0).compare('-1'), 1, 'Number#compare | strings are coerced | 0 is greater than -1'); | ||
equal((0).compare('1'), -1, 'Number#compare | strings are coerced | 0 is less than 1'); | ||
equal((1).compare('1'), 0, 'Number#compare | strings are coerced | 1 is equal to 1'); | ||
equal((1).compare('2'), -1, 'Number#compare | strings are coerced | 1 is less than 2'); | ||
equal((1).compare('0'), 1, 'Number#compare | strings are coerced | 1 is greater than than 0'); | ||
equal((5).compare('15'), -10, 'Number#compare | strings are coerced | 5 is less than than 15'); | ||
equal((15).compare('5'), 10, 'Number#compare | strings are coerced | 15 is greater than than 5'); | ||
equal((15).compare('wasabi'), NaN, 'Number#compare | cannot compare numbers to strings'); | ||
equal((15).compare({ foo: 'bar' }), NaN, 'Number#compare | cannot compare numbers to objects'); | ||
equal((15).compare(/wasabi/), NaN, 'Number#compare | cannot compare numbers to regexps'); | ||
equal((15).compare(new Date) < 0, true, 'Number#compare | Dates are implicitly converted to numbers'); | ||
}); | ||
@@ -446,4 +446,6 @@ test('Object', function () { | ||
equal(Object.isEmpty(''), true, 'Object.isEmpty | empty string is empty'); | ||
equal(Object.isEmpty([]), true, 'Object.isEmpty | empty array is empty'); | ||
equal(Object.isEmpty(NaN), true, 'Object.isEmpty | NaN is empty'); | ||
equal(Object.isEmpty(0), true, 'Object.isEmpty | 0 is empty'); | ||
equal(Object.isEmpty(8), true, 'Object.isEmpty | 8 is empty'); | ||
@@ -645,2 +647,3 @@ equal(Object.extended({}).isEmpty({}), true, 'Object#isEmpty | object is empty'); | ||
equal(Object.fromQueryString('foo=3.14156'), { foo: 3.14156 }, 'String#fromQueryString | can handle float values'); | ||
@@ -647,0 +650,0 @@ // Object.watch |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1050199
55
18958
64