Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit 2050590

Browse files
authored
Merge pull request #2 from ambit-tsai/dev
v2.0.0
2 parents 37cfb9e + e0f8c67 commit 2050590

File tree

15 files changed

+3023
-312
lines changed

15 files changed

+3023
-312
lines changed

README.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
English | <a href="README.zh-CN.md">中文</a>
1+
[简体中文](README.zh-CN.md) | English
22

3-
# ES6 Proxy Polyfill
4-
This is a polyfill for the `Proxy` constructor based on **ES3** supports **IE8** , Node.js, etc.
53

6-
Refer to <a href="https://tc39.github.io/ecma262/#sec-proxy-target-handler" target="_blank">ECMAScript</a>, and this has no external dependencies.
4+
# ES6 Proxy Polyfill&nbsp;&nbsp;![Version](https://img.shields.io/npm/v/es6-proxy-polyfill.svg)
75

8-
Due to the limitations of ES3, the polyfill supports just a limited number of proxy 'traps':
6+
This is a polyfill for ES6 `Proxy`, supports **IE6+** , Node.js, etc.
7+
8+
So far, it supports more features than the <a href="https://github.com/GoogleChrome/proxy-polyfill" target="_blank">proxy-polyfill</a> of GoogleChrome.
9+
10+
The polyfill supports just a limited number of proxy 'traps':
11+
* get
12+
* set
913
* apply
1014
* construct
1115

1216
The `Proxy.revocable` method is also supported, but only for calls to the above traps.
1317

14-
#### Installation
1518

19+
#### Installation
1620
1. Use NPM: `npm install -S es6-proxy-polyfill`
1721
2. Download directly: <a href="src/es6-proxy-polyfill.js" target="_blank">Development Version</a>, <a href="dist/es6-proxy-polyfill.js" target="_blank">Production Version</a>
1822

1923

2024
#### Usage
21-
2225
1. Browser:
23-
```
26+
```html
27+
<!--[if lte IE 8]>
28+
<script src="path/to/object-defineproperty-ie.js" type="text/javascript"></script>
29+
<![endif]-->
2430
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
2531
<script type="text/javascript">
26-
var target = function(){/* code */};
27-
var handler = {/* code */};
28-
var proxy = new Proxy(target, handler);
32+
var proxy = new Proxy({}, {});
2933
</script>
3034
```
3135
2. Node.js:
32-
```
33-
require('es6-proxy-polyfill');
36+
```javascript
37+
const Proxy = require('es6-proxy-polyfill');
3438

35-
var target = function(){/* code */};
36-
var handler = {/* code */};
37-
var proxy = new Proxy(target, handler);
39+
let proxy = new Proxy({}, {});
3840
```
3941

4042

4143
#### Notice
44+
1. For **non-array** object, the properties you want to proxy **must be known at creation time**;
45+
1. In IE8 or below, `Object.defineProperties` and `Object.getOwnPropertyDescriptor` are provided by library "<a href="https://github.com/ambit-tsai/object-defineproperty-ie" target="_blank">object-defineproperty-ie</a>";
46+
1. Support `UMD`.
4247

43-
1. In ES6, the access to `Proxy` object's properties will be passed to target. In order to simulate this feature, polyfill will try to copy properties from target by using `Object.assign` method, so it's better to load an `Object.assign` polyfill first;
44-
```
45-
<script src="path/to/babel-polyfill.js" type="text/javascript"></script>
46-
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
47-
```
48-
2. The code has been tested on Node.js 0.10.48 and IE8, and it may work in other environments too;
49-
3. The revoked `Proxy` object will not throw errors when it's properties are accessed.
48+
49+
#### Testing
50+
1. Access `test/browser/index.html` with browser
51+
1. Tested in IE6-8, IE11
52+
53+
54+
#### Contact Us
55+
1. WeChat: ambit_tsai
56+
1. QQ Group: 663286147
57+

README.zh-CN.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
<a href="README.md">English</a> | 中文
1+
简体中文 | [English](README.md)
22

3-
# ES6 Proxy Polyfill
4-
这是一个基于 **ES3**`Proxy`构造器polyfill,支持 **IE8** 和 Node.js 等。
53

6-
参照 <a href="https://tc39.github.io/ecma262/#sec-proxy-target-handler" target="_blank">ECMAScript</a> 标准编写,无外部依赖。
4+
# ES6 Proxy Polyfill&nbsp;&nbsp;![Version](https://img.shields.io/npm/v/es6-proxy-polyfill.svg)
75

