Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

array-reduce-prototypejs-fix

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Issues
File Explorer

Advanced tools

array-reduce-prototypejs-fix

Safe `Array.reduce()` when using PrototypeJS v1.6 and lower.

    1.2.0latest

Version published
Maintainers
1
Yearly downloads
11,537
increased by1082.07%

Weekly downloads

Readme

Source

Safe Array.reduce when using PrototypeJS v1.6 and lower

PrototypeJS was a popular JS library many years ago. It extended and changed native objects. Which led to collisions with newer versions of browsers, if they implemented methods with the same names. This is the case of Array.reduce() (see native versus Prototype's implementation).

This, kids, is exactly why you should never touch native objects. And this is why PrototypeJS lost JavaScript libraries war and Jquery won.

Anyway, if you need to use Array.reduce() in a project that uses PrototypeJS v1.6 and lower (they removed it from v1.7), this module should help you. Since PrototypeJS replaced the original method, there's no way to get it back. We could replace the method with polyfill, but that would potentially break the code expecting PrototypeJS' method. So instead we create a new function. It checks for the presence of PrototypeJS. If it is there, it uses polyfill. Otherwise it uses native implementation.

Just remember that this should be a temporary fix. Real fix would be to get rid of PrototypeJS from your project. Or at least to upgrade it to v1.7.

Documentation

index

Does exactly the same as native Array.reduce(), but is safe to use when PrototypeJS v1.6 or lower is present.

Parameters

  • array [Array](default []) Array object upon which you would call the native reduce() method.
  • params ...Any Rest of parameters which you would provide to native reduce() method.

Returns Any

Bug reports, feature requests and contact

If you found any bugs, if you have feature requests or any questions, please, either file an issue at GitHub or send me an e-mail at [email protected].

License

Safe Array.reduce when usingPrototypeJS v1.6 and lower is published under the MIT license.

FAQs

What is array-reduce-prototypejs-fix?

Safe `Array.reduce()` when using PrototypeJS v1.6 and lower.

Is array-reduce-prototypejs-fix popular?

The npm package array-reduce-prototypejs-fix receives a total of 128 weekly downloads. As such, array-reduce-prototypejs-fix popularity was classified as not popular.

Is array-reduce-prototypejs-fix well maintained?

We found that array-reduce-prototypejs-fix demonstrated a not healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.

Last updated on 16 Feb 2017
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc