![]() Callbacks supplied to these methods may only be functions.Each of lodash's collection methods will be implemented to support arrays only, with an object-specific version provided separately. Slapdash's 'collection' methods are split into two sets - array and object. ![]() ![]() Unless the operand in question is declared near to where it is used (or there is an assertion/invariant to validate the type), it can be difficult to determine what type it actually is. Reading code which uses these methods can be difficult to reason about.There are subtleties to the behavior of each method depending on the types of the operands.al.) is that they can operate on either arrays or objects, and that they accept callbacks in the form of strings and objects, as well as simply functions. One of the most problematic aspects of using lodash's common methods (like map, each, reduce, et. However, I strongly recommend against this approach, as most bundling tools (such as webpack/browserify) add additional closures around each file you import, which both add cruft and work for the browser. If you find yourself only using a single method, you can import it directly from the source. You can then import the library like this: var _ = require('slapdash') If another script has tampered with the prototype (or doesn't provide one at all), we fall back to our own (small, performant) implementation. However, the first time it attempts to get a native method, it will make sure that it is the one it expected. Where possible, slapdash uses browser native methods to boost performance.This includes, for example, supporting strings in place of callbacks in map/ each/ filter etc. By not implementing the full lodash/underscore API, a lot of cruft can be removed.So, Slapdash featurefills missing native methods without touching any prototypes. I mean, it doesn't even have Object.keys!. Maybe you're writing script for deployment on 3rd party sites - maybe that 3rd party decides to override Function::bind with something incompatible? Don't worry. We don't all have control over our execution environment.IE8/9 are a distant memory for most web developers, but unfortunately for some of us they remain a waking nightmare.Slapdash's prodigious speed allows him to do everything quickly-which he likes, because anything else would require effort. Be compatible with Internet Explorer 8 and up.Slapdash is a lightweight JavaScript utility belt, inspired heavily by
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |