Skip to content

Commit

Permalink
Merge branch 'release/v0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rousan committed Jan 28, 2018
2 parents 8b96b64 + 582aabd commit 0d33ba8
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 116 deletions.
Binary file added .DS_Store
Binary file not shown.
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

package-lock.json
6 changes: 0 additions & 6 deletions .idea/jsLibraryMappings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/symbol-es6.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Ariyan Khan
Copyright (c) 2017 Rousan Ali

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
140 changes: 74 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
[![NPM version](https://img.shields.io/npm/v/symbol-es6.svg)](https://www.npmjs.com/package/symbol-es6)
[![NPM total downloads](https://img.shields.io/npm/dt/symbol-es6.svg)](https://www.npmjs.com/package/symbol-es6)
[![Contributors](https://img.shields.io/github/contributors/rousan/symbol-es6.svg)](https://github.com/rousan/symbol-es6/graphs/contributors)
[![License](https://img.shields.io/github/license/rousan/symbol-es6.svg)](https://github.com/rousan/symbol-es6/blob/master/LICENSE)

# Symbol-ES6

Provides support for Symbol API of ES6 in ES5 for older JS environments i.e. older browsers or NodeJS.
To get full implementations of ES6 in ES5, install [es6-harmony](https://github.com/ariyankhan/es6-harmony) module.
Provides support for `ES6` Symbol API in `ES5` for older JS environments i.e. older browsers or NodeJS.

## Polyfills
> ES6 Symbol polyfill in pure ES5.
* `Symbol`
* `for()`
* `keyFor`
* `@@hasInstance`
* `@@isConcatSpreadable`
* `@@iterator`
* `@@toStringTag`
* `Symbol.prototype.toString()`
* `Symbol.prototype.valueOf()`

* `Function`
* `Function.prototype[@@hasInstance]()`

* `Array`
* `Array.prototype.concat()` (ES6 version, addition of `@@isConcatSpreadable` support)
* `Array.prototype[@@iterator]()`
* `Array.from()`
* `Array.prototype.entries()`
* `Array.prototype.keys()`
## Install

* `Object`
* `Object.prototype.toString()` (ES6 version, addition of `@@toStringTag` support)
### NPM

* `String`
* `String.prototype[@@iterator]()`

## Limitation
Install it from `npm` and `require` it before any other modules:

Some ES6 features can't be implemented in ES5 natively like `spread operator`, `for..of` loop,
ES6 version of `instanceOf` operator etc. So this module exports a object named `ES6` globally,
that provides some approximate equivalent implementation of those features.
```bash
$ npm install --save symbol-es6
```

## `ES6` Object
```javascript
require("symbol-es6");
```

This object provides,
### CDN

* `isSymbol()` (It can be used as equivalent API of: `typeof symbol === 'symbol'`)
* `instanceOf()` (Provides ES6 version of `instanceOf`)
* `forOf()` (This method behaves exactly same as ES6 `for...of` loop)
* `spreadOperator` (Gives same functionality of the `spread operator` of ES6)
If you prefer CDN, then just insert it into your HTML page on the top of other scripts:

```html
<script src="https://cdn.jsdelivr.net/npm/symbol-es6/dist/symbol-es6.min.js"></script>
```


## Examples

```javascript
"use strict";

require("symbol-es6");
var ES6 = require("symbol-es6");

console.log(Symbol("bar") === Symbol("bar")); //false

Expand Down Expand Up @@ -131,42 +115,66 @@ function Student(name, roll) {
console.log(ES6.spreadOperator(Student).spread(["Ariyan", 10]).new().name); //Ariyan
```

## Installation
## Polyfills

* In browser context, just insert this script on the top of other scripts
* For NodeJS, just install it from npm
* `Symbol`
* `for()`
* `keyFor`
* `@@hasInstance`
* `@@isConcatSpreadable`
* `@@iterator`
* `@@toStringTag`
* `Symbol.prototype.toString()`
* `Symbol.prototype.valueOf()`

* `Function`
* `Function.prototype[@@hasInstance]()`

* `Array`
* `Array.prototype.concat()` (ES6 version, addition of `@@isConcatSpreadable` support)
* `Array.prototype[@@iterator]()`
* `Array.from()`
* `Array.prototype.entries()`
* `Array.prototype.keys()`

`npm install symbol-es6`
* `Object`
* `Object.prototype.toString()` (ES6 version, addition of `@@toStringTag` support)

## Testing
* `String`
* `String.prototype[@@iterator]()`

`npm test`

## Contributors

* [Rousan Ali](https://github.com/ariyankhan)
## Limitation

Some `ES6` features can't be implemented in `ES5` natively like `spread operator`, `for..of` loop,
`ES6` version of `instanceOf` operator etc. So this module exports a object named `ES6` globally,
that provides some approximate equivalent implementation of those features.

## `ES6` Object

## License
This object provides,

MIT License
* `isSymbol()` (It can be used as equivalent API of: `typeof symbol === 'symbol'`)
* `instanceOf()` (Provides ES6 version of `instanceOf`)
* `forOf()` (This method behaves exactly same as ES6 `for...of` loop)
* `spreadOperator` (Gives same functionality of the `spread operator` of ES6)

Copyright (c) 2017 Rousan Ali
## Contributing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Your PRs and stars are always welcome.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Please, try to follow:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* Clone the repository.
* Checkout `develop` branch.
* Install dependencies.
* Add your new features or fixes.
* Build the project.

```sh
$ git clone https://github.com/rousan/symbol-es6.git
$ cd symbol-es6
$ git checkout develop
$ npm i
$ npm run build
```
2 changes: 1 addition & 1 deletion dist/symbol-es6.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/symbol-es6.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"name": "symbol-es6",
"version": "0.1.1",
"description": "Provides Symbol implementation of ES6 in pure ES5 for older browsers and JS engines",
"version": "0.1.2",
"description": "ES6 Symbol polyfill in pure ES5",
"main": "symbol-es6.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "uglifyjs --source-map --compress --output dist/symbol-es6.min.js -- symbol-es6.js",
"test": "node ./test/test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ariyankhan/symbol-es6.git"
"url": "git+https://github.com/rousan/symbol-es6.git"
},
"keywords": [
"es",
Expand All @@ -27,10 +25,13 @@
"js-symbol",
"es-symbol"
],
"author": "Ariyan Khan",
"author": "Rousan Ali <rousanali786@gmail.com> (https://rousan.io)",
"license": "MIT",
"bugs": {
"url": "https://github.com/ariyankhan/symbol-es6/issues"
"url": "https://github.com/rousan/symbol-es6/issues"
},
"homepage": "https://github.com/ariyankhan/symbol-es6#readme"
"homepage": "https://github.com/rousan/symbol-es6#readme",
"devDependencies": {
"uglify-js": "^3.3.9"
}
}
11 changes: 5 additions & 6 deletions symbol-es6.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*!
* Symbol-ES6 v0.1.1
* Provides Symbol implementation of ES6 in pure ES5 for older browsers
* and JS engines.
* Symbol-ES6 v0.1.2
* ES6 Symbol polyfill in pure ES5.
*
* @license Copyright (c) 2017 Ariyan Khan, MIT License
* @license Copyright (c) 2017-2018 Rousan Ali, MIT License
*
* Codebase: https://github.com/ariyankhan/symbol-es6
* Date: Jun 14, 2017
* Codebase: https://github.com/rousan/symbol-es6
* Date: 28th Jan, 2018
*/

(function (global, factory) {
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

require("../symbol-es6");
var ES6 = require("../symbol-es6");

console.log(Symbol("bar") === Symbol("bar")); //false

Expand Down

0 comments on commit 0d33ba8

Please sign in to comment.