Sha256: 92930b0cef8deceec72326d5c75e9d4916744a564a6c2a6d7bacd70501cd4f4b

Contents?: true

Size: 1.79 KB

Versions: 16

Compression:

Stored size: 1.79 KB

Contents

# es6-symbol
## ECMAScript6 Symbol polyfill

### Limitations

- Underneath it uses real string property names which can easily be retrieved (however accidental collision with other property names is unlikely)
- As it needs custom `toString` behavior to work properly. Original `Symbol.prototype.toString` couldn't be implemented as specified, still it's accessible as `Symbol.prototoype.properToString`

### Usage

If you want to make sure your environment implements `Symbol`, do:

```javascript
require('es6-symbol/implement');
```

If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Symbol` on global scope, do:

```javascript
var Symbol = require('es6-symbol');
```

If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do:

```javascript
var Symbol = require('es6-symbol/polyfill');
```

#### API

Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples:

```javascript
var Symbol = require('es6-symbol');

var symbol = Symbol('My custom symbol');
var x = {};

x[symbol] = 'foo';
console.log(x[symbol]); 'foo'

// Detect iterable:
var iterator, result;
if (possiblyIterable[Symbol.iterator]) {
  iterator = possiblyIterable[Symbol.iterator]();
  result = iterator.next();
  while(!result.done) {
    console.log(result.value);
    result = iterator.next();
  }
}
```

### Installation
#### NPM

In your project path:

	$ npm install es6-symbol

##### Browser

You can easily bundle _es6-symbol_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)

## Tests [![Build Status](https://travis-ci.org/medikoo/es6-symbol.png)](https://travis-ci.org/medikoo/es6-symbol)

	$ npm test

Version data entries

16 entries across 9 versions & 2 rubygems

Version Path
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/escope/node_modules/es6-map/node_modules/es6-symbol/README.md
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/escope/node_modules/es6-map/node_modules/es6-symbol/README.md
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/insight/node_modules/inquirer/node_modules/cli-color/node_modules/memoizee/node_modules/es6-weak-map/node_modules/es6-symbol/README.md