├── .flowconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── Makefile ├── README.md ├── babel.config.js ├── jest.config.js ├── lerna.json ├── package.json ├── packages ├── babel-plugin-transform-charcodes │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.js │ ├── test │ │ └── transformation.test.js │ └── yarn.lock └── charcodes │ ├── README.md │ ├── package.json │ └── src │ └── index.js ├── scripts └── build.sh └── yarn.lock /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/build/.* 3 | .*/packages/.*/lib 4 | .*/packages/.*/test 5 | 6 | [include] 7 | packages/*/src 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | /packages/*/lib 61 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | node_modules 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "8" 5 | - "lts/*" 6 | install: make bootstrap 7 | test: make test 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export PATH := $(PATH):./node_modules/.bin/ 2 | 3 | bootstrap: 4 | make clean-all 5 | yarn --ignore-engines 6 | ./node_modules/.bin/lerna bootstrap 7 | make build 8 | 9 | doc-charcodes: 10 | dump-exports ./packages/charcodes/src/index.js > ./packages/charcodes/README.md 11 | 12 | flow-charcodes: 13 | cp ./packages/charcodes/src/index.js ./packages/charcodes/lib/index.js.flow 14 | cp ./packages/charcodes/src/index.js ./packages/charcodes/lib/index.mjs.flow 15 | 16 | build: 17 | ./scripts/build.sh 18 | make flow-charcodes 19 | 20 | publish: build 21 | ./node_modules/.bin/lerna publish --force-publish=* 22 | 23 | test: 24 | ./node_modules/.bin/jest 25 | 26 | clean-all: 27 | rm -rf node_modules 28 | rm -rf package-lock.json 29 | rm -rf packages/*/node_modules 30 | rm -rf packages/*/lib 31 | rm -rf packages/*/package-lock.json 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # charcodes 2 | > Char codes constants 3 | 4 | See https://github.com/babel/babel/pull/6727 5 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = function(api) { 4 | const env = api.env(); 5 | 6 | let modules = "commonjs"; 7 | if (env === "esm") { 8 | modules = false; 9 | } 10 | 11 | const config = { 12 | comments: false, 13 | presets: ["@babel/flow", ["@babel/env", { modules }]], 14 | }; 15 | 16 | return config; 17 | }; 18 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // For a detailed explanation regarding each configuration property, visit: 2 | // https://jestjs.io/docs/en/configuration.html 3 | 4 | module.exports = { 5 | // All imported modules in your tests should be mocked automatically 6 | // automock: false, 7 | 8 | // Stop running tests after the first failure 9 | // bail: false, 10 | 11 | // Respect "browser" field in package.json when resolving modules 12 | // browser: false, 13 | 14 | // The directory where Jest should store its cached dependency information 15 | // cacheDirectory: "/var/folders/jc/4dcm6vb95ps5fsv31bztxm3h0000gn/T/jest_dx", 16 | 17 | // Automatically clear mock calls and instances between every test 18 | // clearMocks: false, 19 | 20 | // Indicates whether the coverage information should be collected while executing the test 21 | // collectCoverage: false, 22 | 23 | // An array of glob patterns indicating a set of files for which coverage information should be collected 24 | // collectCoverageFrom: null, 25 | 26 | // The directory where Jest should output its coverage files 27 | // coverageDirectory: null, 28 | 29 | // An array of regexp pattern strings used to skip coverage collection 30 | // coveragePathIgnorePatterns: [ 31 | // "/node_modules/" 32 | // ], 33 | 34 | // A list of reporter names that Jest uses when writing coverage reports 35 | // coverageReporters: [ 36 | // "json", 37 | // "text", 38 | // "lcov", 39 | // "clover" 40 | // ], 41 | 42 | // An object that configures minimum threshold enforcement for coverage results 43 | // coverageThreshold: null, 44 | 45 | // Make calling deprecated APIs throw helpful error messages 46 | // errorOnDeprecated: false, 47 | 48 | // Force coverage collection from ignored files usin a array of glob patterns 49 | // forceCoverageMatch: [], 50 | 51 | // A path to a module which exports an async function that is triggered once before all test suites 52 | // globalSetup: null, 53 | 54 | // A path to a module which exports an async function that is triggered once after all test suites 55 | // globalTeardown: null, 56 | 57 | // A set of global variables that need to be available in all test environments 58 | // globals: {}, 59 | 60 | // An array of directory names to be searched recursively up from the requiring module's location 61 | // moduleDirectories: [ 62 | // "node_modules" 63 | // ], 64 | 65 | // An array of file extensions your modules use 66 | // moduleFileExtensions: [ 67 | // "js", 68 | // "json", 69 | // "jsx", 70 | // "node" 71 | // ], 72 | 73 | // A map from regular expressions to module names that allow to stub out resources with a single module 74 | // moduleNameMapper: {}, 75 | 76 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 77 | // modulePathIgnorePatterns: [], 78 | 79 | // Activates notifications for test results 80 | // notify: false, 81 | 82 | // An enum that specifies notification mode. Requires { notify: true } 83 | // notifyMode: "always", 84 | 85 | // A preset that is used as a base for Jest's configuration 86 | // preset: null, 87 | 88 | // Run tests from one or more projects 89 | // projects: null, 90 | 91 | // Use this configuration option to add custom reporters to Jest 92 | // reporters: undefined, 93 | 94 | // Automatically reset mock state between every test 95 | // resetMocks: false, 96 | 97 | // Reset the module registry before running each individual test 98 | // resetModules: false, 99 | 100 | // A path to a custom resolver 101 | // resolver: null, 102 | 103 | // Automatically restore mock state between every test 104 | // restoreMocks: false, 105 | 106 | // The root directory that Jest should scan for tests and modules within 107 | // rootDir: null, 108 | 109 | // A list of paths to directories that Jest should use to search for files in 110 | // roots: [ 111 | // "" 112 | // ], 113 | 114 | // Allows you to use a custom runner instead of Jest's default test runner 115 | // runner: "jest-runner", 116 | 117 | // The paths to modules that run some code to configure or set up the testing environment before each test 118 | // setupFiles: [], 119 | 120 | // The path to a module that runs some code to configure or set up the testing framework before each test 121 | // setupTestFrameworkScriptFile: null, 122 | 123 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 124 | // snapshotSerializers: [], 125 | 126 | // The test environment that will be used for testing 127 | testEnvironment: "node", 128 | 129 | // Options that will be passed to the testEnvironment 130 | // testEnvironmentOptions: {}, 131 | 132 | // Adds a location field to test results 133 | // testLocationInResults: false, 134 | 135 | // The glob patterns Jest uses to detect test files 136 | // testMatch: [ 137 | // "**/__tests__/**/*.js?(x)", 138 | // "**/?(*.)+(spec|test).js?(x)" 139 | // ], 140 | 141 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 142 | // testPathIgnorePatterns: [ 143 | // "/node_modules/" 144 | // ], 145 | 146 | // The regexp pattern Jest uses to detect test files 147 | // testRegex: "", 148 | 149 | // This option allows the use of a custom results processor 150 | // testResultsProcessor: null, 151 | 152 | // This option allows use of a custom test runner 153 | // testRunner: "jasmine2", 154 | 155 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href 156 | // testURL: "http://localhost", 157 | 158 | // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" 159 | // timers: "real", 160 | 161 | // A map from regular expressions to paths to transformers 162 | // transform: null, 163 | 164 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 165 | // transformIgnorePatterns: [ 166 | // "/node_modules/" 167 | // ], 168 | 169 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 170 | // unmockedModulePathPatterns: undefined, 171 | 172 | // Indicates whether each individual test should be reported during the run 173 | // verbose: null, 174 | 175 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 176 | // watchPathIgnorePatterns: [], 177 | 178 | // Whether to use watchman for file crawling 179 | // watchman: true, 180 | }; 181 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.5.1", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "version": "0.2.0", 7 | "npmClient": "yarn", 8 | "npmClientArgs": [ 9 | "--ignore-engines" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "test": "make test" 4 | }, 5 | "devDependencies": { 6 | "@babel/cli": "^7.0.0", 7 | "@babel/core": "^7.0.0", 8 | "@babel/preset-env": "^7.0.0", 9 | "@babel/preset-flow": "^7.0.0", 10 | "babel-core": "^7.0.0-bridge.0", 11 | "babel-jest": "^23.6.0", 12 | "dump-exports": "0.1.0", 13 | "flow-bin": "^0.91.0", 14 | "jest": "^23.6.0", 15 | "lerna": "^2.5.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/babel-plugin-transform-charcodes/README.md: -------------------------------------------------------------------------------- 1 | # babel-plugin-transform-charcodes 2 | 3 | > Replace charcodes AOT 4 | 5 | ## Examples 6 | 7 | ### Constants 8 | 9 | in: 10 | ```js 11 | import * as charcodes from "charcodes" 12 | 13 | charcodes.space 14 | ``` 15 | 16 | out: 17 | ```js 18 | 32 19 | ``` 20 | 21 | ### Functions 22 | 23 | in: 24 | ```js 25 | import * as charcodes from "charcodes" 26 | 27 | (charcodes.isDigit(1)) 28 | ``` 29 | 30 | out: 31 | ```js 32 | (function isDigit(code) { 33 | return code >= 48 && code <= 57; 34 | }(1)) 35 | ``` 36 | 37 | ## Installation 38 | 39 | ```sh 40 | npm install --save-dev babel-plugin-transform-charcodes 41 | ``` 42 | 43 | ## Usage 44 | 45 | ### Via `.babelrc` (Recommended) 46 | 47 | **.babelrc** 48 | 49 | ```json 50 | { 51 | "plugins": ["transform-charcodes"] 52 | } 53 | ``` 54 | 55 | ### Via CLI 56 | 57 | ```sh 58 | babel --plugins transform-charcodes script.js 59 | ``` 60 | 61 | ### Via Node API 62 | 63 | ```javascript 64 | require("@babel/core").transform("code", { 65 | plugins: ["transform-charcodes"] 66 | }); 67 | ``` 68 | -------------------------------------------------------------------------------- /packages/babel-plugin-transform-charcodes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-plugin-transform-charcodes", 3 | "version": "0.2.0", 4 | "description": "Replace charcodes AOT", 5 | "main": "lib/index.js", 6 | "module": "lib/index.mjs", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/xtuc/charcodes.git" 10 | }, 11 | "engines": { 12 | "node": ">=6" 13 | }, 14 | "keywords": [ 15 | "charcodes", 16 | "ascii", 17 | "constants", 18 | "babel-plugin" 19 | ], 20 | "author": "Sven Sauleau", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/xtuc/charcodes/issues" 24 | }, 25 | "homepage": "https://github.com/xtuc/charcodes#readme", 26 | "devDependencies": { 27 | "@babel/types": "^7.0.0", 28 | "charcodes": "^0.2.0" 29 | }, 30 | "dependencies": { 31 | "@babel/parser": "^7.0.0", 32 | "@babel/traverse": "^7.0.0" 33 | }, 34 | "peerDependencies": { 35 | "charcodes": "^0.2.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/babel-plugin-transform-charcodes/src/index.js: -------------------------------------------------------------------------------- 1 | import * as charcodes from "charcodes"; 2 | import { parse } from "@babel/parser"; 3 | import traverse from '@babel/traverse'; 4 | 5 | type ast = Object 6 | 7 | export default function (babel) { 8 | const { types: t } = babel; 9 | 10 | function parseFunctionSource(str: string): ast { 11 | const root = parse(str, { 12 | sourceType: 'script', 13 | }) 14 | 15 | return root.program.body[0]; 16 | } 17 | 18 | function createInlineFunction(func: ast, id: ast): ast { 19 | 20 | traverse(func, { 21 | noScope: true, 22 | 23 | Identifier(path) { 24 | const name = path.node.name 25 | 26 | if (typeof charcodes[name] !== "undefined" && typeof charcodes[name] !== "function") { 27 | path.replaceWith(t.NumericLiteral(charcodes[name])) 28 | } 29 | } 30 | }) 31 | 32 | return t.variableDeclaration( 33 | 'var', 34 | [t.variableDeclarator( 35 | id, 36 | t.toExpression(func), 37 | )] 38 | ) 39 | } 40 | 41 | return { 42 | 43 | visitor: { 44 | 45 | ImportDeclaration(path, state) { 46 | 47 | if (path.node.source.value === "charcodes") { 48 | state.importedLocalName = path.node.specifiers[0].local.name 49 | 50 | // We remove the import just in case 51 | path.remove() 52 | } 53 | }, 54 | 55 | MemberExpression(path, state) { 56 | if (typeof state.importedLocalName !== "undefined" && path.node.object.name == state.importedLocalName) { 57 | const rightName = path.node.property.name 58 | const charCodeValue = charcodes[rightName] 59 | 60 | if (typeof charCodeValue === "undefined") { 61 | throw new Error("unknown key " + rightName) 62 | } else if (typeof charCodeValue !== "function") { 63 | path.replaceWith(t.NumericLiteral(charCodeValue)) 64 | } else { 65 | const fn = parseFunctionSource(charCodeValue.toString()) 66 | const id = path.scope.generateUidIdentifier(rightName) 67 | 68 | state._toHoist.push(createInlineFunction(fn, id)) 69 | 70 | path.replaceWith(id) 71 | } 72 | } 73 | }, 74 | 75 | Program: { 76 | enter(path, state) { 77 | state._toHoist = []; 78 | }, 79 | 80 | exit(path, state) { 81 | state._toHoist.forEach(x => { 82 | path.node.body.unshift(x) 83 | }) 84 | } 85 | } 86 | } 87 | 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /packages/babel-plugin-transform-charcodes/test/transformation.test.js: -------------------------------------------------------------------------------- 1 | import { parse } from '@babel/parser'; 2 | import * as types from '@babel/types'; 3 | import generate from '@babel/generator'; 4 | import traverse from '@babel/traverse'; 5 | 6 | import visitor from '../src'; 7 | 8 | function transform(code) { 9 | const ast = parse(code, { 10 | sourceType: 'module', 11 | }); 12 | 13 | traverse(ast, visitor({ types }).visitor, null, {}); 14 | 15 | return generate(ast).code; 16 | } 17 | 18 | function assertOutput(code, expected) { 19 | const out = transform(code); 20 | 21 | expect(out).toEqual(expected); 22 | } 23 | 24 | describe('function', () => { 25 | 26 | it('should hoist a function and call it', () => { 27 | 28 | const out = transform(` 29 | import * as charcodes from "charcodes" 30 | 31 | (charcodes.isDigit(1)) 32 | `) 33 | 34 | const expected = ` 35 | var _isDigit = function isDigit(code) { 36 | return code >= 48 && code <= 57; 37 | }; 38 | _isDigit(1); 39 | ` 40 | 41 | assertOutput(expected, out) 42 | }) 43 | 44 | }) 45 | 46 | describe('constant', () => { 47 | 48 | it('should inline a constant', () => { 49 | 50 | const out = transform(` 51 | import * as charcodes from "charcodes" 52 | 53 | charcodes.space 54 | `) 55 | 56 | const expected = ` 57 | 32 58 | ` 59 | 60 | assertOutput(expected, out) 61 | }) 62 | 63 | it('should throw if the key is unknown', () => { 64 | 65 | const fn = () => transform(` 66 | import * as charcodes from "charcodes" 67 | 68 | charcodes.somethinglikefoobar 69 | `) 70 | 71 | expect(fn).toThrow(/unknown key/); 72 | }) 73 | 74 | }) 75 | -------------------------------------------------------------------------------- /packages/babel-plugin-transform-charcodes/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@babel/code-frame@^7.0.0": 6 | version "7.0.0" 7 | resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" 8 | integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== 9 | dependencies: 10 | "@babel/highlight" "^7.0.0" 11 | 12 | "@babel/generator@^7.2.2": 13 | version "7.3.0" 14 | resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.0.tgz#f663838cd7b542366de3aa608a657b8ccb2a99eb" 15 | integrity sha512-dZTwMvTgWfhmibq4V9X+LMf6Bgl7zAodRn9PvcPdhlzFMbvUutx74dbEv7Atz3ToeEpevYEJtAwfxq/bDCzHWg== 16 | dependencies: 17 | "@babel/types" "^7.3.0" 18 | jsesc "^2.5.1" 19 | lodash "^4.17.10" 20 | source-map "^0.5.0" 21 | trim-right "^1.0.1" 22 | 23 | "@babel/helper-function-name@^7.1.0": 24 | version "7.1.0" 25 | resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" 26 | integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== 27 | dependencies: 28 | "@babel/helper-get-function-arity" "^7.0.0" 29 | "@babel/template" "^7.1.0" 30 | "@babel/types" "^7.0.0" 31 | 32 | "@babel/helper-get-function-arity@^7.0.0": 33 | version "7.0.0" 34 | resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" 35 | integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== 36 | dependencies: 37 | "@babel/types" "^7.0.0" 38 | 39 | "@babel/helper-split-export-declaration@^7.0.0": 40 | version "7.0.0" 41 | resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813" 42 | integrity sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag== 43 | dependencies: 44 | "@babel/types" "^7.0.0" 45 | 46 | "@babel/highlight@^7.0.0": 47 | version "7.0.0" 48 | resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" 49 | integrity sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw== 50 | dependencies: 51 | chalk "^2.0.0" 52 | esutils "^2.0.2" 53 | js-tokens "^4.0.0" 54 | 55 | "@babel/parser@^7.0.0", "@babel/parser@^7.2.2", "@babel/parser@^7.2.3": 56 | version "7.3.0" 57 | resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.0.tgz#930251fe6714df47ce540a919ccdf6dcfb652b61" 58 | integrity sha512-8M30TzMpLHGmuthHZStm4F+az5wxyYeh8U+LWK7+b2qnlQ0anXBmOQ1I8DCMV1K981wPY3C3kWZ4SA1lR3Y3xQ== 59 | 60 | "@babel/template@^7.1.0": 61 | version "7.2.2" 62 | resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907" 63 | integrity sha512-zRL0IMM02AUDwghf5LMSSDEz7sBCO2YnNmpg3uWTZj/v1rcG2BmQUvaGU8GhU8BvfMh1k2KIAYZ7Ji9KXPUg7g== 64 | dependencies: 65 | "@babel/code-frame" "^7.0.0" 66 | "@babel/parser" "^7.2.2" 67 | "@babel/types" "^7.2.2" 68 | 69 | "@babel/traverse@^7.0.0": 70 | version "7.2.3" 71 | resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.2.3.tgz#7ff50cefa9c7c0bd2d81231fdac122f3957748d8" 72 | integrity sha512-Z31oUD/fJvEWVR0lNZtfgvVt512ForCTNKYcJBGbPb1QZfve4WGH8Wsy7+Mev33/45fhP/hwQtvgusNdcCMgSw== 73 | dependencies: 74 | "@babel/code-frame" "^7.0.0" 75 | "@babel/generator" "^7.2.2" 76 | "@babel/helper-function-name" "^7.1.0" 77 | "@babel/helper-split-export-declaration" "^7.0.0" 78 | "@babel/parser" "^7.2.3" 79 | "@babel/types" "^7.2.2" 80 | debug "^4.1.0" 81 | globals "^11.1.0" 82 | lodash "^4.17.10" 83 | 84 | "@babel/types@^7.0.0", "@babel/types@^7.2.2", "@babel/types@^7.3.0": 85 | version "7.3.0" 86 | resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.0.tgz#61dc0b336a93badc02bf5f69c4cd8e1353f2ffc0" 87 | integrity sha512-QkFPw68QqWU1/RVPyBe8SO7lXbPfjtqAxRYQKpFpaB8yMq7X2qAqfwK5LKoQufEkSmO5NQ70O6Kc3Afk03RwXw== 88 | dependencies: 89 | esutils "^2.0.2" 90 | lodash "^4.17.10" 91 | to-fast-properties "^2.0.0" 92 | 93 | ansi-styles@^3.2.1: 94 | version "3.2.1" 95 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" 96 | integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== 97 | dependencies: 98 | color-convert "^1.9.0" 99 | 100 | chalk@^2.0.0: 101 | version "2.4.2" 102 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" 103 | integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== 104 | dependencies: 105 | ansi-styles "^3.2.1" 106 | escape-string-regexp "^1.0.5" 107 | supports-color "^5.3.0" 108 | 109 | color-convert@^1.9.0: 110 | version "1.9.3" 111 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" 112 | integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== 113 | dependencies: 114 | color-name "1.1.3" 115 | 116 | color-name@1.1.3: 117 | version "1.1.3" 118 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" 119 | integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= 120 | 121 | debug@^4.1.0: 122 | version "4.1.1" 123 | resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" 124 | integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== 125 | dependencies: 126 | ms "^2.1.1" 127 | 128 | escape-string-regexp@^1.0.5: 129 | version "1.0.5" 130 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 131 | integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= 132 | 133 | esutils@^2.0.2: 134 | version "2.0.2" 135 | resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" 136 | integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= 137 | 138 | globals@^11.1.0: 139 | version "11.10.0" 140 | resolved "https://registry.yarnpkg.com/globals/-/globals-11.10.0.tgz#1e09776dffda5e01816b3bb4077c8b59c24eaa50" 141 | integrity sha512-0GZF1RiPKU97IHUO5TORo9w1PwrH/NBPl+fS7oMLdaTRiYmYbwK4NWoZWrAdd0/abG9R2BU+OiwyQpTpE6pdfQ== 142 | 143 | has-flag@^3.0.0: 144 | version "3.0.0" 145 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 146 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= 147 | 148 | js-tokens@^4.0.0: 149 | version "4.0.0" 150 | resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" 151 | integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== 152 | 153 | jsesc@^2.5.1: 154 | version "2.5.2" 155 | resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" 156 | integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== 157 | 158 | lodash@^4.17.10: 159 | version "4.17.11" 160 | resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" 161 | integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== 162 | 163 | ms@^2.1.1: 164 | version "2.1.1" 165 | resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" 166 | integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== 167 | 168 | source-map@^0.5.0: 169 | version "0.5.7" 170 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" 171 | integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= 172 | 173 | supports-color@^5.3.0: 174 | version "5.5.0" 175 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 176 | integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== 177 | dependencies: 178 | has-flag "^3.0.0" 179 | 180 | to-fast-properties@^2.0.0: 181 | version "2.0.0" 182 | resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" 183 | integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= 184 | 185 | trim-right@^1.0.1: 186 | version "1.0.1" 187 | resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" 188 | integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= 189 | -------------------------------------------------------------------------------- /packages/charcodes/README.md: -------------------------------------------------------------------------------- 1 | ## Exports 2 | 3 | - Constant number `backSpace` 4 | - Constant number `tab` 5 | - Constant number `lineFeed` 6 | - Constant number `carriageReturn` 7 | - Constant number `shiftOut` 8 | - Constant number `space` 9 | - Constant number `exclamationMark` 10 | - Constant number `quotationMark` 11 | - Constant number `numberSign` 12 | - Constant number `dollarSign` 13 | - Constant number `percentSign` 14 | - Constant number `ampersand` 15 | - Constant number `apostrophe` 16 | - Constant number `leftParenthesis` 17 | - Constant number `rightParenthesis` 18 | - Constant number `asterisk` 19 | - Constant number `plusSign` 20 | - Constant number `comma` 21 | - Constant number `dash` 22 | - Constant number `dot` 23 | - Constant number `slash` 24 | - Constant number `digit0` 25 | - Constant number `digit1` 26 | - Constant number `digit2` 27 | - Constant number `digit3` 28 | - Constant number `digit4` 29 | - Constant number `digit5` 30 | - Constant number `digit6` 31 | - Constant number `digit7` 32 | - Constant number `digit8` 33 | - Constant number `digit9` 34 | - Constant number `colon` 35 | - Constant number `semicolon` 36 | - Constant number `lessThan` 37 | - Constant number `equalsTo` 38 | - Constant number `greaterThan` 39 | - Constant number `questionMark` 40 | - Constant number `atSign` 41 | - Constant number `uppercaseA` 42 | - Constant number `uppercaseB` 43 | - Constant number `uppercaseC` 44 | - Constant number `uppercaseD` 45 | - Constant number `uppercaseE` 46 | - Constant number `uppercaseF` 47 | - Constant number `uppercaseG` 48 | - Constant number `uppercaseH` 49 | - Constant number `uppercaseI` 50 | - Constant number `uppercaseJ` 51 | - Constant number `uppercaseK` 52 | - Constant number `uppercaseL` 53 | - Constant number `uppercaseM` 54 | - Constant number `uppercaseN` 55 | - Constant number `uppercaseO` 56 | - Constant number `uppercaseP` 57 | - Constant number `uppercaseQ` 58 | - Constant number `uppercaseR` 59 | - Constant number `uppercaseS` 60 | - Constant number `uppercaseT` 61 | - Constant number `uppercaseU` 62 | - Constant number `uppercaseV` 63 | - Constant number `uppercaseW` 64 | - Constant number `uppercaseX` 65 | - Constant number `uppercaseY` 66 | - Constant number `uppercaseZ` 67 | - Constant number `leftSquareBracket` 68 | - Constant number `backslash` 69 | - Constant number `rightSquareBracket` 70 | - Constant number `caret` 71 | - Constant number `underscore` 72 | - Constant number `graveAccent` 73 | - Constant number `lowercaseA` 74 | - Constant number `lowercaseB` 75 | - Constant number `lowercaseC` 76 | - Constant number `lowercaseD` 77 | - Constant number `lowercaseE` 78 | - Constant number `lowercaseF` 79 | - Constant number `lowercaseG` 80 | - Constant number `lowercaseH` 81 | - Constant number `lowercaseI` 82 | - Constant number `lowercaseJ` 83 | - Constant number `lowercaseK` 84 | - Constant number `lowercaseL` 85 | - Constant number `lowercaseM` 86 | - Constant number `lowercaseN` 87 | - Constant number `lowercaseO` 88 | - Constant number `lowercaseP` 89 | - Constant number `lowercaseQ` 90 | - Constant number `lowercaseR` 91 | - Constant number `lowercaseS` 92 | - Constant number `lowercaseT` 93 | - Constant number `lowercaseU` 94 | - Constant number `lowercaseV` 95 | - Constant number `lowercaseW` 96 | - Constant number `lowercaseX` 97 | - Constant number `lowercaseY` 98 | - Constant number `lowercaseZ` 99 | - Constant number `leftCurlyBrace` 100 | - Constant number `verticalBar` 101 | - Constant number `rightCurlyBrace` 102 | - Constant number `tilde` 103 | - Constant number `nonBreakingSpace` 104 | - Constant number `oghamSpaceMark` 105 | - Constant number `lineSeparator` 106 | - Constant number `paragraphSeparator` 107 | - function `isDigit(code)` 108 | 109 | -------------------------------------------------------------------------------- /packages/charcodes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "charcodes", 3 | "version": "0.2.0", 4 | "description": "Char codes constants", 5 | "main": "lib/index.js", 6 | "module": "lib/index.mjs", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/xtuc/charcodes.git" 10 | }, 11 | "engines": { 12 | "node": ">=6" 13 | }, 14 | "keywords": [ 15 | "charcodes", 16 | "ascii", 17 | "constants" 18 | ], 19 | "author": "Sven Sauleau", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/xtuc/charcodes/issues" 23 | }, 24 | "homepage": "https://github.com/xtuc/charcodes#readme" 25 | } 26 | -------------------------------------------------------------------------------- /packages/charcodes/src/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | export const backSpace: 8 = 8; 4 | export const tab: 9 = 9; // '\t' 5 | export const lineFeed: 10 = 10; // '\n' 6 | export const carriageReturn: 13 = 13; // '\r' 7 | export const shiftOut: 14 = 14; 8 | export const space: 32 = 32; 9 | export const exclamationMark: 33 = 33; // '!' 10 | export const quotationMark: 34 = 34; // '"' 11 | export const numberSign: 35 = 35; // '#' 12 | export const dollarSign: 36 = 36; // '$' 13 | export const percentSign: 37 = 37; // '%' 14 | export const ampersand: 38 = 38; // '&' 15 | export const apostrophe: 39 = 39; // ''' 16 | export const leftParenthesis: 40 = 40; // '(' 17 | export const rightParenthesis: 41 = 41; // ')' 18 | export const asterisk: 42 = 42; // '*' 19 | export const plusSign: 43 = 43; // '+' 20 | export const comma: 44 = 44; // ',' 21 | export const dash: 45 = 45; // '-' 22 | export const dot: 46 = 46; // '.' 23 | export const slash: 47 = 47; // '/' 24 | export const digit0: 48 = 48; // '0' 25 | export const digit1: 49 = 49; // '1' 26 | export const digit2: 50 = 50; // '2' 27 | export const digit3: 51 = 51; // '3' 28 | export const digit4: 52 = 52; // '4' 29 | export const digit5: 53 = 53; // '5' 30 | export const digit6: 54 = 54; // '6' 31 | export const digit7: 55 = 55; // '7' 32 | export const digit8: 56 = 56; // '8' 33 | export const digit9: 57 = 57; // '9' 34 | export const colon: 58 = 58; // ':' 35 | export const semicolon: 59 = 59; // ';' 36 | export const lessThan: 60 = 60; // '<' 37 | export const equalsTo: 61 = 61; // '=' 38 | export const greaterThan: 62 = 62; // '>' 39 | export const questionMark: 63 = 63; // '?' 40 | export const atSign: 64 = 64; // '@' 41 | export const uppercaseA: 65 = 65; // 'A' 42 | export const uppercaseB: 66 = 66; // 'B' 43 | export const uppercaseC: 67 = 67; // 'C' 44 | export const uppercaseD: 68 = 68; // 'D' 45 | export const uppercaseE: 69 = 69; // 'E' 46 | export const uppercaseF: 70 = 70; // 'F' 47 | export const uppercaseG: 71 = 71; // 'G' 48 | export const uppercaseH: 72 = 72; // 'H' 49 | export const uppercaseI: 73 = 73; // 'I' 50 | export const uppercaseJ: 74 = 74; // 'J' 51 | export const uppercaseK: 75 = 75; // 'K' 52 | export const uppercaseL: 76 = 76; // 'L' 53 | export const uppercaseM: 77 = 77; // 'M' 54 | export const uppercaseN: 78 = 78; // 'N' 55 | export const uppercaseO: 79 = 79; // 'O' 56 | export const uppercaseP: 80 = 80; // 'P' 57 | export const uppercaseQ: 81 = 81; // 'Q' 58 | export const uppercaseR: 82 = 82; // 'R' 59 | export const uppercaseS: 83 = 83; // 'S' 60 | export const uppercaseT: 84 = 84; // 'T' 61 | export const uppercaseU: 85 = 85; // 'U' 62 | export const uppercaseV: 86 = 86; // 'V' 63 | export const uppercaseW: 87 = 87; // 'W' 64 | export const uppercaseX: 88 = 88; // 'X' 65 | export const uppercaseY: 89 = 89; // 'Y' 66 | export const uppercaseZ: 90 = 90; // 'Z' 67 | export const leftSquareBracket: 91 = 91; // '[' 68 | export const backslash: 92 = 92; // '\ ' 69 | export const rightSquareBracket: 93 = 93; // ']' 70 | export const caret: 94 = 94; // '^' 71 | export const underscore: 95 = 95; // '_' 72 | export const graveAccent: 96 = 96; // '`' 73 | export const lowercaseA: 97 = 97; // 'a' 74 | export const lowercaseB: 98 = 98; // 'b' 75 | export const lowercaseC: 99 = 99; // 'c' 76 | export const lowercaseD: 100 = 100; // 'd' 77 | export const lowercaseE: 101 = 101; // 'e' 78 | export const lowercaseF: 102 = 102; // 'f' 79 | export const lowercaseG: 103 = 103; // 'g' 80 | export const lowercaseH: 104 = 104; // 'h' 81 | export const lowercaseI: 105 = 105; // 'i' 82 | export const lowercaseJ: 106 = 106; // 'j' 83 | export const lowercaseK: 107 = 107; // 'k' 84 | export const lowercaseL: 108 = 108; // 'l' 85 | export const lowercaseM: 109 = 109; // 'm' 86 | export const lowercaseN: 110 = 110; // 'n' 87 | export const lowercaseO: 111 = 111; // 'o' 88 | export const lowercaseP: 112 = 112; // 'p' 89 | export const lowercaseQ: 113 = 113; // 'q' 90 | export const lowercaseR: 114 = 114; // 'r' 91 | export const lowercaseS: 115 = 115; // 's' 92 | export const lowercaseT: 116 = 116; // 't' 93 | export const lowercaseU: 117 = 117; // 'u' 94 | export const lowercaseV: 118 = 118; // 'v' 95 | export const lowercaseW: 119 = 119; // 'w' 96 | export const lowercaseX: 120 = 120; // 'x' 97 | export const lowercaseY: 121 = 121; // 'y' 98 | export const lowercaseZ: 122 = 122; // 'z' 99 | export const leftCurlyBrace: 123 = 123; // '{' 100 | export const verticalBar: 124 = 124; // '|' 101 | export const rightCurlyBrace: 125 = 125; // '}' 102 | export const tilde: 126 = 126; // '~' 103 | export const nonBreakingSpace: 160 = 160; 104 | export const oghamSpaceMark: 5760 = 5760; // ' ' 105 | export const lineSeparator: 8232 = 8232; 106 | export const paragraphSeparator: 8233 = 8233; 107 | 108 | export function isDigit(code: number): boolean { 109 | return code >= digit0 && code <= digit9; 110 | } 111 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | ROOT_DIR=$(cd $(dirname $0)/..; pwd) 5 | cd $ROOT_DIR 6 | 7 | PACKAGE="$1" 8 | 9 | for D in ./packages/*; do 10 | if [ ! -d "${D}/src" ]; then 11 | continue 12 | fi 13 | 14 | if [ -n "$PACKAGE" ] && [ `basename $D` != "$PACKAGE" ]; then 15 | continue 16 | fi 17 | 18 | echo "Building $D..." 19 | 20 | # Clean 21 | rm -rf "${D}/lib" 22 | mkdir "${D}/lib" 23 | 24 | # Build cjs 25 | ./node_modules/.bin/babel "${D}/src/index.js" \ 26 | -o "${D}/lib/index.js" \ 27 | --env-name "cjs" \ 28 | --quiet 29 | 30 | # Build esm 31 | ./node_modules/.bin/babel "${D}/src/index.js" \ 32 | -o "${D}/lib/index.mjs" \ 33 | --env-name "esm" \ 34 | --quiet 35 | done 36 | --------------------------------------------------------------------------------