You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
Here's a simplified zero-dependency polyfill supporting all environments as far back as ES6, derived from the official polyfill at the time of writing.
constO=Objectconstfloor=Math.floorfunctionlast(value,fallback){if(value!=null){constl=+value.lengthif(l===l){if(l>9007199254740991)return9007199254740990if(l>=1)returnfloor(l)-1}}returnfallback}functioninstall(name,desc){if(Object.getOwnPropertyDescriptor(Array.prototype,name)==null){Object.defineProperty(Array.prototype,name,desc)}}install("lastItem",{enumerable: false,configurable: false,get(){constl=last(this,-1)if(l>=0)returnthis[l]},set(value){// The coercion is so it doesn't throw in strict mode and has the// correct observable behavior WRT indexed property setters.O(this)[last(this,0)]=value},})install("lastIndex",{enumerable: false,configurable: false,get(){returnlast(this,0)},})
This issue is purely informational, and no action here is needed. I just wanted to elaborate a bit upon the "There are polyfills which could use less code." part of this section of the README.
The text was updated successfully, but these errors were encountered:
@ljharb I fixed the comment to clarify I meant invoking setters without throwing, not getters. It matters in that 0[0] = 1 throws in strict mode, but Object(0)[0] = 1 doesn't, and the README spec polyfill uses explicit object coercions for all methods, so I had to include it.
Here's a simplified zero-dependency polyfill supporting all environments as far back as ES6, derived from the official polyfill at the time of writing.
This issue is purely informational, and no action here is needed. I just wanted to elaborate a bit upon the "There are polyfills which could use less code." part of this section of the README.
The text was updated successfully, but these errors were encountered: