]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/README.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / README.md
1 # es6-symbol
2 ## ECMAScript 6 Symbol polyfill
3
4 For more information about symbols see following links
5 - [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html)
6 - [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)
7 - [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor)
8
9 ### Limitations
10
11 Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely.
12
13 ### Usage
14
15 It’s safest to use *es6-symbol* as a [ponyfill](http://kikobeats.com/polyfill-ponyfill-and-prollyfill/) – a polyfill which doesn’t touch global objects:
16
17 ```javascript
18 var Symbol = require('es6-symbol');
19 ```
20
21 If you want to make sure your environment implements `Symbol` globally, do:
22
23 ```javascript
24 require('es6-symbol/implement');
25 ```
26
27 If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do:
28
29 ```javascript
30 var Symbol = require('es6-symbol/polyfill');
31 ```
32
33 #### API
34
35 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:
36
37 ```javascript
38 var Symbol = require('es6-symbol');
39
40 var symbol = Symbol('My custom symbol');
41 var x = {};
42
43 x[symbol] = 'foo';
44 console.log(x[symbol]); 'foo'
45
46 // Detect iterable:
47 var iterator, result;
48 if (possiblyIterable[Symbol.iterator]) {
49   iterator = possiblyIterable[Symbol.iterator]();
50   result = iterator.next();
51   while(!result.done) {
52     console.log(result.value);
53     result = iterator.next();
54   }
55 }
56 ```
57
58 ### Installation
59 #### NPM
60
61 In your project path:
62
63         $ npm install es6-symbol
64
65 ##### Browser
66
67 To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
68
69 ## Tests [![Build Status](https://travis-ci.org/medikoo/es6-symbol.png)](https://travis-ci.org/medikoo/es6-symbol)
70
71         $ npm test