|
| 1 | +[](https://www.npmjs.com/package/symbol-es6) |
| 2 | +[](https://www.npmjs.com/package/symbol-es6) |
| 3 | +[](https://github.com/rousan/symbol-es6/graphs/contributors) |
| 4 | +[](https://github.com/rousan/symbol-es6/blob/master/LICENSE) |
| 5 | + |
1 | 6 | # Symbol-ES6
|
2 | 7 |
|
3 |
| -Provides support for Symbol API of ES6 in ES5 for older JS environments i.e. older browsers or NodeJS. |
4 |
| -To get full implementations of ES6 in ES5, install [es6-harmony](https://github.com/ariyankhan/es6-harmony) module. |
| 8 | +Provides support for `ES6` Symbol API in `ES5` for older JS environments i.e. older browsers or NodeJS. |
5 | 9 |
|
6 |
| -## Polyfills |
| 10 | +> ES6 Symbol polyfill in pure ES5. |
7 | 11 |
|
8 |
| -* `Symbol` |
9 |
| - * `for()` |
10 |
| - * `keyFor` |
11 |
| - * `@@hasInstance` |
12 |
| - * `@@isConcatSpreadable` |
13 |
| - * `@@iterator` |
14 |
| - * `@@toStringTag` |
15 |
| - * `Symbol.prototype.toString()` |
16 |
| - * `Symbol.prototype.valueOf()` |
17 |
| - |
18 |
| -* `Function` |
19 |
| - * `Function.prototype[@@hasInstance]()` |
20 |
| - |
21 |
| -* `Array` |
22 |
| - * `Array.prototype.concat()` (ES6 version, addition of `@@isConcatSpreadable` support) |
23 |
| - * `Array.prototype[@@iterator]()` |
24 |
| - * `Array.from()` |
25 |
| - * `Array.prototype.entries()` |
26 |
| - * `Array.prototype.keys()` |
| 12 | +## Install |
27 | 13 |
|
28 |
| -* `Object` |
29 |
| - * `Object.prototype.toString()` (ES6 version, addition of `@@toStringTag` support) |
| 14 | +### NPM |
30 | 15 |
|
31 |
| -* `String` |
32 |
| - * `String.prototype[@@iterator]()` |
33 |
| - |
34 |
| -## Limitation |
| 16 | +Install it from `npm` and `require` it before any other modules: |
35 | 17 |
|
36 |
| -Some ES6 features can't be implemented in ES5 natively like `spread operator`, `for..of` loop, |
37 |
| -ES6 version of `instanceOf` operator etc. So this module exports a object named `ES6` globally, |
38 |
| -that provides some approximate equivalent implementation of those features. |
| 18 | +```bash |
| 19 | +$ npm install --save symbol-es6 |
| 20 | +``` |
39 | 21 |
|
40 |
| -## `ES6` Object |
| 22 | +```javascript |
| 23 | +require("symbol-es6"); |
| 24 | +``` |
41 | 25 |
|
42 |
| -This object provides, |
| 26 | +### CDN |
43 | 27 |
|
44 |
| -* `isSymbol()` (It can be used as equivalent API of: `typeof symbol === 'symbol'`) |
45 |
| -* `instanceOf()` (Provides ES6 version of `instanceOf`) |
46 |
| -* `forOf()` (This method behaves exactly same as ES6 `for...of` loop) |
47 |
| -* `spreadOperator` (Gives same functionality of the `spread operator` of ES6) |
| 28 | +If you prefer CDN, then just insert it into your HTML page on the top of other scripts: |
| 29 | + |
| 30 | +```html |
| 31 | +<script src="https://cdn.jsdelivr.net/npm/symbol-es6/dist/symbol-es6.min.js"></script> |
| 32 | +``` |
48 | 33 |
|
49 |
| - |
50 | 34 | ## Examples
|
51 | 35 |
|
52 | 36 | ```javascript
|
53 | 37 | "use strict";
|
54 | 38 |
|
55 |
| -require("symbol-es6"); |
| 39 | +var ES6 = require("symbol-es6"); |
56 | 40 |
|
57 | 41 | console.log(Symbol("bar") === Symbol("bar")); //false
|
58 | 42 |
|
@@ -131,42 +115,66 @@ function Student(name, roll) {
|
131 | 115 | console.log(ES6.spreadOperator(Student).spread(["Ariyan", 10]).new().name); //Ariyan
|
132 | 116 | ```
|
133 | 117 |
|
134 |
| -## Installation |
| 118 | +## Polyfills |
135 | 119 |
|
136 |
| -* In browser context, just insert this script on the top of other scripts |
137 |
| -* For NodeJS, just install it from npm |
| 120 | +* `Symbol` |
| 121 | + * `for()` |
| 122 | + * `keyFor` |
| 123 | + * `@@hasInstance` |
| 124 | + * `@@isConcatSpreadable` |
| 125 | + * `@@iterator` |
| 126 | + * `@@toStringTag` |
| 127 | + * `Symbol.prototype.toString()` |
| 128 | + * `Symbol.prototype.valueOf()` |
| 129 | + |
| 130 | +* `Function` |
| 131 | + * `Function.prototype[@@hasInstance]()` |
| 132 | + |
| 133 | +* `Array` |
| 134 | + * `Array.prototype.concat()` (ES6 version, addition of `@@isConcatSpreadable` support) |
| 135 | + * `Array.prototype[@@iterator]()` |
| 136 | + * `Array.from()` |
| 137 | + * `Array.prototype.entries()` |
| 138 | + * `Array.prototype.keys()` |
138 | 139 |
|
139 |
| - `npm install symbol-es6` |
| 140 | +* `Object` |
| 141 | + * `Object.prototype.toString()` (ES6 version, addition of `@@toStringTag` support) |
140 | 142 |
|
141 |
| -## Testing |
| 143 | +* `String` |
| 144 | + * `String.prototype[@@iterator]()` |
142 | 145 |
|
143 |
| - `npm test` |
144 |
| - |
145 |
| -## Contributors |
146 | 146 |
|
147 |
| -* [Rousan Ali](https://github.com/ariyankhan) |
| 147 | +## Limitation |
| 148 | + |
| 149 | +Some `ES6` features can't be implemented in `ES5` natively like `spread operator`, `for..of` loop, |
| 150 | +`ES6` version of `instanceOf` operator etc. So this module exports a object named `ES6` globally, |
| 151 | +that provides some approximate equivalent implementation of those features. |
| 152 | + |
| 153 | +## `ES6` Object |
148 | 154 |
|
149 |
| -## License |
| 155 | +This object provides, |
150 | 156 |
|
151 |
| -MIT License |
| 157 | +* `isSymbol()` (It can be used as equivalent API of: `typeof symbol === 'symbol'`) |
| 158 | +* `instanceOf()` (Provides ES6 version of `instanceOf`) |
| 159 | +* `forOf()` (This method behaves exactly same as ES6 `for...of` loop) |
| 160 | +* `spreadOperator` (Gives same functionality of the `spread operator` of ES6) |
152 | 161 |
|
153 |
| -Copyright (c) 2017 Rousan Ali |
| 162 | +## Contributing |
154 | 163 |
|
155 |
| -Permission is hereby granted, free of charge, to any person obtaining a copy |
156 |
| -of this software and associated documentation files (the "Software"), to deal |
157 |
| -in the Software without restriction, including without limitation the rights |
158 |
| -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
159 |
| -copies of the Software, and to permit persons to whom the Software is |
160 |
| -furnished to do so, subject to the following conditions: |
| 164 | +Your PRs and stars are always welcome. |
161 | 165 |
|
162 |
| -The above copyright notice and this permission notice shall be included in all |
163 |
| -copies or substantial portions of the Software. |
| 166 | +Please, try to follow: |
164 | 167 |
|
165 |
| -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
166 |
| -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
167 |
| -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
168 |
| -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
169 |
| -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
170 |
| -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
171 |
| -SOFTWARE. |
| 168 | +* Clone the repository. |
| 169 | +* Checkout `develop` branch. |
| 170 | +* Install dependencies. |
| 171 | +* Add your new features or fixes. |
| 172 | +* Build the project. |
172 | 173 |
|
| 174 | +```sh |
| 175 | +$ git clone https://github.com/rousan/symbol-es6.git |
| 176 | +$ cd symbol-es6 |
| 177 | +$ git checkout develop |
| 178 | +$ npm i |
| 179 | +$ npm run build |
| 180 | +``` |
0 commit comments