update
This commit is contained in:
@@ -0,0 +1,334 @@
|
||||
'use strict'
|
||||
|
||||
// A linked list to keep track of recently-used-ness
|
||||
const Yallist = require('yallist')
|
||||
|
||||
const MAX = Symbol('max')
|
||||
const LENGTH = Symbol('length')
|
||||
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
|
||||
const ALLOW_STALE = Symbol('allowStale')
|
||||
const MAX_AGE = Symbol('maxAge')
|
||||
const DISPOSE = Symbol('dispose')
|
||||
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
|
||||
const LRU_LIST = Symbol('lruList')
|
||||
const CACHE = Symbol('cache')
|
||||
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
|
||||
|
||||
const naiveLength = () => 1
|
||||
|
||||
// lruList is a yallist where the head is the youngest
|
||||
// item, and the tail is the oldest. the list contains the Hit
|
||||
// objects as the entries.
|
||||
// Each Hit object has a reference to its Yallist.Node. This
|
||||
// never changes.
|
||||
//
|
||||
// cache is a Map (or PseudoMap) that matches the keys to
|
||||
// the Yallist.Node object.
|
||||
class LRUCache {
|
||||
constructor (options) {
|
||||
if (typeof options === 'number')
|
||||
options = { max: options }
|
||||
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
// Kind of weird to have a default max of Infinity, but oh well.
|
||||
const max = this[MAX] = options.max || Infinity
|
||||
|
||||
const lc = options.length || naiveLength
|
||||
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
|
||||
this[ALLOW_STALE] = options.stale || false
|
||||
if (options.maxAge && typeof options.maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
this[MAX_AGE] = options.maxAge || 0
|
||||
this[DISPOSE] = options.dispose
|
||||
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
||||
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// resize the cache when the max changes.
|
||||
set max (mL) {
|
||||
if (typeof mL !== 'number' || mL < 0)
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
|
||||
this[MAX] = mL || Infinity
|
||||
trim(this)
|
||||
}
|
||||
get max () {
|
||||
return this[MAX]
|
||||
}
|
||||
|
||||
set allowStale (allowStale) {
|
||||
this[ALLOW_STALE] = !!allowStale
|
||||
}
|
||||
get allowStale () {
|
||||
return this[ALLOW_STALE]
|
||||
}
|
||||
|
||||
set maxAge (mA) {
|
||||
if (typeof mA !== 'number')
|
||||
throw new TypeError('maxAge must be a non-negative number')
|
||||
|
||||
this[MAX_AGE] = mA
|
||||
trim(this)
|
||||
}
|
||||
get maxAge () {
|
||||
return this[MAX_AGE]
|
||||
}
|
||||
|
||||
// resize the cache when the lengthCalculator changes.
|
||||
set lengthCalculator (lC) {
|
||||
if (typeof lC !== 'function')
|
||||
lC = naiveLength
|
||||
|
||||
if (lC !== this[LENGTH_CALCULATOR]) {
|
||||
this[LENGTH_CALCULATOR] = lC
|
||||
this[LENGTH] = 0
|
||||
this[LRU_LIST].forEach(hit => {
|
||||
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
||||
this[LENGTH] += hit.length
|
||||
})
|
||||
}
|
||||
trim(this)
|
||||
}
|
||||
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
||||
|
||||
get length () { return this[LENGTH] }
|
||||
get itemCount () { return this[LRU_LIST].length }
|
||||
|
||||
rforEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
||||
const prev = walker.prev
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
|
||||
forEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
||||
const next = walker.next
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = next
|
||||
}
|
||||
}
|
||||
|
||||
keys () {
|
||||
return this[LRU_LIST].toArray().map(k => k.key)
|
||||
}
|
||||
|
||||
values () {
|
||||
return this[LRU_LIST].toArray().map(k => k.value)
|
||||
}
|
||||
|
||||
reset () {
|
||||
if (this[DISPOSE] &&
|
||||
this[LRU_LIST] &&
|
||||
this[LRU_LIST].length) {
|
||||
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
|
||||
}
|
||||
|
||||
this[CACHE] = new Map() // hash of items by key
|
||||
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
||||
this[LENGTH] = 0 // length of items in the list
|
||||
}
|
||||
|
||||
dump () {
|
||||
return this[LRU_LIST].map(hit =>
|
||||
isStale(this, hit) ? false : {
|
||||
k: hit.key,
|
||||
v: hit.value,
|
||||
e: hit.now + (hit.maxAge || 0)
|
||||
}).toArray().filter(h => h)
|
||||
}
|
||||
|
||||
dumpLru () {
|
||||
return this[LRU_LIST]
|
||||
}
|
||||
|
||||
set (key, value, maxAge) {
|
||||
maxAge = maxAge || this[MAX_AGE]
|
||||
|
||||
if (maxAge && typeof maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
|
||||
const now = maxAge ? Date.now() : 0
|
||||
const len = this[LENGTH_CALCULATOR](value, key)
|
||||
|
||||
if (this[CACHE].has(key)) {
|
||||
if (len > this[MAX]) {
|
||||
del(this, this[CACHE].get(key))
|
||||
return false
|
||||
}
|
||||
|
||||
const node = this[CACHE].get(key)
|
||||
const item = node.value
|
||||
|
||||
// dispose of the old one before overwriting
|
||||
// split out into 2 ifs for better coverage tracking
|
||||
if (this[DISPOSE]) {
|
||||
if (!this[NO_DISPOSE_ON_SET])
|
||||
this[DISPOSE](key, item.value)
|
||||
}
|
||||
|
||||
item.now = now
|
||||
item.maxAge = maxAge
|
||||
item.value = value
|
||||
this[LENGTH] += len - item.length
|
||||
item.length = len
|
||||
this.get(key)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
const hit = new Entry(key, value, len, now, maxAge)
|
||||
|
||||
// oversized objects fall out of cache automatically.
|
||||
if (hit.length > this[MAX]) {
|
||||
if (this[DISPOSE])
|
||||
this[DISPOSE](key, value)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
this[LENGTH] += hit.length
|
||||
this[LRU_LIST].unshift(hit)
|
||||
this[CACHE].set(key, this[LRU_LIST].head)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
has (key) {
|
||||
if (!this[CACHE].has(key)) return false
|
||||
const hit = this[CACHE].get(key).value
|
||||
return !isStale(this, hit)
|
||||
}
|
||||
|
||||
get (key) {
|
||||
return get(this, key, true)
|
||||
}
|
||||
|
||||
peek (key) {
|
||||
return get(this, key, false)
|
||||
}
|
||||
|
||||
pop () {
|
||||
const node = this[LRU_LIST].tail
|
||||
if (!node)
|
||||
return null
|
||||
|
||||
del(this, node)
|
||||
return node.value
|
||||
}
|
||||
|
||||
del (key) {
|
||||
del(this, this[CACHE].get(key))
|
||||
}
|
||||
|
||||
load (arr) {
|
||||
// reset the cache
|
||||
this.reset()
|
||||
|
||||
const now = Date.now()
|
||||
// A previous serialized cache has the most recent items first
|
||||
for (let l = arr.length - 1; l >= 0; l--) {
|
||||
const hit = arr[l]
|
||||
const expiresAt = hit.e || 0
|
||||
if (expiresAt === 0)
|
||||
// the item was created without expiration in a non aged cache
|
||||
this.set(hit.k, hit.v)
|
||||
else {
|
||||
const maxAge = expiresAt - now
|
||||
// dont add already expired items
|
||||
if (maxAge > 0) {
|
||||
this.set(hit.k, hit.v, maxAge)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prune () {
|
||||
this[CACHE].forEach((value, key) => get(this, key, false))
|
||||
}
|
||||
}
|
||||
|
||||
const get = (self, key, doUse) => {
|
||||
const node = self[CACHE].get(key)
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
return undefined
|
||||
} else {
|
||||
if (doUse) {
|
||||
if (self[UPDATE_AGE_ON_GET])
|
||||
node.value.now = Date.now()
|
||||
self[LRU_LIST].unshiftNode(node)
|
||||
}
|
||||
}
|
||||
return hit.value
|
||||
}
|
||||
}
|
||||
|
||||
const isStale = (self, hit) => {
|
||||
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
||||
return false
|
||||
|
||||
const diff = Date.now() - hit.now
|
||||
return hit.maxAge ? diff > hit.maxAge
|
||||
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
||||
}
|
||||
|
||||
const trim = self => {
|
||||
if (self[LENGTH] > self[MAX]) {
|
||||
for (let walker = self[LRU_LIST].tail;
|
||||
self[LENGTH] > self[MAX] && walker !== null;) {
|
||||
// We know that we're about to delete this one, and also
|
||||
// what the next least recently used key will be, so just
|
||||
// go ahead and set it now.
|
||||
const prev = walker.prev
|
||||
del(self, walker)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const del = (self, node) => {
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (self[DISPOSE])
|
||||
self[DISPOSE](hit.key, hit.value)
|
||||
|
||||
self[LENGTH] -= hit.length
|
||||
self[CACHE].delete(hit.key)
|
||||
self[LRU_LIST].removeNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
class Entry {
|
||||
constructor (key, value, length, now, maxAge) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
this.length = length
|
||||
this.now = now
|
||||
this.maxAge = maxAge || 0
|
||||
}
|
||||
}
|
||||
|
||||
const forEachStep = (self, fn, node, thisp) => {
|
||||
let hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
hit = undefined
|
||||
}
|
||||
if (hit)
|
||||
fn.call(thisp, hit.value, hit.key, self)
|
||||
}
|
||||
|
||||
module.exports = LRUCache
|
||||
@@ -0,0 +1,211 @@
|
||||
# escalade [](https://github.com/lukeed/escalade/actions) [](https://licenses.dev/npm/escalade) [](https://codecov.io/gh/lukeed/escalade)
|
||||
|
||||
> A tiny (183B to 210B) and [fast](#benchmarks) utility to ascend parent directories
|
||||
|
||||
With [escalade](https://en.wikipedia.org/wiki/Escalade), you can scale parent directories until you've found what you're looking for.<br>Given an input file or directory, `escalade` will continue executing your callback function until either:
|
||||
|
||||
1) the callback returns a truthy value
|
||||
2) `escalade` has reached the system root directory (eg, `/`)
|
||||
|
||||
> **Important:**<br>Please note that `escalade` only deals with direct ancestry – it will not dive into parents' sibling directories.
|
||||
|
||||
---
|
||||
|
||||
**Notice:** As of v3.1.0, `escalade` now includes [Deno support](http://deno.land/x/escalade)! Please see [Deno Usage](#deno) below.
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save escalade
|
||||
```
|
||||
|
||||
|
||||
## Modes
|
||||
|
||||
There are two "versions" of `escalade` available:
|
||||
|
||||
#### "async"
|
||||
> **Node.js:** >= 8.x<br>
|
||||
> **Size (gzip):** 210 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/escalade/dist/index.js), [ES Module](https://unpkg.com/escalade/dist/index.mjs)
|
||||
|
||||
This is the primary/default mode. It makes use of `async`/`await` and [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original).
|
||||
|
||||
#### "sync"
|
||||
> **Node.js:** >= 6.x<br>
|
||||
> **Size (gzip):** 183 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/escalade/sync/index.js), [ES Module](https://unpkg.com/escalade/sync/index.mjs)
|
||||
|
||||
This is the opt-in mode, ideal for scenarios where `async` usage cannot be supported.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
***Example Structure***
|
||||
|
||||
```
|
||||
/Users/lukeed
|
||||
└── oss
|
||||
├── license
|
||||
└── escalade
|
||||
├── package.json
|
||||
└── test
|
||||
└── fixtures
|
||||
├── index.js
|
||||
└── foobar
|
||||
└── demo.js
|
||||
```
|
||||
|
||||
***Example Usage***
|
||||
|
||||
```js
|
||||
//~> demo.js
|
||||
import { join } from 'path';
|
||||
import escalade from 'escalade';
|
||||
|
||||
const input = join(__dirname, 'demo.js');
|
||||
// or: const input = __dirname;
|
||||
|
||||
const pkg = await escalade(input, (dir, names) => {
|
||||
console.log('~> dir:', dir);
|
||||
console.log('~> names:', names);
|
||||
console.log('---');
|
||||
|
||||
if (names.includes('package.json')) {
|
||||
// will be resolved into absolute
|
||||
return 'package.json';
|
||||
}
|
||||
});
|
||||
|
||||
//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar
|
||||
//~> names: ['demo.js']
|
||||
//---
|
||||
//~> dir: /Users/lukeed/oss/escalade/test/fixtures
|
||||
//~> names: ['index.js', 'foobar']
|
||||
//---
|
||||
//~> dir: /Users/lukeed/oss/escalade/test
|
||||
//~> names: ['fixtures']
|
||||
//---
|
||||
//~> dir: /Users/lukeed/oss/escalade
|
||||
//~> names: ['package.json', 'test']
|
||||
//---
|
||||
|
||||
console.log(pkg);
|
||||
//=> /Users/lukeed/oss/escalade/package.json
|
||||
|
||||
// Now search for "missing123.txt"
|
||||
// (Assume it doesn't exist anywhere!)
|
||||
const missing = await escalade(input, (dir, names) => {
|
||||
console.log('~> dir:', dir);
|
||||
return names.includes('missing123.txt') && 'missing123.txt';
|
||||
});
|
||||
|
||||
//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar
|
||||
//~> dir: /Users/lukeed/oss/escalade/test/fixtures
|
||||
//~> dir: /Users/lukeed/oss/escalade/test
|
||||
//~> dir: /Users/lukeed/oss/escalade
|
||||
//~> dir: /Users/lukeed/oss
|
||||
//~> dir: /Users/lukeed
|
||||
//~> dir: /Users
|
||||
//~> dir: /
|
||||
|
||||
console.log(missing);
|
||||
//=> undefined
|
||||
```
|
||||
|
||||
> **Note:** To run the above example with "sync" mode, import from `escalade/sync` and remove the `await` keyword.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### escalade(input, callback)
|
||||
Returns: `string|void` or `Promise<string|void>`
|
||||
|
||||
When your `callback` locates a file, `escalade` will resolve/return with an absolute path.<br>
|
||||
If your `callback` was never satisfied, then `escalade` will resolve/return with nothing (undefined).
|
||||
|
||||
> **Important:**<br>The `sync` and `async` versions share the same API.<br>The **only** difference is that `sync` is not Promise-based.
|
||||
|
||||
#### input
|
||||
Type: `string`
|
||||
|
||||
The path from which to start ascending.
|
||||
|
||||
This may be a file or a directory path.<br>However, when `input` is a file, `escalade` will begin with its parent directory.
|
||||
|
||||
> **Important:** Unless given an absolute path, `input` will be resolved from `process.cwd()` location.
|
||||
|
||||
#### callback
|
||||
Type: `Function`
|
||||
|
||||
The callback to execute for each ancestry level. It always is given two arguments:
|
||||
|
||||
1) `dir` - an absolute path of the current parent directory
|
||||
2) `names` - a list (`string[]`) of contents _relative to_ the `dir` parent
|
||||
|
||||
> **Note:** The `names` list can contain names of files _and_ directories.
|
||||
|
||||
When your callback returns a _falsey_ value, then `escalade` will continue with `dir`'s parent directory, re-invoking your callback with new argument values.
|
||||
|
||||
When your callback returns a string, then `escalade` stops iteration immediately.<br>
|
||||
If the string is an absolute path, then it's left as is. Otherwise, the string is resolved into an absolute path _from_ the `dir` that housed the satisfying condition.
|
||||
|
||||
> **Important:** Your `callback` can be a `Promise/AsyncFunction` when using the "async" version of `escalade`.
|
||||
|
||||
## Benchmarks
|
||||
|
||||
> Running on Node.js v10.13.0
|
||||
|
||||
```
|
||||
# Load Time
|
||||
find-up 3.891ms
|
||||
escalade 0.485ms
|
||||
escalade/sync 0.309ms
|
||||
|
||||
# Levels: 6 (target = "foo.txt"):
|
||||
find-up x 24,856 ops/sec ±6.46% (55 runs sampled)
|
||||
escalade x 73,084 ops/sec ±4.23% (73 runs sampled)
|
||||
find-up.sync x 3,663 ops/sec ±1.12% (83 runs sampled)
|
||||
escalade/sync x 9,360 ops/sec ±0.62% (88 runs sampled)
|
||||
|
||||
# Levels: 12 (target = "package.json"):
|
||||
find-up x 29,300 ops/sec ±10.68% (70 runs sampled)
|
||||
escalade x 73,685 ops/sec ± 5.66% (66 runs sampled)
|
||||
find-up.sync x 1,707 ops/sec ± 0.58% (91 runs sampled)
|
||||
escalade/sync x 4,667 ops/sec ± 0.68% (94 runs sampled)
|
||||
|
||||
# Levels: 18 (target = "missing123.txt"):
|
||||
find-up x 21,818 ops/sec ±17.37% (14 runs sampled)
|
||||
escalade x 67,101 ops/sec ±21.60% (20 runs sampled)
|
||||
find-up.sync x 1,037 ops/sec ± 2.86% (88 runs sampled)
|
||||
escalade/sync x 1,248 ops/sec ± 0.50% (93 runs sampled)
|
||||
```
|
||||
|
||||
## Deno
|
||||
|
||||
As of v3.1.0, `escalade` is available on the Deno registry.
|
||||
|
||||
Please note that the [API](#api) is identical and that there are still [two modes](#modes) from which to choose:
|
||||
|
||||
```ts
|
||||
// Choose "async" mode
|
||||
import escalade from 'https://deno.land/escalade/async.ts';
|
||||
|
||||
// Choose "sync" mode
|
||||
import escalade from 'https://deno.land/escalade/sync.ts';
|
||||
```
|
||||
|
||||
> **Important:** The `allow-read` permission is required!
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [premove](https://github.com/lukeed/premove) - A tiny (247B) utility to remove items recursively
|
||||
- [totalist](https://github.com/lukeed/totalist) - A tiny (195B to 224B) utility to recursively list all (total) files in a directory
|
||||
- [mk-dirs](https://github.com/lukeed/mk-dirs) - A tiny (420B) utility to make a directory and its parents, recursively
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
||||
"description": "Meta-schema for $data reference (JSON Schema extension proposal)",
|
||||
"type": "object",
|
||||
"required": [ "$data" ],
|
||||
"properties": {
|
||||
"$data": {
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{ "format": "relative-json-pointer" },
|
||||
{ "format": "json-pointer" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export declare function ScrollRestoration(): import("react/jsx-runtime").JSX.Element | null;
|
||||
@@ -0,0 +1,261 @@
|
||||
[](https://www.npmjs.com/package/espree)
|
||||
[](https://www.npmjs.com/package/espree)
|
||||
[](https://github.com/js/espree/actions)
|
||||
[](https://www.bountysource.com/trackers/9348450-eslint?utm_source=9348450&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||
|
||||
# Espree
|
||||
|
||||
Espree started out as a fork of [Esprima](http://esprima.org) v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree is now built on top of [Acorn](https://github.com/ternjs/acorn), which has a modular architecture that allows extension of core functionality. The goal of Espree is to produce output that is similar to Esprima with a similar API so that it can be used in place of Esprima.
|
||||
|
||||
## Usage
|
||||
|
||||
Install:
|
||||
|
||||
```
|
||||
npm i espree
|
||||
```
|
||||
|
||||
To use in an ESM file:
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
To use in a Common JS file:
|
||||
|
||||
```js
|
||||
const espree = require("espree");
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `parse()`
|
||||
|
||||
`parse` parses the given code and returns a abstract syntax tree (AST). It takes two parameters.
|
||||
|
||||
- `code` [string]() - the code which needs to be parsed.
|
||||
- `options (Optional)` [Object]() - read more about this [here](#options).
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const ast = espree.parse(code);
|
||||
```
|
||||
|
||||
**Example :**
|
||||
|
||||
```js
|
||||
const ast = espree.parse('let foo = "bar"', { ecmaVersion: 6 });
|
||||
console.log(ast);
|
||||
```
|
||||
|
||||
<details><summary>Output</summary>
|
||||
<p>
|
||||
|
||||
```
|
||||
Node {
|
||||
type: 'Program',
|
||||
start: 0,
|
||||
end: 15,
|
||||
body: [
|
||||
Node {
|
||||
type: 'VariableDeclaration',
|
||||
start: 0,
|
||||
end: 15,
|
||||
declarations: [Array],
|
||||
kind: 'let'
|
||||
}
|
||||
],
|
||||
sourceType: 'script'
|
||||
}
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
### `tokenize()`
|
||||
|
||||
`tokenize` returns the tokens of a given code. It takes two parameters.
|
||||
|
||||
- `code` [string]() - the code which needs to be parsed.
|
||||
- `options (Optional)` [Object]() - read more about this [here](#options).
|
||||
|
||||
Even if `options` is empty or undefined or `options.tokens` is `false`, it assigns it to `true` in order to get the `tokens` array
|
||||
|
||||
**Example :**
|
||||
|
||||
```js
|
||||
import * as espree from "espree";
|
||||
|
||||
const tokens = espree.tokenize('let foo = "bar"', { ecmaVersion: 6 });
|
||||
console.log(tokens);
|
||||
```
|
||||
|
||||
<details><summary>Output</summary>
|
||||
<p>
|
||||
|
||||
```
|
||||
Token { type: 'Keyword', value: 'let', start: 0, end: 3 },
|
||||
Token { type: 'Identifier', value: 'foo', start: 4, end: 7 },
|
||||
Token { type: 'Punctuator', value: '=', start: 8, end: 9 },
|
||||
Token { type: 'String', value: '"bar"', start: 10, end: 15 }
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
### `version`
|
||||
|
||||
Returns the current `espree` version
|
||||
|
||||
### `VisitorKeys`
|
||||
|
||||
Returns all visitor keys for traversing the AST from [eslint-visitor-keys](https://github.com/eslint/js/tree/main/packages/eslint-visitor-keys)
|
||||
|
||||
### `latestEcmaVersion`
|
||||
|
||||
Returns the latest ECMAScript supported by `espree`
|
||||
|
||||
### `supportedEcmaVersions`
|
||||
|
||||
Returns an array of all supported ECMAScript versions
|
||||
|
||||
## Options
|
||||
|
||||
```js
|
||||
const options = {
|
||||
// attach range information to each node
|
||||
range: false,
|
||||
|
||||
// attach line/column location information to each node
|
||||
loc: false,
|
||||
|
||||
// create a top-level comments array containing all comments
|
||||
comment: false,
|
||||
|
||||
// create a top-level tokens array containing all tokens
|
||||
tokens: false,
|
||||
|
||||
// Set to 3, 5 (the default), 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 or 16 to specify the version of ECMAScript syntax you want to use.
|
||||
// You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), 2023 (same as 14), 2024 (same as 15) or 2025 (same as 16) to use the year-based naming.
|
||||
// You can also set "latest" to use the most recently supported version.
|
||||
ecmaVersion: 3,
|
||||
|
||||
allowReserved: true, // only allowed when ecmaVersion is 3
|
||||
|
||||
// specify which type of script you're parsing ("script", "module", or "commonjs")
|
||||
sourceType: "script",
|
||||
|
||||
// specify additional language features
|
||||
ecmaFeatures: {
|
||||
|
||||
// enable JSX parsing
|
||||
jsx: false,
|
||||
|
||||
// enable return in global scope (set to true automatically when sourceType is "commonjs")
|
||||
globalReturn: false,
|
||||
|
||||
// enable implied strict mode (if ecmaVersion >= 5)
|
||||
impliedStrict: false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Esprima Compatibility Going Forward
|
||||
|
||||
The primary goal is to produce the exact same AST structure and tokens as Esprima, and that takes precedence over anything else. (The AST structure being the [ESTree](https://github.com/estree/estree) API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same.
|
||||
|
||||
Espree may also deviate from Esprima in the interface it exposes.
|
||||
|
||||
## Contributing
|
||||
|
||||
Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/js/issues).
|
||||
|
||||
Espree is licensed under a permissive BSD 2-clause license.
|
||||
|
||||
## Security Policy
|
||||
|
||||
We work hard to ensure that Espree is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
|
||||
|
||||
## Build Commands
|
||||
|
||||
* `npm test` - run all tests
|
||||
* `npm run lint` - run all linting
|
||||
|
||||
## Differences from Espree 2.x
|
||||
|
||||
* The `tokenize()` method does not use `ecmaFeatures`. Any string will be tokenized completely based on ECMAScript 6 semantics.
|
||||
* Trailing whitespace no longer is counted as part of a node.
|
||||
* `let` and `const` declarations are no longer parsed by default. You must opt-in by using an `ecmaVersion` newer than `5` or setting `sourceType` to `module`.
|
||||
* The `esparse` and `esvalidate` binary scripts have been removed.
|
||||
* There is no `tolerant` option. We will investigate adding this back in the future.
|
||||
|
||||
## Known Incompatibilities
|
||||
|
||||
In an effort to help those wanting to transition from other parsers to Espree, the following is a list of noteworthy incompatibilities with other parsers. These are known differences that we do not intend to change.
|
||||
|
||||
### Esprima 1.2.2
|
||||
|
||||
* Esprima counts trailing whitespace as part of each AST node while Espree does not. In Espree, the end of a node is where the last token occurs.
|
||||
* Espree does not parse `let` and `const` declarations by default.
|
||||
* Error messages returned for parsing errors are different.
|
||||
* There are two addition properties on every node and token: `start` and `end`. These represent the same data as `range` and are used internally by Acorn.
|
||||
|
||||
### Esprima 2.x
|
||||
|
||||
* Esprima 2.x uses a different comment attachment algorithm that results in some comments being added in different places than Espree. The algorithm Espree uses is the same one used in Esprima 1.2.2.
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### Why another parser
|
||||
|
||||
[ESLint](http://eslint.org) had been relying on Esprima as its parser from the beginning. While that was fine when the JavaScript language was evolving slowly, the pace of development increased dramatically and Esprima had fallen behind. ESLint, like many other tools reliant on Esprima, has been stuck in using new JavaScript language features until Esprima updates, and that caused our users frustration.
|
||||
|
||||
We decided the only way for us to move forward was to create our own parser, bringing us inline with JSHint and JSLint, and allowing us to keep implementing new features as we need them. We chose to fork Esprima instead of starting from scratch in order to move as quickly as possible with a compatible API.
|
||||
|
||||
With Espree 2.0.0, we are no longer a fork of Esprima but rather a translation layer between Acorn and Esprima syntax. This allows us to put work back into a community-supported parser (Acorn) that is continuing to grow and evolve while maintaining an Esprima-compatible parser for those utilities still built on Esprima.
|
||||
|
||||
### Have you tried working with Esprima?
|
||||
|
||||
Yes. Since the start of ESLint, we've regularly filed bugs and feature requests with Esprima and will continue to do so. However, there are some different philosophies around how the projects work that need to be worked through. The initial goal was to have Espree track Esprima and eventually merge the two back together, but we ultimately decided that building on top of Acorn was a better choice due to Acorn's plugin support.
|
||||
|
||||
### Why don't you just use Acorn?
|
||||
|
||||
Acorn is a great JavaScript parser that produces an AST that is compatible with Esprima. Unfortunately, ESLint relies on more than just the AST to do its job. It relies on Esprima's tokens and comment attachment features to get a complete picture of the source code. We investigated switching to Acorn, but the inconsistencies between Esprima and Acorn created too much work for a project like ESLint.
|
||||
|
||||
We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better.
|
||||
|
||||
### What ECMAScript features do you support?
|
||||
|
||||
Espree supports all ECMAScript 2024 features and partially supports ECMAScript 2025 features.
|
||||
|
||||
Because ECMAScript 2025 is still under development, we are implementing features as they are finalized. Currently, Espree supports:
|
||||
|
||||
* [RegExp Duplicate named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups)
|
||||
|
||||
See [finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md) to know what features are finalized.
|
||||
|
||||
### How do you determine which experimental features to support?
|
||||
|
||||
In general, we do not support experimental JavaScript features. We may make exceptions from time to time depending on the maturity of the features.
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
||||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
@@ -0,0 +1,4 @@
|
||||
var x=String;
|
||||
var create=function() {return {isColorSupported:false,reset:x,bold:x,dim:x,italic:x,underline:x,inverse:x,hidden:x,strikethrough:x,black:x,red:x,green:x,yellow:x,blue:x,magenta:x,cyan:x,white:x,gray:x,bgBlack:x,bgRed:x,bgGreen:x,bgYellow:x,bgBlue:x,bgMagenta:x,bgCyan:x,bgWhite:x,blackBright:x,redBright:x,greenBright:x,yellowBright:x,blueBright:x,magentaBright:x,cyanBright:x,whiteBright:x,bgBlackBright:x,bgRedBright:x,bgGreenBright:x,bgYellowBright:x,bgBlueBright:x,bgMagentaBright:x,bgCyanBright:x,bgWhiteBright:x}};
|
||||
module.exports=create();
|
||||
module.exports.createColors = create;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["require","_utils","_placeholders","_deprecatedAliases","Object","keys","DEPRECATED_ALIASES","forEach","deprecatedAlias","FLIPPED_ALIAS_KEYS","types","set","allExpandedTypes","type","aliases","add","TYPES","exports","concat","VISITOR_KEYS","DEPRECATED_KEYS"],"sources":["../../src/definitions/index.ts"],"sourcesContent":["import \"./core.ts\";\nimport \"./flow.ts\";\nimport \"./jsx.ts\";\nimport \"./misc.ts\";\nimport \"./experimental.ts\";\nimport \"./typescript.ts\";\nimport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n allExpandedTypes,\n} from \"./utils.ts\";\nimport {\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n} from \"./placeholders.ts\";\nimport { DEPRECATED_ALIASES } from \"./deprecated-aliases.ts\";\n\n(\n Object.keys(DEPRECATED_ALIASES) as (keyof typeof DEPRECATED_ALIASES)[]\n).forEach(deprecatedAlias => {\n FLIPPED_ALIAS_KEYS[deprecatedAlias] =\n FLIPPED_ALIAS_KEYS[DEPRECATED_ALIASES[deprecatedAlias]];\n});\n\nfor (const { types, set } of allExpandedTypes) {\n for (const type of types) {\n const aliases = FLIPPED_ALIAS_KEYS[type];\n if (aliases) {\n aliases.forEach(set.add, set);\n } else {\n set.add(type);\n }\n }\n}\n\nconst TYPES: Array<string> = [].concat(\n Object.keys(VISITOR_KEYS),\n Object.keys(FLIPPED_ALIAS_KEYS),\n Object.keys(DEPRECATED_KEYS),\n);\n\nexport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_ALIASES,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n TYPES,\n};\n\nexport type { FieldOptions } from \"./utils.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,kBAAA,GAAAH,OAAA;AAGEI,MAAM,CAACC,IAAI,CAACC,qCAAkB,CAAC,CAC/BC,OAAO,CAACC,eAAe,IAAI;EAC3BC,yBAAkB,CAACD,eAAe,CAAC,GACjCC,yBAAkB,CAACH,qCAAkB,CAACE,eAAe,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,KAAK,MAAM;EAAEE,KAAK;EAAEC;AAAI,CAAC,IAAIC,uBAAgB,EAAE;EAC7C,KAAK,MAAMC,IAAI,IAAIH,KAAK,EAAE;IACxB,MAAMI,OAAO,GAAGL,yBAAkB,CAACI,IAAI,CAAC;IACxC,IAAIC,OAAO,EAAE;MACXA,OAAO,CAACP,OAAO,CAACI,GAAG,CAACI,GAAG,EAAEJ,GAAG,CAAC;IAC/B,CAAC,MAAM;MACLA,GAAG,CAACI,GAAG,CAACF,IAAI,CAAC;IACf;EACF;AACF;AAEA,MAAMG,KAAoB,GAAAC,OAAA,CAAAD,KAAA,GAAG,EAAE,CAACE,MAAM,CACpCd,MAAM,CAACC,IAAI,CAACc,mBAAY,CAAC,EACzBf,MAAM,CAACC,IAAI,CAACI,yBAAkB,CAAC,EAC/BL,MAAM,CAACC,IAAI,CAACe,sBAAe,CAC7B,CAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
'use client';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const react_1 = require("react");
|
||||
const outlineContext = (0, react_1.createContext)(null);
|
||||
exports.default = outlineContext;
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* @fileoverview The main file for the hfs package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
/** @typedef{import("@humanfs/types").HfsImpl} HfsImpl */
|
||||
/** @typedef{import("@humanfs/types").HfsDirectoryEntry} HfsDirectoryEntry */
|
||||
/**
|
||||
* Error to represent when a method is missing on an impl.
|
||||
*/
|
||||
export class NoSuchMethodError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} methodName The name of the method that was missing.
|
||||
*/
|
||||
constructor(methodName: string);
|
||||
}
|
||||
/**
|
||||
* Error to represent when an impl is already set.
|
||||
*/
|
||||
export class ImplAlreadySetError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
/**
|
||||
* A class representing a log entry.
|
||||
*/
|
||||
export class LogEntry {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} type The type of log entry.
|
||||
* @param {any} [data] The data associated with the log entry.
|
||||
*/
|
||||
constructor(type: string, data?: any);
|
||||
/**
|
||||
* The time at which the log entry was created.
|
||||
* @type {number}
|
||||
*/
|
||||
timestamp: number;
|
||||
methodName: string;
|
||||
data: any;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class representing a file system utility library.
|
||||
* @implements {HfsImpl}
|
||||
*/
|
||||
export class Hfs implements HfsImpl {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {object} options The options for the instance.
|
||||
* @param {HfsImpl} options.impl The implementation to use.
|
||||
*/
|
||||
constructor({ impl }: {
|
||||
impl: HfsImpl;
|
||||
});
|
||||
/**
|
||||
* Starts a new log with the given name.
|
||||
* @param {string} name The name of the log to start;
|
||||
* @returns {void}
|
||||
* @throws {Error} When the log already exists.
|
||||
* @throws {TypeError} When the name is not a non-empty string.
|
||||
*/
|
||||
logStart(name: string): void;
|
||||
/**
|
||||
* Ends a log with the given name and returns the entries.
|
||||
* @param {string} name The name of the log to end.
|
||||
* @returns {Array<LogEntry>} The entries in the log.
|
||||
* @throws {Error} When the log does not exist.
|
||||
*/
|
||||
logEnd(name: string): Array<LogEntry>;
|
||||
/**
|
||||
* Determines if the current implementation is the base implementation.
|
||||
* @returns {boolean} True if the current implementation is the base implementation.
|
||||
*/
|
||||
isBaseImpl(): boolean;
|
||||
/**
|
||||
* Sets the implementation for this instance.
|
||||
* @param {object} impl The implementation to use.
|
||||
* @returns {void}
|
||||
*/
|
||||
setImpl(impl: object): void;
|
||||
/**
|
||||
* Resets the implementation for this instance back to its original.
|
||||
* @returns {void}
|
||||
*/
|
||||
resetImpl(): void;
|
||||
/**
|
||||
* Reads the given file and returns the contents as text. Assumes UTF-8 encoding.
|
||||
* @param {string} filePath The file to read.
|
||||
* @returns {Promise<string|undefined>} The contents of the file.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
text(filePath: string): Promise<string | undefined>;
|
||||
/**
|
||||
* Reads the given file and returns the contents as JSON. Assumes UTF-8 encoding.
|
||||
* @param {string} filePath The file to read.
|
||||
* @returns {Promise<any|undefined>} The contents of the file as JSON.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {SyntaxError} When the file contents are not valid JSON.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
json(filePath: string): Promise<any | undefined>;
|
||||
/**
|
||||
* Reads the given file and returns the contents as an ArrayBuffer.
|
||||
* @param {string} filePath The file to read.
|
||||
* @returns {Promise<ArrayBuffer|undefined>} The contents of the file as an ArrayBuffer.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
* @deprecated Use bytes() instead.
|
||||
*/
|
||||
arrayBuffer(filePath: string): Promise<ArrayBuffer | undefined>;
|
||||
/**
|
||||
* Reads the given file and returns the contents as an Uint8Array.
|
||||
* @param {string} filePath The file to read.
|
||||
* @returns {Promise<Uint8Array|undefined>} The contents of the file as an Uint8Array.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
bytes(filePath: string): Promise<Uint8Array | undefined>;
|
||||
/**
|
||||
* Writes the given data to the given file. Creates any necessary directories along the way.
|
||||
* If the data is a string, UTF-8 encoding is used.
|
||||
* @param {string} filePath The file to write.
|
||||
* @param {any} contents The data to write.
|
||||
* @returns {Promise<void>} A promise that resolves when the file is written.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
write(filePath: string, contents: any): Promise<void>;
|
||||
/**
|
||||
* Determines if the given file exists.
|
||||
* @param {string} filePath The file to check.
|
||||
* @returns {Promise<boolean>} True if the file exists.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
isFile(filePath: string): Promise<boolean>;
|
||||
/**
|
||||
* Determines if the given directory exists.
|
||||
* @param {string} dirPath The directory to check.
|
||||
* @returns {Promise<boolean>} True if the directory exists.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the directory path is not a non-empty string.
|
||||
*/
|
||||
isDirectory(dirPath: string): Promise<boolean>;
|
||||
/**
|
||||
* Creates the given directory.
|
||||
* @param {string} dirPath The directory to create.
|
||||
* @returns {Promise<void>} A promise that resolves when the directory is created.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the directory path is not a non-empty string.
|
||||
*/
|
||||
createDirectory(dirPath: string): Promise<void>;
|
||||
/**
|
||||
* Deletes the given file.
|
||||
* @param {string} filePath The file to delete.
|
||||
* @returns {Promise<void>} A promise that resolves when the file is deleted.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the file path is not a non-empty string.
|
||||
*/
|
||||
delete(filePath: string): Promise<void>;
|
||||
/**
|
||||
* Deletes the given directory.
|
||||
* @param {string} dirPath The directory to delete.
|
||||
* @returns {Promise<void>} A promise that resolves when the directory is deleted.
|
||||
* @throws {NoSuchMethodError} When the method does not exist on the current implementation.
|
||||
* @throws {TypeError} When the directory path is not a non-empty string.
|
||||
*/
|
||||
deleteAll(dirPath: string): Promise<void>;
|
||||
/**
|
||||
* Returns a list of directory entries for the given path.
|
||||
* @param {string} dirPath The path to the directory to read.
|
||||
* @returns {AsyncIterable<HfsDirectoryEntry>} A promise that resolves with the
|
||||
* directory entries.
|
||||
* @throws {TypeError} If the directory path is not a string.
|
||||
* @throws {Error} If the directory cannot be read.
|
||||
*/
|
||||
list(dirPath: string): AsyncIterable<HfsDirectoryEntry>;
|
||||
/**
|
||||
* Returns the size of the given file.
|
||||
* @param {string} filePath The path to the file to read.
|
||||
* @returns {Promise<number>} A promise that resolves with the size of the file.
|
||||
* @throws {TypeError} If the file path is not a string.
|
||||
* @throws {Error} If the file cannot be read.
|
||||
*/
|
||||
size(filePath: string): Promise<number>;
|
||||
#private;
|
||||
}
|
||||
export type HfsImpl = import("@humanfs/types").HfsImpl;
|
||||
export type HfsDirectoryEntry = import("@humanfs/types").HfsDirectoryEntry;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","_default","exports","default","createTypeAnnotationBasedOnTypeof","type","stringTypeAnnotation","numberTypeAnnotation","voidTypeAnnotation","booleanTypeAnnotation","genericTypeAnnotation","identifier","anyTypeAnnotation","Error"],"sources":["../../../src/builders/flow/createTypeAnnotationBasedOnTypeof.ts"],"sourcesContent":["import {\n anyTypeAnnotation,\n stringTypeAnnotation,\n numberTypeAnnotation,\n voidTypeAnnotation,\n booleanTypeAnnotation,\n genericTypeAnnotation,\n identifier,\n} from \"../generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\nexport default createTypeAnnotationBasedOnTypeof as {\n (type: \"string\"): t.StringTypeAnnotation;\n (type: \"number\"): t.NumberTypeAnnotation;\n (type: \"undefined\"): t.VoidTypeAnnotation;\n (type: \"boolean\"): t.BooleanTypeAnnotation;\n (type: \"function\"): t.GenericTypeAnnotation;\n (type: \"object\"): t.GenericTypeAnnotation;\n (type: \"symbol\"): t.GenericTypeAnnotation;\n (type: \"bigint\"): t.AnyTypeAnnotation;\n};\n\n/**\n * Create a type annotation based on typeof expression.\n */\nfunction createTypeAnnotationBasedOnTypeof(type: string): t.FlowType {\n switch (type) {\n case \"string\":\n return stringTypeAnnotation();\n case \"number\":\n return numberTypeAnnotation();\n case \"undefined\":\n return voidTypeAnnotation();\n case \"boolean\":\n return booleanTypeAnnotation();\n case \"function\":\n return genericTypeAnnotation(identifier(\"Function\"));\n case \"object\":\n return genericTypeAnnotation(identifier(\"Object\"));\n case \"symbol\":\n return genericTypeAnnotation(identifier(\"Symbol\"));\n case \"bigint\":\n // todo: use BigInt annotation when Flow supports BigInt\n // https://github.com/facebook/flow/issues/6639\n return anyTypeAnnotation();\n }\n throw new Error(\"Invalid typeof value: \" + type);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQ+B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhBC,iCAAiC;AAchD,SAASA,iCAAiCA,CAACC,IAAY,EAAc;EACnE,QAAQA,IAAI;IACV,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,WAAW;MACd,OAAO,IAAAC,yBAAkB,EAAC,CAAC;IAC7B,KAAK,SAAS;MACZ,OAAO,IAAAC,4BAAqB,EAAC,CAAC;IAChC,KAAK,UAAU;MACb,OAAO,IAAAC,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,UAAU,CAAC,CAAC;IACtD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MAGX,OAAO,IAAAC,wBAAiB,EAAC,CAAC;EAC9B;EACA,MAAM,IAAIC,KAAK,CAAC,wBAAwB,GAAGR,IAAI,CAAC;AAClD","ignoreList":[]}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"30":0.00478,"35":0.00478,"37":0.00478,"40":0.00478,"44":0.01433,"46":0.00478,"48":0.02865,"56":0.01433,"57":0.00478,"62":0.08595,"63":0.00478,"66":0.00478,"67":0.00478,"72":0.03343,"78":0.04775,"79":0.09073,"91":0.00478,"94":0.00478,"99":0.0382,"102":0.00955,"103":0.00478,"104":0.00478,"105":0.00478,"111":0.00478,"114":0.0382,"115":1.0123,"119":0.00955,"123":0.00478,"124":0.00478,"125":0.00478,"126":0.01433,"127":0.0573,"128":0.24353,"129":0.04298,"130":0.00478,"131":0.0191,"132":0.0191,"133":0.06208,"134":0.10028,"135":0.89293,"136":4.44075,"137":0.08595,_:"2 3 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 31 32 33 34 36 38 39 41 42 43 45 47 49 50 51 52 53 54 55 58 59 60 61 64 65 68 69 70 71 73 74 75 76 77 80 81 82 83 84 85 86 87 88 89 90 92 93 95 96 97 98 100 101 106 107 108 109 110 112 113 116 117 118 120 121 122 138 139 140 3.5 3.6"},D:{"34":0.00478,"42":0.01433,"43":0.00478,"49":0.00955,"51":0.00955,"58":0.02388,"62":0.0382,"64":0.00478,"67":0.00478,"70":0.00955,"71":0.00955,"72":0.00478,"74":0.0191,"76":0.00955,"78":0.00478,"79":0.0191,"80":0.0191,"81":0.00478,"84":0.02388,"86":0.01433,"87":0.08595,"88":0.00478,"89":0.00478,"92":0.00955,"95":0.00955,"96":0.0191,"97":0.00478,"98":0.00478,"99":0.00478,"100":0.00478,"101":0.00478,"102":0.01433,"103":0.09073,"104":0.00478,"105":0.02388,"106":0.00478,"107":0.00955,"108":0.00955,"109":1.48503,"110":0.00955,"111":0.0191,"114":0.0573,"115":0.01433,"116":0.18145,"117":0.00955,"118":0.00955,"119":0.0382,"120":0.09073,"121":0.0191,"122":0.0764,"123":0.06208,"124":0.12893,"125":0.16713,"126":0.18145,"127":0.15758,"128":0.2483,"129":0.14803,"130":0.1528,"131":0.53003,"132":0.71625,"133":6.73275,"134":14.15788,"135":0.00955,_:"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 35 36 37 38 39 40 41 44 45 46 47 48 50 52 53 54 55 56 57 59 60 61 63 65 66 68 69 73 75 77 83 85 90 91 93 94 112 113 136 137 138"},F:{"49":0.00478,"79":0.01433,"85":0.01433,"87":0.00478,"94":0.00478,"95":0.02388,"102":0.00478,"110":0.00478,"114":0.00955,"115":0.01433,"116":0.0573,"117":0.71625,_:"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 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 80 81 82 83 84 86 88 89 90 91 92 93 96 97 98 99 100 101 103 104 105 106 107 108 109 111 112 113 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.0382,"13":0.00478,"14":0.0191,"16":0.0191,"17":0.02865,"18":0.03343,"84":0.00955,"90":0.01433,"92":0.0764,"96":0.01433,"100":0.08595,"104":0.00478,"105":0.00955,"106":0.00478,"107":0.01433,"109":0.0191,"110":0.00478,"113":0.00955,"114":0.02865,"116":0.00478,"117":0.01433,"118":0.01433,"119":0.00478,"120":0.03343,"121":0.02388,"122":0.0191,"123":0.00478,"124":0.00478,"125":0.02388,"126":0.06685,"127":0.05253,"128":0.0382,"129":0.09073,"130":0.12893,"131":0.27218,"132":0.21965,"133":2.86978,"134":5.2716,_:"15 79 80 81 83 85 86 87 88 89 91 93 94 95 97 98 99 101 102 103 108 111 112 115"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 15.4 15.5 16.0 18.4","13.1":0.06685,"14.1":0.15758,"15.1":0.00955,"15.2-15.3":0.00955,"15.6":0.08118,"16.1":0.00478,"16.2":0.00955,"16.3":0.00955,"16.4":0.00478,"16.5":0.02388,"16.6":0.0573,"17.0":0.04298,"17.1":0.03343,"17.2":0.0955,"17.3":0.03343,"17.4":0.0191,"17.5":0.03343,"17.6":0.1337,"18.0":0.03343,"18.1":0.04298,"18.2":0.04775,"18.3":0.4775},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00124,"5.0-5.1":0,"6.0-6.1":0.00372,"7.0-7.1":0.00248,"8.1-8.4":0,"9.0-9.2":0.00186,"9.3":0.00868,"10.0-10.2":0.00062,"10.3":0.01426,"11.0-11.2":0.06574,"11.3-11.4":0.00434,"12.0-12.1":0.00248,"12.2-12.5":0.0614,"13.0-13.1":0.00124,"13.2":0.00186,"13.3":0.00248,"13.4-13.7":0.00868,"14.0-14.4":0.02171,"14.5-14.8":0.02605,"15.0-15.1":0.01426,"15.2-15.3":0.01426,"15.4":0.01737,"15.5":0.01985,"15.6-15.8":0.24436,"16.0":0.03473,"16.1":0.07132,"16.2":0.03721,"16.3":0.0645,"16.4":0.01426,"16.5":0.02667,"16.6-16.7":0.28964,"17.0":0.01737,"17.1":0.03101,"17.2":0.02357,"17.3":0.03287,"17.4":0.06574,"17.5":0.14637,"17.6-17.7":0.42484,"18.0":0.11908,"18.1":0.38949,"18.2":0.17428,"18.3":3.64248,"18.4":0.05396},P:{"21":0.07315,"22":0.1672,"23":0.05225,"24":0.1254,"25":0.1045,"26":0.17765,"27":0.5852,_:"4 20 5.0-5.4 6.2-6.4 8.2 9.2 10.1 12.0 13.0 14.0 17.0 18.0","7.2-7.4":0.0209,"11.1-11.2":0.01045,"15.0":0.01045,"16.0":0.01045,"19.0":0.0418},I:{"0":0.00521,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0.00001},K:{"0":0.52818,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.02388,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.11495},Q:{_:"14.9"},O:{"0":0.4598},H:{"0":0.01},L:{"0":45.413}};
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "pdfjs-dist",
|
||||
"version": "4.8.69",
|
||||
"main": "build/pdf.mjs",
|
||||
"types": "types/src/pdf.d.ts",
|
||||
"description": "Generic build of Mozilla's PDF.js library.",
|
||||
"keywords": [
|
||||
"Mozilla",
|
||||
"pdf",
|
||||
"pdf.js"
|
||||
],
|
||||
"homepage": "https://mozilla.github.io/pdf.js/",
|
||||
"bugs": "https://github.com/mozilla/pdf.js/issues",
|
||||
"license": "Apache-2.0",
|
||||
"optionalDependencies": {
|
||||
"canvas": "^3.0.0-rc2",
|
||||
"path2d": "^0.2.1"
|
||||
},
|
||||
"browser": {
|
||||
"canvas": false,
|
||||
"fs": false,
|
||||
"http": false,
|
||||
"https": false,
|
||||
"url": false
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mozilla/pdf.js.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
# 1.2.1
|
||||
- fix version
|
||||
|
||||
# 1.2.0
|
||||
- add `List.remove`
|
||||
- build with LiveScript 1.6.0
|
||||
- update dependencies
|
||||
- remove coverage calculation
|
||||
|
||||
# 1.1.2
|
||||
- add `Func.memoize`
|
||||
- fix `zip-all` and `zip-with-all` corner case (no input)
|
||||
- build with LiveScript 1.4.0
|
||||
|
||||
# 1.1.1
|
||||
- curry `unique-by`, `minimum-by`
|
||||
|
||||
# 1.1.0
|
||||
- added `List` functions: `maximum-by`, `minimum-by`, `unique-by`
|
||||
- added `List` functions: `at`, `elem-index`, `elem-indices`, `find-index`, `find-indices`
|
||||
- added `Str` functions: `capitalize`, `camelize`, `dasherize`
|
||||
- added `Func` function: `over` - eg. ``same-length = (==) `over` (.length)``
|
||||
- exported `Str.repeat` through main `prelude` object
|
||||
- fixed definition of `foldr` and `foldr1`, the new correct definition is backwards incompatible with the old, incorrect one
|
||||
- fixed issue with `fix`
|
||||
- improved code coverage
|
||||
|
||||
# 1.0.3
|
||||
- build browser versions
|
||||
|
||||
# 1.0.2
|
||||
- bug fix for `flatten` - slight change with bug fix, flattens arrays only, not array-like objects
|
||||
|
||||
# 1.0.1
|
||||
- bug fixes for `drop-while` and `take-while`
|
||||
|
||||
# 1.0.0
|
||||
* massive update - separated functions into separate modules
|
||||
* functions do not accept multiple types anymore - use different versions in their respective modules in some cases (eg. `Obj.map`), or use `chars` or `values` in other cases to transform into a list
|
||||
* objects are no longer transformed into functions, simply use `(obj.)` in LiveScript to do that
|
||||
* browser version now using browserify - use `prelude = require('prelude-ls')`
|
||||
* added `compact`, `split`, `flatten`, `difference`, `intersection`, `union`, `count-by`, `group-by`, `chars`, `unchars`, `apply`
|
||||
* added `lists-to-obj` which takes a list of keys and list of values and zips them up into an object, and the converse `obj-to-lists`
|
||||
* added `pairs-to-obj` which takes a list of pairs (2 element lists) and creates an object, and the converse `obj-to-pairs`
|
||||
* removed `cons`, `append` - use the concat operator
|
||||
* removed `compose` - use the compose operator
|
||||
* removed `obj-to-func` - use partially applied access (eg. `(obj.)`)
|
||||
* removed `length` - use `(.length)`
|
||||
* `sort-by` renamed to `sort-with`
|
||||
* added new `sort-by`
|
||||
* removed `compare` - just use the new `sort-by`
|
||||
* `break-it` renamed `break-list`, (`Str.break-str` for the string version)
|
||||
* added `Str.repeat` which creates a new string by repeating the input n times
|
||||
* `unfold` as alias to `unfoldr` is no longer used
|
||||
* fixed up style and compiled with LiveScript 1.1.1
|
||||
* use Make instead of Slake
|
||||
* greatly improved tests
|
||||
|
||||
# 0.6.0
|
||||
* fixed various bugs
|
||||
* added `fix`, a fixpoint (Y combinator) for anonymous recursive functions
|
||||
* added `unfoldr` (alias `unfold`)
|
||||
* calling `replicate` with a string now returns a list of strings
|
||||
* removed `partial`, just use native partial application in LiveScript using the `_` placeholder, or currying
|
||||
* added `sort`, `sortBy`, and `compare`
|
||||
|
||||
# 0.5.0
|
||||
* removed `lookup` - use (.prop)
|
||||
* removed `call` - use (.func arg1, arg2)
|
||||
* removed `pluck` - use map (.prop), xs
|
||||
* fixed buys wtih `head` and `last`
|
||||
* added non-minifed browser version, as `prelude-browser.js`
|
||||
* renamed `prelude-min.js` to `prelude-browser-min.js`
|
||||
* renamed `zip` to `zipAll`
|
||||
* renamed `zipWith` to `zipAllWith`
|
||||
* added `zip`, a curried zip that takes only two arguments
|
||||
* added `zipWith`, a curried zipWith that takes only two arguments
|
||||
|
||||
# 0.4.0
|
||||
* added `parition` function
|
||||
* added `curry` function
|
||||
* removed `elem` function (use `in`)
|
||||
* removed `notElem` function (use `not in`)
|
||||
|
||||
# 0.3.0
|
||||
* added `listToObject`
|
||||
* added `unique`
|
||||
* added `objToFunc`
|
||||
* added support for using strings in map and the like
|
||||
* added support for using objects in map and the like
|
||||
* added ability to use objects instead of functions in certain cases
|
||||
* removed `error` (just use throw)
|
||||
* added `tau` constant
|
||||
* added `join`
|
||||
* added `values`
|
||||
* added `keys`
|
||||
* added `partial`
|
||||
* renamed `log` to `ln`
|
||||
* added alias to `head`: `first`
|
||||
* added `installPrelude` helper
|
||||
|
||||
# 0.2.0
|
||||
* removed functions that simply warp operators as you can now use operators as functions in LiveScript
|
||||
* `min/max` are now curried and take only 2 arguments
|
||||
* added `call`
|
||||
|
||||
# 0.1.0
|
||||
* initial public release
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_classApplyDescriptorDestructureSet","receiver","descriptor","set","__destrObj","value","v","call","writable","TypeError"],"sources":["../../src/helpers/classApplyDescriptorDestructureSet.js"],"sourcesContent":["/* @minVersion 7.13.10 */\n/* @onlyBabel7 */\n\nexport default function _classApplyDescriptorDestructureSet(\n receiver,\n descriptor,\n) {\n if (descriptor.set) {\n if (!(\"__destrObj\" in descriptor)) {\n descriptor.__destrObj = {\n set value(v) {\n descriptor.set.call(receiver, v);\n },\n };\n }\n return descriptor.__destrObj;\n } else {\n if (!descriptor.writable) {\n // This should only throw in strict mode, but class bodies are\n // always strict and private fields can only be used inside\n // class bodies.\n throw new TypeError(\"attempted to set read only private field\");\n }\n\n return descriptor;\n }\n}\n"],"mappings":";;;;;;AAGe,SAASA,mCAAmCA,CACzDC,QAAQ,EACRC,UAAU,EACV;EACA,IAAIA,UAAU,CAACC,GAAG,EAAE;IAClB,IAAI,EAAE,YAAY,IAAID,UAAU,CAAC,EAAE;MACjCA,UAAU,CAACE,UAAU,GAAG;QACtB,IAAIC,KAAKA,CAACC,CAAC,EAAE;UACXJ,UAAU,CAACC,GAAG,CAACI,IAAI,CAACN,QAAQ,EAAEK,CAAC,CAAC;QAClC;MACF,CAAC;IACH;IACA,OAAOJ,UAAU,CAACE,UAAU;EAC9B,CAAC,MAAM;IACL,IAAI,CAACF,UAAU,CAACM,QAAQ,EAAE;MAIxB,MAAM,IAAIC,SAAS,CAAC,0CAA0C,CAAC;IACjE;IAEA,OAAOP,UAAU;EACnB;AACF","ignoreList":[]}
|
||||
@@ -0,0 +1,163 @@
|
||||
# detect-libc
|
||||
|
||||
Node.js module to detect details of the C standard library (libc)
|
||||
implementation provided by a given Linux system.
|
||||
|
||||
Currently supports detection of GNU glibc and MUSL libc.
|
||||
|
||||
Provides asychronous and synchronous functions for the
|
||||
family (e.g. `glibc`, `musl`) and version (e.g. `1.23`, `1.2.3`).
|
||||
|
||||
The version numbers of libc implementations
|
||||
are not guaranteed to be semver-compliant.
|
||||
|
||||
For previous v1.x releases, please see the
|
||||
[v1](https://github.com/lovell/detect-libc/tree/v1) branch.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install detect-libc
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### GLIBC
|
||||
|
||||
```ts
|
||||
const GLIBC: string = 'glibc';
|
||||
```
|
||||
|
||||
A String constant containing the value `glibc`.
|
||||
|
||||
### MUSL
|
||||
|
||||
```ts
|
||||
const MUSL: string = 'musl';
|
||||
```
|
||||
|
||||
A String constant containing the value `musl`.
|
||||
|
||||
### family
|
||||
|
||||
```ts
|
||||
function family(): Promise<string | null>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* `glibc` or `musl` when the libc family can be determined
|
||||
* `null` when the libc family cannot be determined
|
||||
* `null` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { family, GLIBC, MUSL } = require('detect-libc');
|
||||
|
||||
switch (await family()) {
|
||||
case GLIBC: ...
|
||||
case MUSL: ...
|
||||
case null: ...
|
||||
}
|
||||
```
|
||||
|
||||
### familySync
|
||||
|
||||
```ts
|
||||
function familySync(): string | null;
|
||||
```
|
||||
|
||||
Synchronous version of `family()`.
|
||||
|
||||
```js
|
||||
const { familySync, GLIBC, MUSL } = require('detect-libc');
|
||||
|
||||
switch (familySync()) {
|
||||
case GLIBC: ...
|
||||
case MUSL: ...
|
||||
case null: ...
|
||||
}
|
||||
```
|
||||
|
||||
### version
|
||||
|
||||
```ts
|
||||
function version(): Promise<string | null>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* The version when it can be determined
|
||||
* `null` when the libc family cannot be determined
|
||||
* `null` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { version } = require('detect-libc');
|
||||
|
||||
const v = await version();
|
||||
if (v) {
|
||||
const [major, minor, patch] = v.split('.');
|
||||
}
|
||||
```
|
||||
|
||||
### versionSync
|
||||
|
||||
```ts
|
||||
function versionSync(): string | null;
|
||||
```
|
||||
|
||||
Synchronous version of `version()`.
|
||||
|
||||
```js
|
||||
const { versionSync } = require('detect-libc');
|
||||
|
||||
const v = versionSync();
|
||||
if (v) {
|
||||
const [major, minor, patch] = v.split('.');
|
||||
}
|
||||
```
|
||||
|
||||
### isNonGlibcLinux
|
||||
|
||||
```ts
|
||||
function isNonGlibcLinux(): Promise<boolean>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* `false` when the libc family is `glibc`
|
||||
* `true` when the libc family is not `glibc`
|
||||
* `false` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { isNonGlibcLinux } = require('detect-libc');
|
||||
|
||||
if (await isNonGlibcLinux()) { ... }
|
||||
```
|
||||
|
||||
### isNonGlibcLinuxSync
|
||||
|
||||
```ts
|
||||
function isNonGlibcLinuxSync(): boolean;
|
||||
```
|
||||
|
||||
Synchronous version of `isNonGlibcLinux()`.
|
||||
|
||||
```js
|
||||
const { isNonGlibcLinuxSync } = require('detect-libc');
|
||||
|
||||
if (isNonGlibcLinuxSync()) { ... }
|
||||
```
|
||||
|
||||
## Licensing
|
||||
|
||||
Copyright 2017 Lovell Fuller and others.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow duplicate conditions in if-else-if chains
|
||||
* @author Milos Djermanovic
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines whether the first given array is a subset of the second given array.
|
||||
* @param {Function} comparator A function to compare two elements, should return `true` if they are equal.
|
||||
* @param {Array} arrA The array to compare from.
|
||||
* @param {Array} arrB The array to compare against.
|
||||
* @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
|
||||
*/
|
||||
function isSubsetByComparator(comparator, arrA, arrB) {
|
||||
return arrA.every(a => arrB.some(b => comparator(a, b)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the given node by the given logical operator.
|
||||
* @param {string} operator Logical operator `||` or `&&`.
|
||||
* @param {ASTNode} node The node to split.
|
||||
* @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
|
||||
*/
|
||||
function splitByLogicalOperator(operator, node) {
|
||||
if (node.type === "LogicalExpression" && node.operator === operator) {
|
||||
return [
|
||||
...splitByLogicalOperator(operator, node.left),
|
||||
...splitByLogicalOperator(operator, node.right),
|
||||
];
|
||||
}
|
||||
return [node];
|
||||
}
|
||||
|
||||
const splitByOr = splitByLogicalOperator.bind(null, "||");
|
||||
const splitByAnd = splitByLogicalOperator.bind(null, "&&");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow duplicate conditions in if-else-if chains",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-dupe-else-if",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected:
|
||||
"This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
|
||||
* represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
|
||||
* @param {ASTNode} a First node.
|
||||
* @param {ASTNode} b Second node.
|
||||
* @returns {boolean} `true` if the nodes are considered to be equal.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
if (a.type !== b.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
a.type === "LogicalExpression" &&
|
||||
(a.operator === "||" || a.operator === "&&") &&
|
||||
a.operator === b.operator
|
||||
) {
|
||||
return (
|
||||
(equal(a.left, b.left) && equal(a.right, b.right)) ||
|
||||
(equal(a.left, b.right) && equal(a.right, b.left))
|
||||
);
|
||||
}
|
||||
|
||||
return astUtils.equalTokens(a, b, sourceCode);
|
||||
}
|
||||
|
||||
const isSubset = isSubsetByComparator.bind(null, equal);
|
||||
|
||||
return {
|
||||
IfStatement(node) {
|
||||
const test = node.test,
|
||||
conditionsToCheck =
|
||||
test.type === "LogicalExpression" &&
|
||||
test.operator === "&&"
|
||||
? [test, ...splitByAnd(test)]
|
||||
: [test];
|
||||
let current = node,
|
||||
listToCheck = conditionsToCheck.map(c =>
|
||||
splitByOr(c).map(splitByAnd),
|
||||
);
|
||||
|
||||
while (
|
||||
current.parent &&
|
||||
current.parent.type === "IfStatement" &&
|
||||
current.parent.alternate === current
|
||||
) {
|
||||
current = current.parent;
|
||||
|
||||
const currentOrOperands = splitByOr(current.test).map(
|
||||
splitByAnd,
|
||||
);
|
||||
|
||||
listToCheck = listToCheck.map(orOperands =>
|
||||
orOperands.filter(
|
||||
orOperand =>
|
||||
!currentOrOperands.some(currentOrOperand =>
|
||||
isSubset(currentOrOperand, orOperand),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (
|
||||
listToCheck.some(orOperands => orOperands.length === 0)
|
||||
) {
|
||||
context.report({ node: test, messageId: "unexpected" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
// Standard YAML's Core schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
//
|
||||
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||
// So, Core schema has no distinctions from JSON schema is JS-YAML.
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
module.exports = require('./json');
|
||||
@@ -0,0 +1,7 @@
|
||||
import { AnySchema } from './validators.cjs';
|
||||
export declare const defaultParseSearch: (searchStr: string) => AnySchema;
|
||||
export declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
||||
export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySchema;
|
||||
export declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;
|
||||
export type SearchSerializer = (searchObj: Record<string, any>) => string;
|
||||
export type SearchParser = (searchStr: string) => Record<string, any>;
|
||||
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"types": {
|
||||
"problem": [],
|
||||
"suggestion": [],
|
||||
"layout": []
|
||||
},
|
||||
"deprecated": [],
|
||||
"removed": [
|
||||
{
|
||||
"removed": "generator-star",
|
||||
"replacedBy": [{ "rule": { "name": "generator-star-spacing" } }]
|
||||
},
|
||||
{
|
||||
"removed": "global-strict",
|
||||
"replacedBy": [{ "rule": { "name": "strict" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-arrow-condition",
|
||||
"replacedBy": [
|
||||
{ "rule": { "name": "no-confusing-arrow" } },
|
||||
{ "rule": { "name": "no-constant-condition" } }
|
||||
]
|
||||
},
|
||||
{
|
||||
"removed": "no-comma-dangle",
|
||||
"replacedBy": [{ "rule": { "name": "comma-dangle" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-empty-class",
|
||||
"replacedBy": [{ "rule": { "name": "no-empty-character-class" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-empty-label",
|
||||
"replacedBy": [{ "rule": { "name": "no-labels" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-extra-strict",
|
||||
"replacedBy": [{ "rule": { "name": "strict" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-reserved-keys",
|
||||
"replacedBy": [{ "rule": { "name": "quote-props" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-space-before-semi",
|
||||
"replacedBy": [{ "rule": { "name": "semi-spacing" } }]
|
||||
},
|
||||
{
|
||||
"removed": "no-wrap-func",
|
||||
"replacedBy": [{ "rule": { "name": "no-extra-parens" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-after-function-name",
|
||||
"replacedBy": [{ "rule": { "name": "space-before-function-paren" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-after-keywords",
|
||||
"replacedBy": [{ "rule": { "name": "keyword-spacing" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-before-function-parentheses",
|
||||
"replacedBy": [{ "rule": { "name": "space-before-function-paren" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-before-keywords",
|
||||
"replacedBy": [{ "rule": { "name": "keyword-spacing" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-in-brackets",
|
||||
"replacedBy": [
|
||||
{ "rule": { "name": "object-curly-spacing" } },
|
||||
{ "rule": { "name": "array-bracket-spacing" } }
|
||||
]
|
||||
},
|
||||
{
|
||||
"removed": "space-return-throw-case",
|
||||
"replacedBy": [{ "rule": { "name": "keyword-spacing" } }]
|
||||
},
|
||||
{
|
||||
"removed": "space-unary-word-ops",
|
||||
"replacedBy": [{ "rule": { "name": "space-unary-ops" } }]
|
||||
},
|
||||
{
|
||||
"removed": "spaced-line-comment",
|
||||
"replacedBy": [{ "rule": { "name": "spaced-comment" } }]
|
||||
},
|
||||
{ "removed": "valid-jsdoc", "replacedBy": [] },
|
||||
{ "removed": "require-jsdoc", "replacedBy": [] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/* Copyright 2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import invariant from 'tiny-invariant';
|
||||
const DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
|
||||
export default class LinkService {
|
||||
constructor() {
|
||||
this.externalLinkEnabled = true;
|
||||
this.externalLinkRel = undefined;
|
||||
this.externalLinkTarget = undefined;
|
||||
this.isInPresentationMode = false;
|
||||
this.pdfDocument = undefined;
|
||||
this.pdfViewer = undefined;
|
||||
}
|
||||
setDocument(pdfDocument) {
|
||||
this.pdfDocument = pdfDocument;
|
||||
}
|
||||
setViewer(pdfViewer) {
|
||||
this.pdfViewer = pdfViewer;
|
||||
}
|
||||
setExternalLinkRel(externalLinkRel) {
|
||||
this.externalLinkRel = externalLinkRel;
|
||||
}
|
||||
setExternalLinkTarget(externalLinkTarget) {
|
||||
this.externalLinkTarget = externalLinkTarget;
|
||||
}
|
||||
setHistory() {
|
||||
// Intentionally empty
|
||||
}
|
||||
get pagesCount() {
|
||||
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
||||
}
|
||||
get page() {
|
||||
invariant(this.pdfViewer, 'PDF viewer is not initialized.');
|
||||
return this.pdfViewer.currentPageNumber || 0;
|
||||
}
|
||||
set page(value) {
|
||||
invariant(this.pdfViewer, 'PDF viewer is not initialized.');
|
||||
this.pdfViewer.currentPageNumber = value;
|
||||
}
|
||||
get rotation() {
|
||||
return 0;
|
||||
}
|
||||
set rotation(_value) {
|
||||
// Intentionally empty
|
||||
}
|
||||
goToDestination(dest) {
|
||||
return new Promise((resolve) => {
|
||||
invariant(this.pdfDocument, 'PDF document not loaded.');
|
||||
invariant(dest, 'Destination is not specified.');
|
||||
if (typeof dest === 'string') {
|
||||
this.pdfDocument.getDestination(dest).then(resolve);
|
||||
}
|
||||
else if (Array.isArray(dest)) {
|
||||
resolve(dest);
|
||||
}
|
||||
else {
|
||||
dest.then(resolve);
|
||||
}
|
||||
}).then((explicitDest) => {
|
||||
invariant(Array.isArray(explicitDest), `"${explicitDest}" is not a valid destination array.`);
|
||||
const destRef = explicitDest[0];
|
||||
new Promise((resolve) => {
|
||||
invariant(this.pdfDocument, 'PDF document not loaded.');
|
||||
if (destRef instanceof Object) {
|
||||
this.pdfDocument
|
||||
.getPageIndex(destRef)
|
||||
.then((pageIndex) => {
|
||||
resolve(pageIndex);
|
||||
})
|
||||
.catch(() => {
|
||||
invariant(false, `"${destRef}" is not a valid page reference.`);
|
||||
});
|
||||
}
|
||||
else if (typeof destRef === 'number') {
|
||||
resolve(destRef);
|
||||
}
|
||||
else {
|
||||
invariant(false, `"${destRef}" is not a valid destination reference.`);
|
||||
}
|
||||
}).then((pageIndex) => {
|
||||
const pageNumber = pageIndex + 1;
|
||||
invariant(this.pdfViewer, 'PDF viewer is not initialized.');
|
||||
invariant(pageNumber >= 1 && pageNumber <= this.pagesCount, `"${pageNumber}" is not a valid page number.`);
|
||||
this.pdfViewer.scrollPageIntoView({
|
||||
dest: explicitDest,
|
||||
pageIndex,
|
||||
pageNumber,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
navigateTo(dest) {
|
||||
this.goToDestination(dest);
|
||||
}
|
||||
goToPage(pageNumber) {
|
||||
const pageIndex = pageNumber - 1;
|
||||
invariant(this.pdfViewer, 'PDF viewer is not initialized.');
|
||||
invariant(pageNumber >= 1 && pageNumber <= this.pagesCount, `"${pageNumber}" is not a valid page number.`);
|
||||
this.pdfViewer.scrollPageIntoView({
|
||||
pageIndex,
|
||||
pageNumber,
|
||||
});
|
||||
}
|
||||
addLinkAttributes(link, url, newWindow) {
|
||||
link.href = url;
|
||||
link.rel = this.externalLinkRel || DEFAULT_LINK_REL;
|
||||
link.target = newWindow ? '_blank' : this.externalLinkTarget || '';
|
||||
}
|
||||
getDestinationHash() {
|
||||
return '#';
|
||||
}
|
||||
getAnchorUrl() {
|
||||
return '#';
|
||||
}
|
||||
setHash() {
|
||||
// Intentionally empty
|
||||
}
|
||||
executeNamedAction() {
|
||||
// Intentionally empty
|
||||
}
|
||||
cachePageRef() {
|
||||
// Intentionally empty
|
||||
}
|
||||
isPageVisible() {
|
||||
return true;
|
||||
}
|
||||
isPageCached() {
|
||||
return true;
|
||||
}
|
||||
executeSetOCGState() {
|
||||
// Intentionally empty
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.react-server.production.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.react-server.development.js');
|
||||
}
|
||||
Reference in New Issue
Block a user