es-shims/es5-shim hiện có 7.1k sao trên GitHub, viết chủ yếu bằng JavaScript. ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
es5-shim.js and es5-shim.min.js monkey-patch a JavaScript context to
contain all EcmaScript 5 methods that can be faithfully emulated with a
legacy JavaScript engine.
Note: As es5-shim.js is designed to patch the native Javascript
engine, it should be the library that is loaded first.
es5-sham.js and es5-sham.min.js monkey-patch other ES5 methods as
closely as possible. For these methods, as closely as possible to ES5
is not very close. Many of these shams are intended only to allow code
to be written to ES5 without causing run-time errors in older engines.
In many cases, this means that these shams cause many ES5 methods to
silently fail. Decide carefully whether this is what you want.
Note:es5-sham.js requires es5-shim.js to be able to work properly.
Tests
The tests are written with the Jasmine BDD test framework.
To run the tests, navigate to /tests/ , or,
simply npm install and npm test.
Shims
Complete tests
Array.prototype.every (standalone shim)
Array.prototype.filter (standalone shim)
Array.prototype.forEach (standalone shim)
Array.prototype.indexOf (standalone shim)
Array.prototype.lastIndexOf (standalone shim)
Array.prototype.map (standalone shim)
Array.prototype.slice
Array.prototype.some (standalone shim)
Array.prototype.sort
Array.prototype.reduce (standalone shim)
Array.prototype.reduceRight (standalone shim)
Array.prototype.push (standalone shim)
Array.prototype.join
Array.prototype.splice (standalone shim)
Array.isArray
Date.now (standalone shim)
Date.prototype.toJSON (standalone shim)
Function.prototype.bind
:warning: Caveat: the bound function has a prototype property.
:warning: Caveat: bound functions do not try too hard to keep you
from manipulating their arguments and caller properties.
:warning: Caveat: bound functions don't have checks in call and
apply to avoid executing as a constructor.
Number.prototype.toExponential (standalone shim)
Number.prototype.toFixed
Number.prototype.toPrecision
Object.keys (standalone shim)
String.prototype.split (standalone shim)
String.prototype.trim (standalone shim)
String.prototype.lastIndexOf (standalone shim)
String.prototype.replace
Firefox (through v29) natively handles capturing groups incorrectly.
Date.parse (for ISO parsing) (standalone shim)
Date.prototype.toISOString (standalone shim)
parseInt (standalone shim)
parseFloat
Error.prototype.toString
Error.prototype.name
Error.prototype.message
RegExp.prototype.toString
Shams
:warning: Object.create
For the case of simply "begetting" an object that inherits
prototypically from another, this should work fine across legacy
engines.
:warning: The second argument is passed to Object.defineProperties
which will probably fail either silently or with extreme prejudice.
:warning: Object.getPrototypeOf
This will return "undefined" in some cases. It uses __proto__ if
it's available. Failing that, it uses constructor.prototype, which
depends on the constructor property of the object's prototype having
not been replaced. If your object was created like this, it won't
work:
function Foo() {
}
Foo.prototype = {};
Because the prototype reassignment destroys the constructor
property.
This will work for all objects that were created using
Object.create implemented with this library.
:warning: Object.getOwnPropertyNames
This method uses Object.keys, so it will not be accurate on legacy
engines.
Object.isSealed
Returns "false" in all legacy engines for all objects, which is
conveniently guaranteed to be accurate.
Object.isFrozen
Returns "false" in all legacy engines for all objects, which is
conveniently guaranteed to be accurate.
Object.isExtensible
Works like a charm, by trying very hard to extend the object then
redacting the extension.
May fail
:warning: Object.getOwnPropertyDescriptor
The behavior of this shim does not conform to ES5. It should
probably not be used at this time, until its behavior has been
reviewed and been confirmed to be useful in legacy engines.
:warning: Object.defineProperty
In the worst of circumstances, IE 8 provides a version of this
method that only works on DOM objects. This sham will not be
installed. The given version of defineProperty will throw an
exception if used on non-DOM objects.
In slightly better circumstances, this method will silently fail to
set "writable", "enumerable", and "configurable" properties.
Providing a getter or setter with "get" or "set" on a descriptor
will silently fail on engines that lack "defineGetter" and
"defineSetter", which include all versions of IE.
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
Object.freeze
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
Object.preventExtensions
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
Example of applying ES compatibility shims in a browser project
es-shims/es5-shim thuộc nhóm Frontend trên TopGit, cùng 5 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về es-shims/es5-shim ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/es-shims/es5-shim là nguồn chính thức.
es-shims/es5-shim có bao nhiêu sao?
es-shims/es5-shim có 7.1k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/es-shims/es5-shim. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
es-shims/es5-shim có những chủ đề gì?
GitHub topics của es-shims/es5-shim: "ecmascript", "es5", "javascript", "polyfill", "shim". TopGit xếp repo vào nhóm Frontend.
es-shims/es5-shim có phải mã nguồn mở không?
Có — es-shims/es5-shim phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/es-shims/es5-shim.
es-shims/es5-shim có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho es-shims/es5-shim. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
es-shims/es5-shim còn đang phát triển không?
Commit gần nhất trên es-shims/es5-shim là 10 tháng trước (theo timestamp GitHub). Repo có 877 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc es5-shim có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về es5-shim.