CHANGES
1 v0.8.2 -- 2012.06.22 2 Fix errors in Array's intersection and exclusion methods, related to improper 3 usage of contains method 4 5 v0.8.1 -- 2012.06.13 6 Reorganized internal logic of Function.prototype.memoize. So it's more safe now 7 and clears cache properly. Additionally preventCache option was provided. 8 9 v0.8.0 -- 2012.05.28 10 Again, major overhaul. Probably last experimental stuff was trashed, all API 11 looks more like standard extensions now. 12 13 Changes: 14 * Turn all Object.prototype extensions into functions and move them to Object 15 namespace. We learned that extending Object.prototype is bad idea in any case. 16 * Rename Function.prototype.curry into Function.prototype.partial. This function 17 is really doing partial application while currying is slightly different 18 concept. 19 * Convert Function.prototype.ncurry to new implementation of 20 Function.prototype.curry, it now serves real curry concept additionaly it 21 covers use cases for aritize and hold, which were removed. 22 * Rename Array's peek to last, and provide support for sparse arrays in it 23 * Rename Date's monthDaysCount into daysInMonth 24 * Simplify object iterators, now order of iteration can be configured with just 25 compareFn argument (no extra byKeys option) 26 * Rename Object.isDuplicate to Object.isCopy 27 * Rename Object.isEqual to Object.is which is compatible with future 'is' 28 keyword 29 * Function.memoize is now Function.prototype.memoize. Additionally clear cache 30 functionality is added, and access to original arguments object. 31 * Rename validation functions: assertNotNull to validValue, assertCallable to 32 validCallable. validValue was moved to Object namespace. On success they now 33 return validated value instead of true, it supports better composition. 34 Additionally created Date.validDate and Error.validError 35 * All documentation is now held in README.md not in code files. 36 * Move guid to String namespace. All guids now start with numbers. 37 * Array.generate: fill argument is now optional 38 * Object.toArray is now Array.from (as new ES6 specification draft suggests) 39 * All methods that rely on indexOf or lastIndexOf, now rely on egal (Object.is) 40 versions of them (eIndexOf, eLastIndexOf) 41 * Turn all get* functions that returned methods into actuall methods (get* 42 functionality can still be achieved with help of Function.prototype.partial). 43 So: Date.getFormat is now Date.prototype.format, 44 Number.getPad is now Number.prototype.pad, 45 String.getFormat is now String.prototype.format, 46 String.getIndent is now String.prototype.indent, 47 String.getPad is now String.prototype.pad 48 * Refactored Object.descriptor, it is now just two functions, main one and 49 main.gs, main is for describing values, and gs for describing getters and 50 setters. Configuration is passed with first argument as string e.g. 'ce' for 51 configurable and enumerable. If no configuration string is provided then by 52 default it returns configurable and writable but not enumerable for value or 53 configurable but not enumerable for getter/setter 54 * Function.prototype.silent now returns prepared function (it was 55 expected to be fixed for 0.7) 56 * Reserved keywords map (reserved) is now array not hash. 57 * Object.merge is now Object.extend (while former Object.extend was completely 58 removed) - 'extend' implies that we change object, not creating new one (as 59 'merge' may imply). Similarily Object.mergeProperties was renamed to 60 Object.extendProperties 61 * Position argument support in Array.prototype.contains and 62 String.prototype.contains (so it follows ES6 specification draft) 63 * endPosition argument support in String.prototype.endsWith and fromPosition 64 argument support in String.prototype.startsWith (so it follows ES6 65 specification draft) 66 * Better and cleaner String.prototype.indent implementation. No default value 67 for indent string argument, optional nest value (defaults to 1), remove 68 nostart argument 69 * Correct length values for most methods (so they reflect length of similar 70 methods in standard) 71 * Length argument is now optional in number and string pad methods. 72 * Improve arguments validation in general, so it adheres to standard conventions 73 * Fixed format of package.json 74 75 Removed methods and functions: 76 * Object.prototype.slice - Object is not ordered collection, so slice doesn't 77 make sense. 78 * Function's rcurry, rncurry, s - too cumbersome for JS, not many use cases for 79 that 80 * Function.prototype.aritize and Function.prototype.hold - same functionality 81 can be achieved with new Function.prototype.curry 82 * Function.prototype.log - provided more generic Function.prototype.wrap for 83 same use case 84 * getNextIdGenerator - no use case for that (String.guid should be used if 85 needed) 86 * Object.toObject - Can be now acheived with Object(validValue(x)) 87 * Array.prototype.someValue - no real use case (personally used once and 88 case was already controversial) 89 * Date.prototype.duration - moved to external package 90 * Number.getAutoincrement - No real use case 91 * Object.prototype.extend, Object.prototype.override, 92 Object.prototype.plainCreate, Object.prototype.plainExtend - It was probably 93 too complex, same should be achieved just with Object.create, 94 Object.descriptor and by saving references to super methods in local scope. 95 * Object.getCompareBy - Functions should be created individually for each use 96 case 97 * Object.get, Object.getSet, Object.set, Object.unset - Not many use cases and 98 same can be easily achieved with simple inline function 99 * String.getPrefixWith - Not real use case for something that can be easily 100 achieved with '+' operator 101 * Object.isPrimitive - It's just negation of Object.isObject 102 * Number.prototype.isLess, Number.prototype.isLessOrEqual - they shouldn't be in 103 Number namespace and should rather be addressed with simple inline functions. 104 * Number.prototype.subtract - Should rather be addressed with simple inline 105 function 106 107 New methods and functions: 108 * Array.prototype.lastIndex - Returns last declared index in array 109 * String.prototype.last - last for strings 110 * Function.prototype.wrap - Wrap function with other, it allows to specify 111 before and after behavior transform return value or prevent original function 112 from being called. 113 * Math.sign - Returns sign of a number (already in ES6 specification draft) 114 * Number.toInt - Converts value to integer (already in ES6 specification draft) 115 * Number.isNaN - Returns true if value is NaN (already in ES6 specification 116 draft) 117 * Number.toUint - Converts value to unsigned integer 118 * Number.toUint32 - Converts value to 32bit unsigned integer 119 * Array.prototype.eIndexOf, eLastIndexOf - Egal version (that uses Object.is) of 120 standard methods (all methods that were using native indexOf or lastIndexOf 121 now uses eIndexOf and elastIndexOf respectively) 122 * Array.of - as it's specified for ES6 123 124 Fixes: 125 * Fixed binarySearch so it always returns valid list index 126 * Object.isList - it failed on lists that are callable (e.g. NodeList in Nitro 127 engine) 128 * Object.map now supports third argument for callback 129 130 v0.7.1 -- 2012.01.05 131 New methods: 132 * Array.prototype.firstIndex - returns first valid index of array (for 133 sparse arrays it may not be '0' 134 135 Improvements: 136 * Array.prototype.first - now returns value for index returned by firstIndex 137 * Object.prototype.mapToArray - can be called without callback, then array of 138 key-value pairs is returned 139 140 Fixes 141 * Array.prototype.forEachRight, object's length read through UInt32 conversion 142 143 v0.7.0 -- 2011.12.27 144 Major update. 145 Stepped back from experimental ideas and introduced more standard approach 146 taking example from how ES5 methods and functions are designed. One exceptions 147 is that, we don’t refrain from declaring methods for Object.prototype - it’s up 148 to developer whether how he decides to use it in his context (as function or as 149 method). 150 151 In general: 152 * Removed any method 'functionalization' and functionalize method itself. 153 es5-ext declares plain methods, which can be configured to work as functions 154 with call.bind(method) - see documentation. 155 * Removed separation of Object methods for ES5 (with descriptors) and 156 ES3 (plain) - we're following ES5 idea on that, some methods are intended just 157 for enumerable properties and some are for all properties, all are declared 158 for Object.prototype 159 * Removed separation of Array generic (collected in List folder) and not generic 160 methods (collected in Array folder). Now all methods are generic and are in 161 Array/prototype folder. This separation also meant, that methods in Array are 162 usually destructive. We don’t do that separation now, there’s generally no use 163 case for destructive iterators, we should be fine with one version of each 164 method, (same as ES5 is fine with e.g. one, non destructive 'filter' method) 165 * Folder structure resembles tree of native ES5 Objects 166 * All methods are written with ES5 conventions in mind, it means that most 167 methods are generic and can be run on any object. In more detail: 168 ** Array.prototype and Object.prototype methods can be run on any object (any 169 not null or undefined value), 170 ** Date.prototype methods should be called only on Date instances. 171 ** Function.prototype methods can be called on any callable objects (not 172 necessarily functions) 173 ** Number.prototype & String.prototype methods can be called on any value, in 174 case of Number it it’ll be degraded to number, in case of string it’ll be 175 degraded to string. 176 * Travis CI support (only for Node v0.6 branch, as v0.4 has buggy V8 version) 177 178 Improvements for existing functions and methods: 179 * Function.memoize (was Function.cache) is now fully generic, can operate on any 180 type of arguments and it’s NaN safe (all NaN objects are considered equal) 181 * Method properties passed to Object.prototype.extend or 182 Object.prototype.override can aside of _super optionally take prototype object 183 via _proto argument 184 * Object iterators: forEach, mapToArray and every can now iterate in specified 185 order 186 * pluck, invoke and other functions that return reusable functions or methods 187 have now their results memoized. 188 189 New methods: 190 * Global: assertNotNull, getNextIdGenerator, guid, isEqual, isPrimitive, 191 toObject 192 * Array: generate 193 * Array.prototype: binarySearch, clear, contains, diff, exclusion, find, first, 194 forEachRight, group, indexesOf, intersection, remove, someRight, someValue 195 * Boolean: isBoolean 196 * Date: isDate 197 * Function: arguments, context, insert, isArguments, remove 198 * Function.prototype: not, silent 199 * Number: getAutoincrement, isNumber 200 * Number.prototype: isLessOrEqual, isLess, subtract 201 * Object: assertCallable, descriptor (functions for clean descriptors), 202 getCompareBy, isCallable, isObject 203 * Object.prototype: clone (real clone), compact, count, diff, empty, 204 getPropertyNames, get, keyOf, mapKeys, override, plainCreate, plainExtend, 205 slice, some, unset 206 * RegExp: isRegExp 207 * String: getPrefixWith, isString 208 * String.prototype: caseInsensitiveCompare, contains, isNumeric 209 210 Renamed methods: 211 * Date.clone -> Date.prototype.copy 212 * Date.format -> Date.getFormat 213 * Date/day/floor -> Date.prototype.floorDay 214 * Date/month/floor -> Date.prototype.floorMonth 215 * Date/month/year -> Date.prototype.floorYear 216 * Function.cache -> Function.memoize 217 * Function.getApplyArg -> Function.prototype.match 218 * Function.sequence -> Function.prototype.chain 219 * List.findSameStartLength -> Array.prototype.commonLeft 220 * Number.pad -> Number.getPad 221 * Object/plain/clone -> Object.prototype.copy 222 * Object/plain/elevate -> Object.prototype.flatten 223 * Object/plain/same -> Object.prototype.isDuplicate 224 * Object/plain/setValue -> Object.getSet 225 * String.format -> String.getFormat 226 * String.indent -> String.getIndent 227 * String.pad -> String.getPad 228 * String.trimLeftStr -> String.prototype.trimCommonLeft 229 * Object.merge -> Object.prototype.mergeProperties 230 * Object/plain/pluck -> Object.prototype.get 231 * Array.clone is now Array.prototype.copy and can be used also on any array-like 232 objects 233 * List.isList -> Object.isList 234 * List.toArray -> Object.prototype.toArray 235 * String/convert/dashToCamelCase -> String.prototype.dashToCamelCase 236 237 Removed methods: 238 * Array.compact - removed destructive version (that operated on same array), we 239 have now non destructive version as Array.prototype.compact. 240 * Function.applyBind -> use apply.bind directly 241 * Function.bindBind -> use bind.bind directly 242 * Function.callBind -> use call.bind directly 243 * Fuction.clone -> no valid use case 244 * Function.dscope -> controversial approach, shouldn’t be considered seriously 245 * Function.functionalize -> It was experimental but standards are standards 246 * List/sort/length -> It can be easy obtained by Object.getCompareBy(‘length’) 247 * List.concat -> Concat’s for array-like’s makes no sense, just convert to array 248 first 249 * List.every -> Use Array.prototype.every directly 250 * List.filter -> Use Array.prototype.filter directly 251 * List.forEach -> User Array.prototype.forEach directly 252 * List.isListObject -> No valid use case, do: isList(list) && (typeof list === 253 'object’) 254 * List.map -> Use Array.prototype.map directly 255 * List.reduce -> Use Array.prototype.reduce directly 256 * List.shiftSame -> Use Array.prototype.commonLeft and do slice 257 * List.slice -> Use Array.prototype.slice directly 258 * List.some -> Use Array.prototype.some directly 259 * Object.bindMethods -> it was version that considered descriptors, we have now 260 Object.prototype.bindMethods which operates only on enumerable properties 261 * Object.every -> version that considered all properties, we have now 262 Object.prototype.every which iterates only enumerables 263 * Object.invoke -> no use case 264 * Object.mergeDeep -> no use case 265 * Object.pluck -> no use case 266 * Object.same -> it considered descriptors, now there’s only Object.isDuplicate 267 which compares only enumerable properties 268 * Object.sameType -> no use case 269 * Object.toDescriptor and Object.toDescriptors -> replaced by much nicer 270 Object.descriptor functions 271 * Object/plain/link -> no use case (it was used internally only by 272 Object/plain/merge) 273 * Object/plain/setTrue -> now easily configurable by more universal 274 Object.getSet(true) 275 * String.trimRightStr -> Eventually String.prototype.trimCommonRight will be 276 added 277 278 v0.6.3 -- 2011.12.12 279 * Cleared npm warning for misnamed property in package.json 280 281 v0.6.2 -- 2011.08.12 282 * Calling String.indent without scope (global scope then) now treated as calling 283 it with null scope, it allows more direct invocations when using default nest 284 string: indent().call(str, nest) 285 286 v0.6.1 -- 2011.08.08 287 * Added TAD test suite to devDependencies, configured test commands. 288 Tests can be run with 'make test' or 'npm test' 289 290 v0.6.0 -- 2011.08.07 291 New methods: 292 * Array: clone, compact (in place) 293 * Date: format, duration, clone, monthDaysCount, day.floor, month.floor, 294 year.floor 295 * Function: getApplyArg, , ncurry, rncurry, hold, cache, log 296 * List: findSameStartLength, shiftSame, peek, isListObject 297 * Number: pad 298 * Object: sameType, toString, mapToArray, mergeDeep, toDescriptor, 299 toDescriptors, invoke 300 * String: startsWith, endsWith, indent, trimLeftStr, trimRightStr, pad, format 301 302 Fixed: 303 * Object.extend does now prototypal extend as exptected 304 * Object.merge now tries to overwrite only configurable properties 305 * Function.flip 306 307 Improved: 308 * Faster List.toArray 309 * Better global retrieval 310 * Functionalized all Function methods 311 * Renamed bindApply and bindCall to applyBind and callBind 312 * Removed Function.inherit (as it's unintuitive curry clone) 313 * Straightforward logic in Function.k 314 * Fixed naming of some tests files (letter case issue) 315 * Renamed Function.saturate into Function.lock 316 * String.dashToCamelCase digits support 317 * Strings now considered as List objects 318 * Improved List.compact 319 * Concise logic for List.concat 320 * Test wit TAD in clean ES5 context 321 322 v0.5.1 -- 2011.07.11 323 * Function's bindBind, bindCall and bindApply now more versatile 324 325 v0.5.0 -- 2011.07.07 326 * Removed Object.is and List.apply 327 * Renamed Object.plain.is to Object.plain.isPlainObject (keep naming convention 328 consistent) 329 * Improved documentation 330 331 v0.4.0 -- 2011.07.05 332 * Take most functions on Object to Object.plain to keep them away from object 333 descriptors 334 * Object functions with ES5 standard in mind (object descriptors) 335 336 v0.3.0 -- 2011.06.24 337 * New functions 338 * Consistent file naming (dash instead of camelCase) 339 340 v0.2.1 -- 2011.05.28 341 * Renamed Functions.K and Function.S to to lowercase versions (use consistent 342 naming) 343 344 v0.2.0 -- 2011.05.28 345 * Renamed Array folder to List (as its generic functions for array-like objects) 346 * Added Makefile 347 * Added various functions 348 349 v0.1.0 -- 2011.05.24 350 * Initial version