CHANGES 16 KB

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