How to use
You you can install via
npm install locutus and
require it via
You could also require the
array module in full
so that you could access
The mechanics and order of enumerating the properties is not specified.
So don't use this for anything serious if you rely on the order to be consistent accross platforms.
A community effort
Not unlike Wikipedia, Locutus is an ongoing community effort. Our philosophy follows The McDonald’s Theory. This means that we don't consider it to be a bad thing that many of our functions are first iterations, which may still have their fair share of issues. We hope that these flaws will inspire others to come up with better ideas.
This way of working also means that we don't offer any production guarantees, and recommend to use Locutus inspiration and learning purposes only.
This function deviates from PHP in returning a copy of the array instead of acting by reference and returning true; this was necessary because IE does not allow deleting and re-adding of properties without caching of property position; you can set the ini of “locutus.sortByReference” to true to get the PHP behavior, but use this only if you are in an environment such as Firefox extensions where for-in iteration order is fixed and true property deletion is supported. Note that we intend to implement the PHP behavior by default if IE ever does allow it; only gives shallow copy since is by reference in PHP anyways We cannot use numbers as keys and have them be reordered since they adhere to numerical order in some implementations
Please note that these examples are distilled from test cases that automatically verify our functions still work correctly. This could explain some quirky ones.