Spaces:
Paused
Paused
Download node_modules/@plotly/mapbox-gl/src/util/dictionary_coder.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 747 Bytes
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/dictionary_coder.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@plotly/mapbox-gl/src/util/dictionary_coder.js
-
curl -L -o dictionary_coder.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/dictionary_coder.js
747 Bytes
| // @flow strict | |
| import assert from 'assert'; | |
| class DictionaryCoder { | |
| _stringToNumber: {[_: string]: number }; | |
| _numberToString: Array<string>; | |
| constructor(strings: Array<string>) { | |
| this._stringToNumber = {}; | |
| this._numberToString = []; | |
| for (let i = 0; i < strings.length; i++) { | |
| const string = strings[i]; | |
| this._stringToNumber[string] = i; | |
| this._numberToString[i] = string; | |
| } | |
| } | |
| encode(string: string) { | |
| assert(string in this._stringToNumber); | |
| return this._stringToNumber[string]; | |
| } | |
| decode(n: number) { | |
| assert(n < this._numberToString.length); | |
| return this._numberToString[n]; | |
| } | |
| } | |
| export default DictionaryCoder; | |