8-
由于ES3的限制,该polyfill只支持有限的'traps'代理:
6+
一个 ES6 `Proxy` 的兼容库,支持 **IE6+** 和 Node.js 等。
7+
8+
迄今为止,它支持比 GoogleChrome <a href="https://github.com/GoogleChrome/proxy-polyfill" target="_blank">proxy-polyfill</a> 更多的特性。
9+
10+
该 polyfill 只支持有限的 'trap' 代理:
11+
* get
12+
* set
913
* apply
1014
* construct
1115

12-
`Proxy.revocable`方法也被支持,但只限于调用上面的'traps'
16+
`Proxy.revocable` 方法也被支持,但只限于调用上面的 'trap'
1317

14-
#### 安装
1518

19+
#### 安装
1620
1. 使用NPM:`npm install -S es6-proxy-polyfill`
1721
2. 直接下载:<a href="src/es6-proxy-polyfill.js" target="_blank">开发版本</a>,<a href="dist/es6-proxy-polyfill.js" target="_blank">生产版本</a>
1822

1923

2024
#### 用法
21-
2225
1. 浏览器:
23-
```
26+
```html
27+
<!--[if lte IE 8]>
28+
<script src="path/to/object-defineproperty-ie.js" type="text/javascript"></script>
29+
<![endif]-->
2430
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
2531
<script type="text/javascript">
26-
var target = function(){/* code */};
27-
var handler = {/* code */};
28-
var proxy = new Proxy(target, handler);
32+
var proxy = new Proxy({}, {});
2933
</script>
3034
```
3135
2. Node.js:
32-
```
33-
require('es6-proxy-polyfill');
36+
```javascript
37+
var Proxy = require('es6-proxy-polyfill');
3438

35-
var target = function(){/* code */};
36-
var handler = {/* code */};
37-
var proxy = new Proxy(target, handler);
39+
var proxy = new Proxy({}, {});
3840
```
3941

4042

4143
#### 注意
44+
1. 对于**非数组**对象,想要代理的属性**必须在创建时就已存在**
45+
1. 在 IE8 及以下,`Object.defineProperties``Object.getOwnPropertyDescriptor` 由 "<a href="https://github.com/ambit-tsai/object-defineproperty-ie" target="_blank">object-defineproperty-ie</a>" 库提供支持;
46+
1. 支持 `UMD`
4247

43-
1. 在ES6中,对`Proxy`对象属性的访问将会被传递给目标对象。为了模拟这个特性,polyfill会尝试使用`Object.assign`方法从目标对象复制属性,因此最好先加载一个`Object.assign`的polyfill;
44-
```
45-
<script src="path/to/babel-polyfill.js" type="text/javascript"></script>
46-
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
47-
```
48-
2. 代码已经在Node.js 0.10.48 和 IE8 测试过,而且它也应该能够运行在其他环境下;
49-
3. 当自身属性被访问时,被撤销的`Proxy`对象不会抛出错误。
48+
49+
#### 测试
50+
1. 使用浏览器访问 `test/browser/index.html`
51+
1. 已在 IE6-8、IE11 中进行测试
52+
53+
54+
#### 联系
55+
1. 微信: ambit_tsai
56+
1. QQ群: 663286147
57+

dist/es6-proxy-polyfill.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
{
22
"name": "es6-proxy-polyfill",
3-
"version": "1.2.1",
3+
"version": "2.0.0",
44
"description": "Proxy polyfill based on ES3 supports IE8, Node.js, etc.",
55
"main": "src/es6-proxy-polyfill.js",
66
"scripts": {
7-
"build": "uglifyjs src/es6-proxy-polyfill.js -c -m reserved=[Proxy] --ie8 --comments -o dist/es6-proxy-polyfill.js"
7+
"build": "uglifyjs src/es6-proxy-polyfill.js -c -m --ie8 --comments -o dist/es6-proxy-polyfill.js"
88
},
99
"keywords": [
1010
"proxy",
1111
"es6-proxy",
1212
"proxy-polyfill",
13-
"ie8",
14-
"Proxy",
15-
"ES6-Proxy",
16-
"IE8"
13+
"polyfill",
14+
"ie8"
1715
],
1816
"author": "[email protected]",
1917
"license": "Apache-2.0",
20-
"repository": {
18+
"repository": {
2119
"type": "git",
2220
"url": "git+https://github.com/ambit-tsai/es6-proxy-polyfill.git"
2321
},

0 commit comments

Comments
 (0)