This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function escapeRegex(string: string) { | |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string | |
} | |
export function regex( | |
strings: TemplateStringsArray, | |
...values: Array<RegExp | string> | |
): RegExp; | |
export function regex( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function escapeRegex(string) { | |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string | |
} | |
/** | |
* regex`${'escaped'} ${regex`nestable`}` | |
* regex('gi')`withFlags` | |
*/ | |
export function regex(...args) { | |
function _regex(flags, strings, ...values) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// plugin.js | |
'use strict'; | |
const BabelParser = require("@babel/parser"); | |
// https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md | |
// TODO import decorate/extendObservable | |
module.exports = function ({ types }) { | |
const visitor = { | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const React = require('react'); | |
const __DEV__ = process.env.NODE_ENV !== 'production'; | |
const HOOK_NAME = 'useDerivedState'; | |
const NO_DEPS_HINT = 'If there are no dependencies, use "const [state] = useState(fn)"' | |
/** | |
* Copied from from React sources and adjusted | |
* inlined Object.is polyfill to avoid requiring consumers ship their own | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is |