update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p"},C:{"1":"0 9 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B qC rC"},D:{"1":"0 9 q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p"},E:{"1":"IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C"},F:{"1":"0 c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"1":"2 3 4 5 6 7 8","2":"1 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"1":"rD","2":"qD"}},B:4,C:"CSS Grid animation",D:false};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0.024,"11":0.11518,"44":0.0144,"45":0.0096,"52":0.0096,"59":0.0096,"72":0.0048,"78":0.0192,"88":0.0096,"94":0.0144,"115":0.19196,"118":0.40792,"125":0.0096,"127":0.0048,"128":0.09598,"130":0.0048,"131":0.0048,"132":0.0096,"133":0.024,"134":0.04319,"135":0.5039,"136":1.47329,"137":0.0048,_:"3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 46 47 48 49 50 51 53 54 55 56 57 58 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 79 80 81 82 83 84 85 86 87 89 90 91 92 93 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 116 117 119 120 121 122 123 124 126 129 138 139 140 3.5 3.6"},D:{"39":0.0096,"40":0.0096,"41":0.0096,"42":0.0096,"43":0.0096,"44":0.0096,"45":0.0096,"46":0.0096,"47":0.0096,"48":0.05279,"49":0.02879,"50":0.0096,"51":0.0096,"52":0.0144,"53":0.0096,"54":0.0096,"55":0.0096,"56":0.04799,"57":0.0096,"58":0.0096,"59":0.0096,"60":0.0096,"66":0.024,"74":0.0096,"75":0.0048,"76":0.0096,"77":0.0144,"78":0.0096,"79":0.07678,"80":0.0144,"81":0.02879,"83":0.07678,"84":0.0096,"85":0.0096,"86":0.0096,"87":0.05759,"88":0.0144,"90":0.0096,"91":0.09118,"92":0.0096,"93":0.02879,"94":0.0192,"96":0.0048,"97":0.024,"98":0.0048,"99":0.024,"100":0.0144,"101":0.0144,"102":0.0096,"103":0.15357,"104":0.05759,"105":0.0144,"106":0.024,"107":0.02879,"108":0.05759,"109":0.4799,"110":0.024,"111":0.02879,"112":0.04799,"113":0.04319,"114":0.06719,"115":0.07199,"116":0.16317,"117":0.35993,"118":0.04319,"119":0.04799,"120":0.08158,"121":0.23035,"122":0.10558,"123":0.04319,"124":0.21116,"125":0.81103,"126":0.35993,"127":0.19676,"128":0.20636,"129":0.14397,"130":0.24475,"131":1.9052,"132":2.16435,"133":8.42225,"134":10.77376,"135":0.02879,"136":0.024,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 61 62 63 64 65 67 68 69 70 71 72 73 89 95 137 138"},F:{"87":0.0096,"95":0.024,"116":0.15837,"117":0.4991,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 88 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.0096,"18":0.0096,"109":0.05759,"114":0.0048,"120":0.0096,"121":0.0144,"122":0.0144,"124":0.0048,"126":0.0096,"127":0.0048,"128":0.0096,"129":0.0096,"130":0.0144,"131":0.06719,"132":0.11998,"133":1.9436,"134":4.17033,_:"13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 110 111 112 113 115 116 117 118 119 123 125"},E:{"9":0.0048,"14":0.03359,"15":0.0096,_:"0 4 5 6 7 8 10 11 12 13 3.1 3.2 5.1 6.1 7.1 10.1","9.1":0.0096,"11.1":0.0048,"12.1":0.0144,"13.1":0.08158,"14.1":0.07678,"15.1":0.04799,"15.2-15.3":0.0096,"15.4":0.0192,"15.5":0.024,"15.6":0.27354,"16.0":0.07199,"16.1":0.04319,"16.2":0.03359,"16.3":0.08158,"16.4":0.03359,"16.5":0.05279,"16.6":0.42231,"17.0":0.0192,"17.1":0.25915,"17.2":0.03839,"17.3":0.04799,"17.4":0.10078,"17.5":0.16797,"17.6":0.59508,"18.0":0.06239,"18.1":0.22555,"18.2":0.11518,"18.3":3.16254,"18.4":0.03839},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0.02832,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0.01416,"9.3":0.01888,"10.0-10.2":0,"10.3":0.02832,"11.0-11.2":0.20062,"11.3-11.4":0.01416,"12.0-12.1":0.00708,"12.2-12.5":0.09913,"13.0-13.1":0.00236,"13.2":0.00472,"13.3":0.00472,"13.4-13.7":0.02124,"14.0-14.4":0.0472,"14.5-14.8":0.05428,"15.0-15.1":0.02596,"15.2-15.3":0.02832,"15.4":0.03068,"15.5":0.03776,"15.6-15.8":0.40124,"16.0":0.06609,"16.1":0.20062,"16.2":0.09677,"16.3":0.16049,"16.4":0.02832,"16.5":0.05665,"16.6-16.7":0.78359,"17.0":0.0354,"17.1":0.06137,"17.2":0.04956,"17.3":0.08025,"17.4":0.2195,"17.5":0.39652,"17.6-17.7":1.40905,"18.0":0.25962,"18.1":1.23911,"18.2":0.43428,"18.3":16.67491,"18.4":0.26434},P:{"4":0.01122,"21":0.02244,"24":0.02244,"25":0.02244,"26":0.04489,"27":1.51488,_:"20 22 23 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0"},I:{"0":0.0829,"3":0,"4":0.00001,"2.1":0,"2.2":0.00001,"2.3":0,"4.1":0,"4.2-4.3":0.00016,"4.4":0,"4.4.3-4.4.4":0.00006},K:{"0":0.26005,_:"10 11 12 11.1 11.5 12.1"},A:{"6":0.00566,"9":0.02828,"11":0.12443,_:"7 8 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.57211},Q:{"14.9":0.02601},O:{"0":0.06241},H:{"0":0},L:{"0":26.35015}};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["mergeOptions","target","source","k","Object","keys","parserOpts","targetObj","mergeDefaultFields","val","undefined","isIterableIterator","value","next","Symbol","iterator"],"sources":["../../src/config/util.ts"],"sourcesContent":["import type {\n ValidatedOptions,\n NormalizedOptions,\n} from \"./validation/options.ts\";\n\nexport function mergeOptions(\n target: ValidatedOptions,\n source: ValidatedOptions | NormalizedOptions,\n): void {\n for (const k of Object.keys(source)) {\n if (\n (k === \"parserOpts\" || k === \"generatorOpts\" || k === \"assumptions\") &&\n source[k]\n ) {\n const parserOpts = source[k];\n const targetObj = target[k] || (target[k] = {});\n mergeDefaultFields(targetObj, parserOpts);\n } else {\n //@ts-expect-error k must index source\n const val = source[k];\n //@ts-expect-error assigning source to target\n if (val !== undefined) target[k] = val as any;\n }\n }\n}\n\nfunction mergeDefaultFields<T extends object>(target: T, source: T) {\n for (const k of Object.keys(source) as (keyof T)[]) {\n const val = source[k];\n if (val !== undefined) target[k] = val;\n }\n}\n\nexport function isIterableIterator(value: any): value is IterableIterator<any> {\n return (\n !!value &&\n typeof value.next === \"function\" &&\n typeof value[Symbol.iterator] === \"function\"\n );\n}\n"],"mappings":";;;;;;;AAKO,SAASA,YAAYA,CAC1BC,MAAwB,EACxBC,MAA4C,EACtC;EACN,KAAK,MAAMC,CAAC,IAAIC,MAAM,CAACC,IAAI,CAACH,MAAM,CAAC,EAAE;IACnC,IACE,CAACC,CAAC,KAAK,YAAY,IAAIA,CAAC,KAAK,eAAe,IAAIA,CAAC,KAAK,aAAa,KACnED,MAAM,CAACC,CAAC,CAAC,EACT;MACA,MAAMG,UAAU,GAAGJ,MAAM,CAACC,CAAC,CAAC;MAC5B,MAAMI,SAAS,GAAGN,MAAM,CAACE,CAAC,CAAC,KAAKF,MAAM,CAACE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;MAC/CK,kBAAkB,CAACD,SAAS,EAAED,UAAU,CAAC;IAC3C,CAAC,MAAM;MAEL,MAAMG,GAAG,GAAGP,MAAM,CAACC,CAAC,CAAC;MAErB,IAAIM,GAAG,KAAKC,SAAS,EAAET,MAAM,CAACE,CAAC,CAAC,GAAGM,GAAU;IAC/C;EACF;AACF;AAEA,SAASD,kBAAkBA,CAAmBP,MAAS,EAAEC,MAAS,EAAE;EAClE,KAAK,MAAMC,CAAC,IAAIC,MAAM,CAACC,IAAI,CAACH,MAAM,CAAC,EAAiB;IAClD,MAAMO,GAAG,GAAGP,MAAM,CAACC,CAAC,CAAC;IACrB,IAAIM,GAAG,KAAKC,SAAS,EAAET,MAAM,CAACE,CAAC,CAAC,GAAGM,GAAG;EACxC;AACF;AAEO,SAASE,kBAAkBA,CAACC,KAAU,EAAkC;EAC7E,OACE,CAAC,CAACA,KAAK,IACP,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU,IAChC,OAAOD,KAAK,CAACE,MAAM,CAACC,QAAQ,CAAC,KAAK,UAAU;AAEhD;AAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { ExtractState, Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from 'zustand/vanilla';
|
||||
type ReadonlyStoreApi<T> = Pick<StoreApi<T>, 'getState' | 'getInitialState' | 'subscribe'>;
|
||||
export declare function useStore<S extends ReadonlyStoreApi<unknown>>(api: S): ExtractState<S>;
|
||||
export declare function useStore<S extends ReadonlyStoreApi<unknown>, U>(api: S, selector: (state: ExtractState<S>) => U): U;
|
||||
export type UseBoundStore<S extends ReadonlyStoreApi<unknown>> = {
|
||||
(): ExtractState<S>;
|
||||
<U>(selector: (state: ExtractState<S>) => U): U;
|
||||
} & S;
|
||||
type Create = {
|
||||
<T, Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>): UseBoundStore<Mutate<StoreApi<T>, Mos>>;
|
||||
<T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>;
|
||||
};
|
||||
export declare const create: Create;
|
||||
export {};
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1,103 @@
|
||||
#include "Backend.h"
|
||||
#include <string>
|
||||
#include <napi.h>
|
||||
|
||||
Backend::Backend(std::string name, Napi::CallbackInfo& info) : name(name), env(info.Env()) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (info[0].IsNumber()) width = info[0].As<Napi::Number>().Int32Value();
|
||||
if (info[1].IsNumber()) height = info[1].As<Napi::Number>().Int32Value();
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
Backend::~Backend()
|
||||
{
|
||||
Backend::destroySurface();
|
||||
}
|
||||
|
||||
void Backend::setCanvas(Canvas* _canvas)
|
||||
{
|
||||
this->canvas = _canvas;
|
||||
}
|
||||
|
||||
|
||||
cairo_surface_t* Backend::recreateSurface()
|
||||
{
|
||||
this->destroySurface();
|
||||
|
||||
return this->createSurface();
|
||||
}
|
||||
|
||||
DLL_PUBLIC cairo_surface_t* Backend::getSurface() {
|
||||
if (!surface) createSurface();
|
||||
return surface;
|
||||
}
|
||||
|
||||
void Backend::destroySurface()
|
||||
{
|
||||
if(this->surface)
|
||||
{
|
||||
cairo_surface_destroy(this->surface);
|
||||
this->surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string Backend::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
int Backend::getWidth()
|
||||
{
|
||||
return this->width;
|
||||
}
|
||||
void Backend::setWidth(int width_)
|
||||
{
|
||||
this->width = width_;
|
||||
this->recreateSurface();
|
||||
}
|
||||
|
||||
int Backend::getHeight()
|
||||
{
|
||||
return this->height;
|
||||
}
|
||||
void Backend::setHeight(int height_)
|
||||
{
|
||||
this->height = height_;
|
||||
this->recreateSurface();
|
||||
}
|
||||
|
||||
bool Backend::isSurfaceValid(){
|
||||
bool hadSurface = surface != NULL;
|
||||
bool isValid = true;
|
||||
|
||||
cairo_status_t status = cairo_surface_status(getSurface());
|
||||
|
||||
if (status != CAIRO_STATUS_SUCCESS) {
|
||||
error = cairo_status_to_string(status);
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!hadSurface)
|
||||
destroySurface();
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
BackendOperationNotAvailable::BackendOperationNotAvailable(Backend* backend,
|
||||
std::string operation_name)
|
||||
: operation_name(operation_name)
|
||||
{
|
||||
msg = "operation " + operation_name +
|
||||
" not supported by backend " + backend->getName();
|
||||
};
|
||||
|
||||
BackendOperationNotAvailable::~BackendOperationNotAvailable() throw() {};
|
||||
|
||||
const char* BackendOperationNotAvailable::what() const throw()
|
||||
{
|
||||
return msg.c_str();
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @fileoverview Types for the config-array package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
export interface ConfigObject {
|
||||
/**
|
||||
* The files to include.
|
||||
*/
|
||||
files?: string[];
|
||||
/**
|
||||
* The files to exclude.
|
||||
*/
|
||||
ignores?: string[];
|
||||
/**
|
||||
* The name of the config object.
|
||||
*/
|
||||
name?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
Copyright 2008 Fair Oaks Labs, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017-2018 Fredrik Nicol
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "html",
|
||||
"description": "Outputs results to HTML. The `html` formatter is useful for visual presentation in the browser."
|
||||
},
|
||||
{
|
||||
"name": "json-with-metadata",
|
||||
"description": "Outputs JSON-serialized results. The `json-with-metadata` provides the same linting results as the [`json`](#json) formatter with additional metadata about the rules applied. The linting results are included in the `results` property and the rules metadata is included in the `metadata` property.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint."
|
||||
},
|
||||
{
|
||||
"name": "json",
|
||||
"description": "Outputs JSON-serialized results. The `json` formatter is useful when you want to programmatically work with the CLI's linting results.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint."
|
||||
},
|
||||
{
|
||||
"name": "stylish",
|
||||
"description": "Human-readable output format. This is the default formatter."
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,167 @@
|
||||
// As defined on the list of supported events: https://reactjs.org/docs/events.html
|
||||
export const clipboardEvents = ['onCopy', 'onCut', 'onPaste'] as const;
|
||||
export const compositionEvents = [
|
||||
'onCompositionEnd',
|
||||
'onCompositionStart',
|
||||
'onCompositionUpdate',
|
||||
] as const;
|
||||
export const focusEvents = ['onFocus', 'onBlur'] as const;
|
||||
export const formEvents = ['onInput', 'onInvalid', 'onReset', 'onSubmit'] as const;
|
||||
export const imageEvents = ['onLoad', 'onError'] as const;
|
||||
export const keyboardEvents = ['onKeyDown', 'onKeyPress', 'onKeyUp'] as const;
|
||||
export const mediaEvents = [
|
||||
'onAbort',
|
||||
'onCanPlay',
|
||||
'onCanPlayThrough',
|
||||
'onDurationChange',
|
||||
'onEmptied',
|
||||
'onEncrypted',
|
||||
'onEnded',
|
||||
'onError',
|
||||
'onLoadedData',
|
||||
'onLoadedMetadata',
|
||||
'onLoadStart',
|
||||
'onPause',
|
||||
'onPlay',
|
||||
'onPlaying',
|
||||
'onProgress',
|
||||
'onRateChange',
|
||||
'onSeeked',
|
||||
'onSeeking',
|
||||
'onStalled',
|
||||
'onSuspend',
|
||||
'onTimeUpdate',
|
||||
'onVolumeChange',
|
||||
'onWaiting',
|
||||
] as const;
|
||||
export const mouseEvents = [
|
||||
'onClick',
|
||||
'onContextMenu',
|
||||
'onDoubleClick',
|
||||
'onMouseDown',
|
||||
'onMouseEnter',
|
||||
'onMouseLeave',
|
||||
'onMouseMove',
|
||||
'onMouseOut',
|
||||
'onMouseOver',
|
||||
'onMouseUp',
|
||||
] as const;
|
||||
export const dragEvents = [
|
||||
'onDrag',
|
||||
'onDragEnd',
|
||||
'onDragEnter',
|
||||
'onDragExit',
|
||||
'onDragLeave',
|
||||
'onDragOver',
|
||||
'onDragStart',
|
||||
'onDrop',
|
||||
] as const;
|
||||
export const selectionEvents = ['onSelect'] as const;
|
||||
export const touchEvents = ['onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart'] as const;
|
||||
export const pointerEvents = [
|
||||
'onPointerDown',
|
||||
'onPointerMove',
|
||||
'onPointerUp',
|
||||
'onPointerCancel',
|
||||
'onGotPointerCapture',
|
||||
'onLostPointerCapture',
|
||||
'onPointerEnter',
|
||||
'onPointerLeave',
|
||||
'onPointerOver',
|
||||
'onPointerOut',
|
||||
] as const;
|
||||
export const uiEvents = ['onScroll'] as const;
|
||||
export const wheelEvents = ['onWheel'] as const;
|
||||
export const animationEvents = [
|
||||
'onAnimationStart',
|
||||
'onAnimationEnd',
|
||||
'onAnimationIteration',
|
||||
] as const;
|
||||
export const transitionEvents = ['onTransitionEnd'] as const;
|
||||
export const otherEvents = ['onToggle'] as const;
|
||||
export const changeEvents = ['onChange'] as const;
|
||||
|
||||
export const allEvents = [
|
||||
...clipboardEvents,
|
||||
...compositionEvents,
|
||||
...focusEvents,
|
||||
...formEvents,
|
||||
...imageEvents,
|
||||
...keyboardEvents,
|
||||
...mediaEvents,
|
||||
...mouseEvents,
|
||||
...dragEvents,
|
||||
...selectionEvents,
|
||||
...touchEvents,
|
||||
...pointerEvents,
|
||||
...uiEvents,
|
||||
...wheelEvents,
|
||||
...animationEvents,
|
||||
...transitionEvents,
|
||||
...changeEvents,
|
||||
...otherEvents,
|
||||
] as const;
|
||||
|
||||
type AllEvents = (typeof allEvents)[number];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type EventHandler<ArgsType> = (event: any, args: ArgsType) => void;
|
||||
|
||||
// Creates inferred type for event handler without args.
|
||||
type EventHandlerWithoutArgs<ArgsType, OriginalEventHandler> = OriginalEventHandler extends (
|
||||
event: infer Event,
|
||||
args: ArgsType,
|
||||
) => void
|
||||
? (event: Event) => void
|
||||
: never;
|
||||
|
||||
export type EventProps<ArgsType> = {
|
||||
[K in AllEvents]?: EventHandler<ArgsType>;
|
||||
};
|
||||
|
||||
type Props<ArgsType> = Record<string, unknown> & EventProps<ArgsType>;
|
||||
|
||||
type EventPropsWithoutArgs<ArgsType, PropsType> = {
|
||||
[K in keyof PropsType as K extends AllEvents ? K : never]: EventHandlerWithoutArgs<
|
||||
ArgsType,
|
||||
PropsType[K]
|
||||
>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an object with on-event callback props curried with provided args.
|
||||
* @param {Object} props Props passed to a component.
|
||||
* @param {Function=} getArgs A function that returns argument(s) on-event callbacks
|
||||
* shall be curried with.
|
||||
*/
|
||||
export default function makeEventProps<
|
||||
ArgsType,
|
||||
PropsType extends Props<ArgsType> = Props<ArgsType>,
|
||||
>(
|
||||
props: PropsType,
|
||||
getArgs?: (eventName: string) => ArgsType,
|
||||
): EventPropsWithoutArgs<ArgsType, PropsType> {
|
||||
const eventProps: EventPropsWithoutArgs<ArgsType, PropsType> = {} as EventPropsWithoutArgs<
|
||||
ArgsType,
|
||||
PropsType
|
||||
>;
|
||||
|
||||
allEvents.forEach((eventName) => {
|
||||
type EventHandlerType = EventPropsWithoutArgs<ArgsType, PropsType>[typeof eventName];
|
||||
|
||||
const eventHandler = props[eventName];
|
||||
|
||||
if (!eventHandler) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getArgs) {
|
||||
eventProps[eventName] = ((event) =>
|
||||
eventHandler(event, getArgs(eventName))) as EventHandlerType;
|
||||
} else {
|
||||
eventProps[eventName] = eventHandler as EventHandlerType;
|
||||
}
|
||||
});
|
||||
|
||||
return eventProps;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
'use strict';
|
||||
module.exports = function generate__limit(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $errorKeyword;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $isData = it.opts.$data && $schema && $schema.$data,
|
||||
$schemaValue;
|
||||
if ($isData) {
|
||||
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
|
||||
$schemaValue = 'schema' + $lvl;
|
||||
} else {
|
||||
$schemaValue = $schema;
|
||||
}
|
||||
var $isMax = $keyword == 'maximum',
|
||||
$exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
|
||||
$schemaExcl = it.schema[$exclusiveKeyword],
|
||||
$isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
|
||||
$op = $isMax ? '<' : '>',
|
||||
$notOp = $isMax ? '>' : '<',
|
||||
$errorKeyword = undefined;
|
||||
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
|
||||
throw new Error($keyword + ' must be number');
|
||||
}
|
||||
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
|
||||
throw new Error($exclusiveKeyword + ' must be number or boolean');
|
||||
}
|
||||
if ($isDataExcl) {
|
||||
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
|
||||
$exclusive = 'exclusive' + $lvl,
|
||||
$exclType = 'exclType' + $lvl,
|
||||
$exclIsNumber = 'exclIsNumber' + $lvl,
|
||||
$opExpr = 'op' + $lvl,
|
||||
$opStr = '\' + ' + $opExpr + ' + \'';
|
||||
out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
|
||||
$schemaValueExcl = 'schemaExcl' + $lvl;
|
||||
out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { ';
|
||||
var $errorKeyword = $exclusiveKeyword;
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } else if ( ';
|
||||
if ($isData) {
|
||||
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
|
||||
}
|
||||
out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; ';
|
||||
if ($schema === undefined) {
|
||||
$errorKeyword = $exclusiveKeyword;
|
||||
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
||||
$schemaValue = $schemaValueExcl;
|
||||
$isData = $isDataExcl;
|
||||
}
|
||||
} else {
|
||||
var $exclIsNumber = typeof $schemaExcl == 'number',
|
||||
$opStr = $op;
|
||||
if ($exclIsNumber && $isData) {
|
||||
var $opExpr = '\'' + $opStr + '\'';
|
||||
out += ' if ( ';
|
||||
if ($isData) {
|
||||
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
|
||||
}
|
||||
out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { ';
|
||||
} else {
|
||||
if ($exclIsNumber && $schema === undefined) {
|
||||
$exclusive = true;
|
||||
$errorKeyword = $exclusiveKeyword;
|
||||
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
||||
$schemaValue = $schemaExcl;
|
||||
$notOp += '=';
|
||||
} else {
|
||||
if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
|
||||
if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
|
||||
$exclusive = true;
|
||||
$errorKeyword = $exclusiveKeyword;
|
||||
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
||||
$notOp += '=';
|
||||
} else {
|
||||
$exclusive = false;
|
||||
$opStr += '=';
|
||||
}
|
||||
}
|
||||
var $opExpr = '\'' + $opStr + '\'';
|
||||
out += ' if ( ';
|
||||
if ($isData) {
|
||||
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
|
||||
}
|
||||
out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { ';
|
||||
}
|
||||
}
|
||||
$errorKeyword = $errorKeyword || $keyword;
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should be ' + ($opStr) + ' ';
|
||||
if ($isData) {
|
||||
out += '\' + ' + ($schemaValue);
|
||||
} else {
|
||||
out += '' + ($schemaValue) + '\'';
|
||||
}
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: ';
|
||||
if ($isData) {
|
||||
out += 'validate.schema' + ($schemaPath);
|
||||
} else {
|
||||
out += '' + ($schema);
|
||||
}
|
||||
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } ';
|
||||
if ($breakOnError) {
|
||||
out += ' else { ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @fileoverview typings for "eslint/universal" module
|
||||
* @author 唯然<weiran.zsd@outlook.com>
|
||||
*/
|
||||
|
||||
export { Linter } from "./index";
|
||||
Binary file not shown.
@@ -0,0 +1,89 @@
|
||||
# cross-spawn
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Build status][appveyor-image]][appveyor-url]
|
||||
|
||||
[npm-url]:https://npmjs.org/package/cross-spawn
|
||||
[downloads-image]:https://img.shields.io/npm/dm/cross-spawn.svg
|
||||
[npm-image]:https://img.shields.io/npm/v/cross-spawn.svg
|
||||
[ci-url]:https://github.com/moxystudio/node-cross-spawn/actions/workflows/ci.yaml
|
||||
[ci-image]:https://github.com/moxystudio/node-cross-spawn/actions/workflows/ci.yaml/badge.svg
|
||||
[appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn
|
||||
[appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn/master.svg
|
||||
|
||||
A cross platform solution to node's spawn and spawnSync.
|
||||
|
||||
## Installation
|
||||
|
||||
Node.js version 8 and up:
|
||||
`$ npm install cross-spawn`
|
||||
|
||||
Node.js version 7 and under:
|
||||
`$ npm install cross-spawn@6`
|
||||
|
||||
## Why
|
||||
|
||||
Node has issues when using spawn on Windows:
|
||||
|
||||
- It ignores [PATHEXT](https://github.com/joyent/node/issues/2318)
|
||||
- It does not support [shebangs](https://en.wikipedia.org/wiki/Shebang_(Unix))
|
||||
- Has problems running commands with [spaces](https://github.com/nodejs/node/issues/7367)
|
||||
- Has problems running commands with posix relative paths (e.g.: `./my-folder/my-executable`)
|
||||
- Has an [issue](https://github.com/moxystudio/node-cross-spawn/issues/82) with command shims (files in `node_modules/.bin/`), where arguments with quotes and parenthesis would result in [invalid syntax error](https://github.com/moxystudio/node-cross-spawn/blob/e77b8f22a416db46b6196767bcd35601d7e11d54/test/index.test.js#L149)
|
||||
- No `options.shell` support on node `<v4.8`
|
||||
|
||||
All these issues are handled correctly by `cross-spawn`.
|
||||
There are some known modules, such as [win-spawn](https://github.com/ForbesLindesay/win-spawn), that try to solve this but they are either broken or provide faulty escaping of shell arguments.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) or [`spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), so it's a drop in replacement.
|
||||
|
||||
|
||||
```js
|
||||
const spawn = require('cross-spawn');
|
||||
|
||||
// Spawn NPM asynchronously
|
||||
const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
|
||||
|
||||
// Spawn NPM synchronously
|
||||
const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
|
||||
```
|
||||
|
||||
|
||||
## Caveats
|
||||
|
||||
### Using `options.shell` as an alternative to `cross-spawn`
|
||||
|
||||
Starting from node `v4.8`, `spawn` has a `shell` option that allows you run commands from within a shell. This new option solves
|
||||
the [PATHEXT](https://github.com/joyent/node/issues/2318) issue but:
|
||||
|
||||
- It's not supported in node `<v4.8`
|
||||
- You must manually escape the command and arguments which is very error prone, specially when passing user input
|
||||
- There are a lot of other unresolved issues from the [Why](#why) section that you must take into account
|
||||
|
||||
If you are using the `shell` option to spawn a command in a cross platform way, consider using `cross-spawn` instead. You have been warned.
|
||||
|
||||
### `options.shell` support
|
||||
|
||||
While `cross-spawn` adds support for `options.shell` in node `<v4.8`, all of its enhancements are disabled.
|
||||
|
||||
This mimics the Node.js behavior. More specifically, the command and its arguments will not be automatically escaped nor shebang support will be offered. This is by design because if you are using `options.shell` you are probably targeting a specific platform anyway and you don't want things to get into your way.
|
||||
|
||||
### Shebangs support
|
||||
|
||||
While `cross-spawn` handles shebangs on Windows, its support is limited. More specifically, it just supports `#!/usr/bin/env <program>` where `<program>` must not contain any arguments.
|
||||
If you would like to have the shebang support improved, feel free to contribute via a pull-request.
|
||||
|
||||
Remember to always test your code on Windows!
|
||||
|
||||
|
||||
## Tests
|
||||
|
||||
`$ npm test`
|
||||
`$ npm test -- --watch` during development
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Released under the [MIT License](https://www.opensource.org/licenses/mit-license.php).
|
||||
@@ -0,0 +1,153 @@
|
||||
### Estraverse [](http://travis-ci.org/estools/estraverse)
|
||||
|
||||
Estraverse ([estraverse](http://github.com/estools/estraverse)) is
|
||||
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
traversal functions from [esmangle project](http://github.com/estools/esmangle).
|
||||
|
||||
### Documentation
|
||||
|
||||
You can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).
|
||||
|
||||
### Example Usage
|
||||
|
||||
The following code will output all variables declared at the root of a file.
|
||||
|
||||
```javascript
|
||||
estraverse.traverse(ast, {
|
||||
enter: function (node, parent) {
|
||||
if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
|
||||
return estraverse.VisitorOption.Skip;
|
||||
},
|
||||
leave: function (node, parent) {
|
||||
if (node.type == 'VariableDeclarator')
|
||||
console.log(node.id.name);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.
|
||||
|
||||
```javascript
|
||||
estraverse.traverse(ast, {
|
||||
enter: function (node) {
|
||||
this.break();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.
|
||||
|
||||
```javascript
|
||||
result = estraverse.replace(tree, {
|
||||
enter: function (node) {
|
||||
// Replace it with replaced.
|
||||
if (node.type === 'Literal')
|
||||
return replaced;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
By passing `visitor.keys` mapping, we can extend estraverse traversing functionality.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Extending the existing traversing rules.
|
||||
keys: {
|
||||
// TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]
|
||||
TestExpression: ['argument']
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
By passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Iterating the child **nodes** of unknown nodes.
|
||||
fallback: 'iteration'
|
||||
});
|
||||
```
|
||||
|
||||
When `visitor.fallback` is a function, we can determine which keys to visit on each node.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Skip the `argument` property of each node
|
||||
fallback: function(node) {
|
||||
return Object.keys(node).filter(function(key) {
|
||||
return key !== 'argument';
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### License
|
||||
|
||||
Copyright (C) 2012-2016 [Yusuke Suzuki](http://github.com/Constellation)
|
||||
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name" : "github-from-package",
|
||||
"version" : "0.0.0",
|
||||
"description" : "return the github url from a package.json file",
|
||||
"main" : "index.js",
|
||||
"devDependencies" : {
|
||||
"tap" : "~0.3.0",
|
||||
"tape" : "~0.1.5"
|
||||
},
|
||||
"scripts" : {
|
||||
"test" : "tap test/*.js"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "git://github.com/substack/github-from-package.git"
|
||||
},
|
||||
"homepage" : "https://github.com/substack/github-from-package",
|
||||
"keywords" : [
|
||||
"github",
|
||||
"package.json",
|
||||
"npm",
|
||||
"repository"
|
||||
],
|
||||
"author" : {
|
||||
"name" : "James Halliday",
|
||||
"email" : "mail@substack.net",
|
||||
"url" : "http://substack.net"
|
||||
},
|
||||
"license" : "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user