functionalscript 0.3.15 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bnf/djs/test.f.js +36 -41
- package/bnf/func/module.f.d.ts +12 -5
- package/bnf/func/module.f.js +27 -6
- package/bnf/func/test.f.js +25 -84
- package/bnf/tag/module.f.d.ts +30 -0
- package/bnf/tag/module.f.js +37 -0
- package/bnf/tag/test.f.d.ts +1 -0
- package/bnf/tag/test.f.js +138 -0
- package/fsc/bnf.f.d.ts +2 -0
- package/fsc/bnf.f.js +54 -0
- package/fsc/json.f.d.ts +7 -0
- package/fsc/json.f.js +89 -0
- package/package.json +2 -3
- package/types/array/module.f.d.ts +1 -0
- package/types/array/module.f.js +1 -0
- package/types/bigint/module.f.d.ts +6 -0
- package/types/bigint/module.f.js +27 -5
- package/types/bigint/test.f.d.ts +8 -5
- package/types/bigint/test.f.js +91 -19
- package/com/cpp/module.f.d.ts +0 -10
- package/com/cpp/module.f.js +0 -106
- package/com/cpp/test.f.d.ts +0 -2
- package/com/cpp/test.f.js +0 -40
- package/com/cpp/testlib.f.d.ts +0 -2
- package/com/cpp/testlib.f.js +0 -5
- package/com/cs/module.f.d.ts +0 -12
- package/com/cs/module.f.js +0 -79
- package/com/cs/test.f.d.ts +0 -2
- package/com/cs/test.f.js +0 -43
- package/com/cs/testlib.f.d.ts +0 -2
- package/com/cs/testlib.f.js +0 -5
- package/com/rust/module.f.d.ts +0 -15
- package/com/rust/module.f.js +0 -164
- package/com/rust/test.f.d.ts +0 -2
- package/com/rust/test.f.js +0 -123
- package/com/rust/testlib.f.d.ts +0 -2
- package/com/rust/testlib.f.js +0 -5
- package/com/test/build.f.d.ts +0 -20
- package/com/test/build.f.js +0 -58
- package/com/types/module.f.d.ts +0 -28
- package/com/types/module.f.js +0 -7
- package/com/types/testlib.f.d.ts +0 -44
- package/com/types/testlib.f.js +0 -28
- package/commonjs/build/module.f.d.ts +0 -6
- package/commonjs/build/module.f.js +0 -66
- package/commonjs/build/test.f.d.ts +0 -2
- package/commonjs/build/test.f.js +0 -92
- package/commonjs/module/function/module.f.d.ts +0 -8
- package/commonjs/module/function/module.f.js +0 -4
- package/commonjs/module/module.f.d.ts +0 -18
- package/commonjs/module/module.f.js +0 -11
- package/commonjs/module.f.d.ts +0 -6
- package/commonjs/module.f.js +0 -1
- package/commonjs/package/dependencies/module.f.d.ts +0 -7
- package/commonjs/package/dependencies/module.f.js +0 -13
- package/commonjs/package/dependencies/test.f.d.ts +0 -2
- package/commonjs/package/dependencies/test.f.js +0 -15
- package/commonjs/package/module.f.d.ts +0 -17
- package/commonjs/package/module.f.js +0 -18
- package/commonjs/package/test.f.d.ts +0 -2
- package/commonjs/package/test.f.js +0 -27
- package/commonjs/path/module.f.d.ts +0 -24
- package/commonjs/path/module.f.js +0 -112
- package/commonjs/path/test.f.d.ts +0 -25
- package/commonjs/path/test.f.js +0 -221
package/commonjs/build/test.f.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import * as _ from "./module.f.js";
|
|
2
|
-
import * as map from "../../types/map/module.f.js";
|
|
3
|
-
import { at } from "../../types/object/module.f.js";
|
|
4
|
-
const compileMap = {
|
|
5
|
-
':index.js': [
|
|
6
|
-
'ok',
|
|
7
|
-
require_ => m0 => {
|
|
8
|
-
let [r, m] = require_('./b')(m0);
|
|
9
|
-
if (r[0] === 'error') {
|
|
10
|
-
throw JSON.stringify(r);
|
|
11
|
-
}
|
|
12
|
-
[r, m] = require_('./a/')(m);
|
|
13
|
-
if (r[0] === 'error') {
|
|
14
|
-
throw JSON.stringify(r);
|
|
15
|
-
}
|
|
16
|
-
[r, m] = require_('x/r')(m);
|
|
17
|
-
if (r[0] === 'error') {
|
|
18
|
-
throw JSON.stringify(r);
|
|
19
|
-
}
|
|
20
|
-
return [['ok', ':index.js'], m];
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
':b.js': [
|
|
24
|
-
'ok',
|
|
25
|
-
() => m0 => [['ok', ':b.js'], m0]
|
|
26
|
-
],
|
|
27
|
-
':a/index.js': [
|
|
28
|
-
'ok',
|
|
29
|
-
() => m0 => [['ok', ':a/index.js'], m0]
|
|
30
|
-
],
|
|
31
|
-
'x:r.js': [
|
|
32
|
-
'ok',
|
|
33
|
-
() => m0 => [['ok', 'x:r.js'], m0]
|
|
34
|
-
],
|
|
35
|
-
};
|
|
36
|
-
const compile = source => compileMap[source] ?? ['error', 'invalid source'];
|
|
37
|
-
const packageMap = {
|
|
38
|
-
'': {
|
|
39
|
-
dependencies: {
|
|
40
|
-
'x': '/node_modules/x'
|
|
41
|
-
},
|
|
42
|
-
files: {
|
|
43
|
-
'index.js': ':index.js',
|
|
44
|
-
'b.js': ':b.js',
|
|
45
|
-
'a/index.js': ':a/index.js',
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
'/node_modules/x': {
|
|
49
|
-
dependencies: {},
|
|
50
|
-
files: {
|
|
51
|
-
'r.js': 'x:r.js'
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
const packageGet = packageId => {
|
|
56
|
-
const p = at(packageId)(packageMap);
|
|
57
|
-
return p === null ? null :
|
|
58
|
-
{
|
|
59
|
-
dependency: dependency => at(dependency)(p.dependencies),
|
|
60
|
-
file: file => at(file)(p.files),
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const getOrBuild = _.getOrBuild(compile)(packageGet)(map);
|
|
64
|
-
export default () => {
|
|
65
|
-
let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(map.empty);
|
|
66
|
-
{
|
|
67
|
-
if (r === null) {
|
|
68
|
-
throw 'r === null';
|
|
69
|
-
}
|
|
70
|
-
const x = JSON.stringify(r);
|
|
71
|
-
if (x !==
|
|
72
|
-
'["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js","x/r":"/node_modules/x/r.js"}}]') {
|
|
73
|
-
throw `0:${x}`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
{
|
|
77
|
-
[r, m] = getOrBuild({ package: '', path: ['b.js'] })(m);
|
|
78
|
-
const x = JSON.stringify(r);
|
|
79
|
-
if (x !==
|
|
80
|
-
'["ok",{"exports":":b.js","requireMap":{}}]') {
|
|
81
|
-
throw x;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
{
|
|
85
|
-
[r, m] = getOrBuild({ package: '', path: ['c.js'] })(m);
|
|
86
|
-
const x = JSON.stringify(r);
|
|
87
|
-
if (x !==
|
|
88
|
-
'["error",["file not found"]]') {
|
|
89
|
-
throw x;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An IO interface for creating and running module functions.
|
|
3
|
-
*/
|
|
4
|
-
import type * as TypesResult from '../../../types/result/module.f.ts';
|
|
5
|
-
export type Function_ = <M>(require: Require<M>) => (prior: M) => Result<M>;
|
|
6
|
-
export type Result<M> = readonly [TypesResult.Result<unknown, unknown>, M];
|
|
7
|
-
export type Require<M> = (path: string) => (prior: M) => Result<M>;
|
|
8
|
-
export type Compile = (source: string) => TypesResult.Result<Function_, unknown>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type * as O from '../../types/object/module.f.ts';
|
|
2
|
-
export type MapInterface<M> = {
|
|
3
|
-
readonly at: (moduleId: string) => (moduleMap: M) => State | null;
|
|
4
|
-
readonly setReplace: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M;
|
|
5
|
-
};
|
|
6
|
-
export type State = readonly ['ok', Module] | readonly ['error', Error];
|
|
7
|
-
type Module = {
|
|
8
|
-
readonly exports: unknown;
|
|
9
|
-
readonly requireMap: O.Map<string>;
|
|
10
|
-
};
|
|
11
|
-
export type Error = ['file not found'] | ['compilation error', unknown] | ['runtime error', unknown] | ['circular reference'];
|
|
12
|
-
export type Id = {
|
|
13
|
-
readonly package: string;
|
|
14
|
-
readonly path: readonly string[];
|
|
15
|
-
};
|
|
16
|
-
export declare const dir: (id: Id) => Id | null;
|
|
17
|
-
export declare const idToString: (id: Id) => string;
|
|
18
|
-
export {};
|
package/commonjs/module.f.d.ts
DELETED
package/commonjs/module.f.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Unknown } from '../../../json/module.f.ts';
|
|
2
|
-
type DependencyMapJson = {
|
|
3
|
-
readonly [k in string]: string;
|
|
4
|
-
};
|
|
5
|
-
export type DependenciesJson = DependencyMapJson | null;
|
|
6
|
-
export declare const isDependenciesJson: (j: Unknown) => j is DependenciesJson;
|
|
7
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../../../json/module.f.js";
|
|
2
|
-
import { map, every } from "../../../types/list/module.f.js";
|
|
3
|
-
const { entries } = Object;
|
|
4
|
-
const isDependencyJson = ([, v]) => typeof v === 'string';
|
|
5
|
-
export const isDependenciesJson = (j) => {
|
|
6
|
-
if (j === null) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
if (!isObject(j)) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return every(map(isDependencyJson)(entries(j)));
|
|
13
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as _ from "./module.f.js";
|
|
2
|
-
export default () => {
|
|
3
|
-
if (!_.isDependenciesJson(null)) {
|
|
4
|
-
throw 'error';
|
|
5
|
-
}
|
|
6
|
-
if (!_.isDependenciesJson({})) {
|
|
7
|
-
throw 'error';
|
|
8
|
-
}
|
|
9
|
-
if (!_.isDependenciesJson({ 'a': 'b' })) {
|
|
10
|
-
throw 'error';
|
|
11
|
-
}
|
|
12
|
-
if (_.isDependenciesJson({ 'a': 12 })) {
|
|
13
|
-
throw 'error';
|
|
14
|
-
}
|
|
15
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Unknown } from '../../json/module.f.ts';
|
|
2
|
-
import { type DependenciesJson } from './dependencies/module.f.ts';
|
|
3
|
-
type PackageJson = {
|
|
4
|
-
readonly name: string;
|
|
5
|
-
readonly version: string;
|
|
6
|
-
readonly dependencies?: DependenciesJson;
|
|
7
|
-
};
|
|
8
|
-
export declare const isPackageJson: (j: Unknown) => j is PackageJson;
|
|
9
|
-
export type Package = {
|
|
10
|
-
readonly dependency: (localPackageId: string) => string | null;
|
|
11
|
-
readonly file: (localFileId: string) => string | null;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @note Current package has an empty string '' as a packageId.
|
|
15
|
-
*/
|
|
16
|
-
export type Get = (packageId: string) => Package | null;
|
|
17
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../../json/module.f.js";
|
|
2
|
-
import { isDependenciesJson } from "./dependencies/module.f.js";
|
|
3
|
-
import { at } from "../../types/object/module.f.js";
|
|
4
|
-
export const isPackageJson = (j) => {
|
|
5
|
-
if (!isObject(j)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (typeof j.name !== 'string') {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (typeof j.version !== 'string') {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (!isDependenciesJson(at('dependencies')(j))) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as _ from "./module.f.js";
|
|
2
|
-
export default () => {
|
|
3
|
-
if (_.isPackageJson(null)) {
|
|
4
|
-
throw 'error';
|
|
5
|
-
}
|
|
6
|
-
if (_.isPackageJson({})) {
|
|
7
|
-
throw 'error';
|
|
8
|
-
}
|
|
9
|
-
if (_.isPackageJson({ name: 'x', version: 12 })) {
|
|
10
|
-
throw 'error';
|
|
11
|
-
}
|
|
12
|
-
if (!_.isPackageJson({ name: 'x', version: "12" })) {
|
|
13
|
-
throw 'error';
|
|
14
|
-
}
|
|
15
|
-
if (_.isPackageJson({ version: "", dependencies: [] })) {
|
|
16
|
-
throw 'error';
|
|
17
|
-
}
|
|
18
|
-
if (!_.isPackageJson({ name: 'a', version: "", dependencies: {} })) {
|
|
19
|
-
throw 'error';
|
|
20
|
-
}
|
|
21
|
-
if (_.isPackageJson({ name: 'b', version: "", dependencies: { x: 12 } })) {
|
|
22
|
-
throw 'error';
|
|
23
|
-
}
|
|
24
|
-
if (!_.isPackageJson({ name: 'c', version: "", dependencies: { x: "12" } })) {
|
|
25
|
-
throw 'error';
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type List } from '../../types/list/module.f.ts';
|
|
2
|
-
import type * as Package from '../package/module.f.ts';
|
|
3
|
-
import type * as Module from '../module/module.f.ts';
|
|
4
|
-
type Items = readonly string[];
|
|
5
|
-
type LocalPath = {
|
|
6
|
-
readonly external: boolean;
|
|
7
|
-
readonly dir: boolean;
|
|
8
|
-
readonly items: Items;
|
|
9
|
-
};
|
|
10
|
-
export declare const parseLocal: (local: string) => (path: string) => LocalPath | null;
|
|
11
|
-
export type Path = {
|
|
12
|
-
readonly package: string;
|
|
13
|
-
readonly items: Items;
|
|
14
|
-
readonly dir: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare const parseGlobal: (d: (local: string) => string | null) => (dir: boolean) => (items: List<string>) => Path | null;
|
|
17
|
-
export declare const parse: (packageId: string) => (dependencies: (local: string) => string | null) => (local: string) => (path: string) => Path | null;
|
|
18
|
-
export type FoundResult = {
|
|
19
|
-
readonly id: Module.Id;
|
|
20
|
-
readonly source: string;
|
|
21
|
-
};
|
|
22
|
-
export type Result = FoundResult | null;
|
|
23
|
-
export declare const parseAndFind: (packageGet: Package.Get) => (moduleId: Module.Id) => (path: string) => Result;
|
|
24
|
-
export {};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { next, fold, reverse, first, flat, toArray, filterMap, isEmpty, concat, empty } from "../../types/list/module.f.js";
|
|
2
|
-
import { join } from "../../types/string/module.f.js";
|
|
3
|
-
const split = path => path.split('/');
|
|
4
|
-
const normItemsOp = (first) => (prior) => {
|
|
5
|
-
if (prior === null) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
const tail = prior[0];
|
|
9
|
-
switch (first) {
|
|
10
|
-
case '':
|
|
11
|
-
case '.': {
|
|
12
|
-
return prior;
|
|
13
|
-
}
|
|
14
|
-
case '..': {
|
|
15
|
-
const result = next(tail);
|
|
16
|
-
if (result === null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return [result.tail];
|
|
20
|
-
}
|
|
21
|
-
default: {
|
|
22
|
-
return [{ first, tail }];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const normItems = (items) => {
|
|
27
|
-
const result = fold(normItemsOp)([empty])(items);
|
|
28
|
-
return result === null ? result : [reverse(result[0])];
|
|
29
|
-
};
|
|
30
|
-
const firstNull = first(null);
|
|
31
|
-
export const parseLocal = (local) => {
|
|
32
|
-
const fSeq = (path) => {
|
|
33
|
-
const pathSeq = split(path);
|
|
34
|
-
const dir = [null, '', '.', '..'].includes(pathSeq[pathSeq.length - 1]);
|
|
35
|
-
return ['.', '..'].includes(firstNull(pathSeq)) ?
|
|
36
|
-
[false, dir, flat([split(local), pathSeq])] :
|
|
37
|
-
[true, dir, pathSeq];
|
|
38
|
-
};
|
|
39
|
-
return path => {
|
|
40
|
-
const [external, dir, items] = fSeq(path);
|
|
41
|
-
const n = normItems(items);
|
|
42
|
-
if (n === null) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
external,
|
|
47
|
-
dir,
|
|
48
|
-
items: toArray(n[0])
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
const variants = (prior) => () => {
|
|
53
|
-
const [a, b] = prior;
|
|
54
|
-
const r = next(b);
|
|
55
|
-
if (r === empty) {
|
|
56
|
-
return empty;
|
|
57
|
-
}
|
|
58
|
-
const { first, tail } = r;
|
|
59
|
-
const n = [a === null ? first : `${a}/${first}`, tail];
|
|
60
|
-
return { first: n, tail: variants(n) };
|
|
61
|
-
};
|
|
62
|
-
const mapDependency = (d) => ([external, internal]) => {
|
|
63
|
-
const id = d(external);
|
|
64
|
-
return id === null ? null : [id, internal];
|
|
65
|
-
};
|
|
66
|
-
export const parseGlobal = dependencies => {
|
|
67
|
-
const fMap = filterMap(mapDependency(dependencies));
|
|
68
|
-
return dir => items => {
|
|
69
|
-
const v = variants([null, items]);
|
|
70
|
-
const r = firstNull(fMap(v));
|
|
71
|
-
if (r === null) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return { package: r[0], items: toArray(r[1]), dir };
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
export const parse = packageId => dependencies => {
|
|
78
|
-
const pg = parseGlobal(dependencies);
|
|
79
|
-
return local => path => {
|
|
80
|
-
const parsed = parseLocal(local)(path);
|
|
81
|
-
if (parsed === null) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
const { external, dir, items } = parsed;
|
|
85
|
-
if (!external) {
|
|
86
|
-
return { package: packageId, items, dir };
|
|
87
|
-
}
|
|
88
|
-
return pg(dir)(items);
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
export const parseAndFind = packageGet => moduleId => path => {
|
|
92
|
-
const currentPack = packageGet(moduleId.package);
|
|
93
|
-
if (currentPack === null) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const p = parse(moduleId.package)(currentPack.dependency)(moduleId.path.join('/'))(path);
|
|
97
|
-
if (p === null) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
const pack = packageGet(p.package);
|
|
101
|
-
if (pack === null) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
const tryFile = file => {
|
|
105
|
-
const source = pack.file(file);
|
|
106
|
-
return source === null ? null : { id: { package: p.package, path: file.split('/') }, source };
|
|
107
|
-
};
|
|
108
|
-
const file = p.items.join('/');
|
|
109
|
-
const indexJs = join('/')(concat(p.items)(['index.js']));
|
|
110
|
-
const fileList = p.dir || isEmpty(p.items) ? [indexJs] : [file, `${file}.js`, indexJs];
|
|
111
|
-
return firstNull(filterMap(tryFile)(fileList));
|
|
112
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
0: () => void;
|
|
3
|
-
1: () => void;
|
|
4
|
-
2: () => void;
|
|
5
|
-
3: () => void;
|
|
6
|
-
4: () => void;
|
|
7
|
-
5: () => void;
|
|
8
|
-
6: () => void;
|
|
9
|
-
7: () => void;
|
|
10
|
-
8: {
|
|
11
|
-
0: () => void;
|
|
12
|
-
1: () => void;
|
|
13
|
-
2: () => void;
|
|
14
|
-
3: () => void;
|
|
15
|
-
4: () => void;
|
|
16
|
-
5: () => void;
|
|
17
|
-
6: () => void;
|
|
18
|
-
7: () => void;
|
|
19
|
-
};
|
|
20
|
-
9: () => void;
|
|
21
|
-
10: () => void;
|
|
22
|
-
11: () => void;
|
|
23
|
-
12: () => void;
|
|
24
|
-
};
|
|
25
|
-
export default _default;
|
package/commonjs/path/test.f.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import * as _ from "./module.f.js";
|
|
2
|
-
import { todo } from "../../dev/module.f.js";
|
|
3
|
-
import * as json from "../../json/module.f.js";
|
|
4
|
-
import { identity } from "../../types/function/module.f.js";
|
|
5
|
-
import { at } from "../../types/object/module.f.js";
|
|
6
|
-
const i = (o) => (s) => at(s)(o);
|
|
7
|
-
const stringify = json.stringify(identity);
|
|
8
|
-
export default {
|
|
9
|
-
0: () => {
|
|
10
|
-
const result = _.parseLocal('')('./a');
|
|
11
|
-
if (stringify(result) !== '{"external":false,"dir":false,"items":["a"]}') {
|
|
12
|
-
throw result;
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
1: () => {
|
|
16
|
-
const result = _.parseLocal('')('./a/');
|
|
17
|
-
if (stringify(result) !== '{"external":false,"dir":true,"items":["a"]}') {
|
|
18
|
-
throw result;
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
2: () => {
|
|
22
|
-
const result = _.parseLocal('')('..');
|
|
23
|
-
if (result !== null) {
|
|
24
|
-
throw result;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
3: () => {
|
|
28
|
-
const result = _.parseLocal('a')('');
|
|
29
|
-
if (stringify(result) !== '{"external":true,"dir":true,"items":[]}') {
|
|
30
|
-
throw result;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
4: () => {
|
|
34
|
-
const result = _.parseLocal('')('./a/b/.././c');
|
|
35
|
-
if (stringify(result) !== '{"external":false,"dir":false,"items":["a","c"]}') {
|
|
36
|
-
throw result;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
5: () => {
|
|
40
|
-
const result = _.parseLocal('x/r')('./a/b/.././c');
|
|
41
|
-
if (stringify(result) !== '{"external":false,"dir":false,"items":["x","r","a","c"]}') {
|
|
42
|
-
throw result;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
6: () => {
|
|
46
|
-
const result = _.parseLocal('a')('a/b/.././c');
|
|
47
|
-
if (stringify(result) !== '{"external":true,"dir":false,"items":["a","c"]}') {
|
|
48
|
-
throw result;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
7: () => {
|
|
52
|
-
const result = _.parseLocal('')('./x/..');
|
|
53
|
-
if (stringify(result) !== '{"external":false,"dir":true,"items":[]}') {
|
|
54
|
-
throw result;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
8: {
|
|
58
|
-
0: () => { if (_.parseGlobal(() => null)(false)(['a', 'b']) !== null) {
|
|
59
|
-
throw 'error';
|
|
60
|
-
} },
|
|
61
|
-
1: () => { if (_.parseGlobal(() => null)(false)(['b']) !== null) {
|
|
62
|
-
throw 'error';
|
|
63
|
-
} },
|
|
64
|
-
2: () => { if (_.parseGlobal(i({ b: 'x' }))(false)(['d']) !== null) {
|
|
65
|
-
throw 'error';
|
|
66
|
-
} },
|
|
67
|
-
3: () => {
|
|
68
|
-
const result = stringify(_.parseGlobal(i({ b: 'x' }))(false)(['b']));
|
|
69
|
-
if (result !== '{"package":"x","items":[],"dir":false}') {
|
|
70
|
-
throw result;
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
4: () => { if (_.parseGlobal(i({ 'b/r': 'x' }))(false)(['b']) !== null) {
|
|
74
|
-
throw 'error';
|
|
75
|
-
} },
|
|
76
|
-
5: () => {
|
|
77
|
-
const result = stringify(_.parseGlobal(i({ 'b/r': 'x' }))(false)(['b', 'r']));
|
|
78
|
-
if (result !== '{"package":"x","items":[],"dir":false}') {
|
|
79
|
-
throw result;
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
6: () => {
|
|
83
|
-
const result = stringify(_.parseGlobal(i({ 'b/r': 'x' }))(false)(['b', 'r', 'd', 't']));
|
|
84
|
-
if (result !== '{"package":"x","items":["d","t"],"dir":false}') {
|
|
85
|
-
throw result;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
7: () => {
|
|
89
|
-
const result = stringify(_.parseGlobal(i({ 'b/r': 'x' }))(true)(['b', 'r', 'd', 't']));
|
|
90
|
-
if (result !== '{"package":"x","items":["d","t"],"dir":true}') {
|
|
91
|
-
throw result;
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
9: () => {
|
|
96
|
-
const packages = {
|
|
97
|
-
'': {
|
|
98
|
-
dependency: () => todo(),
|
|
99
|
-
file: i({ 'a/c': 'return "a/c"' }),
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('../c'));
|
|
103
|
-
if (result !== '{"id":{"package":"","path":["a","c"]},"source":"return \\"a/c\\""}') {
|
|
104
|
-
throw result;
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
10: () => {
|
|
108
|
-
const packages = {
|
|
109
|
-
'': {
|
|
110
|
-
dependency: x => {
|
|
111
|
-
const path = `node_modules/${x}`;
|
|
112
|
-
return at(path)(packages) !== null ? path : null;
|
|
113
|
-
},
|
|
114
|
-
file: i({
|
|
115
|
-
'index.js': 'return "index.js"',
|
|
116
|
-
'x/index.js': 'return "x/index.js"',
|
|
117
|
-
'x.js': 'return "x.js"',
|
|
118
|
-
})
|
|
119
|
-
},
|
|
120
|
-
'node_modules/z': {
|
|
121
|
-
dependency: () => todo(),
|
|
122
|
-
file: i({ 'a/c/index.js': 'return "a/c"' }),
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
{
|
|
126
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('z/a/c'));
|
|
127
|
-
if (result !== '{"id":{"package":"node_modules/z","path":["a","c","index.js"]},"source":"return \\"a/c\\""}') {
|
|
128
|
-
throw result;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
{
|
|
132
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('../..'));
|
|
133
|
-
if (result !== '{"id":{"package":"","path":["index.js"]},"source":"return \\"index.js\\""}') {
|
|
134
|
-
throw result;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
{
|
|
138
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: [] })('./x'));
|
|
139
|
-
if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') {
|
|
140
|
-
throw result;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
{
|
|
144
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: [] })('./x.js'));
|
|
145
|
-
if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') {
|
|
146
|
-
throw result;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
{
|
|
150
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: [] })('./x/'));
|
|
151
|
-
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') {
|
|
152
|
-
throw result;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
{
|
|
156
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['x', 'a'] })('../'));
|
|
157
|
-
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') {
|
|
158
|
-
throw result;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
{
|
|
162
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['x', 'a'] })('..'));
|
|
163
|
-
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') {
|
|
164
|
-
throw result;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
11: () => {
|
|
169
|
-
const packages = {
|
|
170
|
-
'': {
|
|
171
|
-
dependency: x => {
|
|
172
|
-
const path = `node_modules/${x}`;
|
|
173
|
-
return at(path)(packages) !== null ? path : null;
|
|
174
|
-
},
|
|
175
|
-
file: todo
|
|
176
|
-
},
|
|
177
|
-
'node_modules/z/a': {
|
|
178
|
-
dependency: () => todo(),
|
|
179
|
-
file: i({
|
|
180
|
-
'c/index.js': 'return "c/index.js"',
|
|
181
|
-
'c.js': 'return "c.js"'
|
|
182
|
-
}),
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
{
|
|
186
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('z/a/c'));
|
|
187
|
-
if (result !== '{"id":{"package":"node_modules/z/a","path":["c.js"]},"source":"return \\"c.js\\""}') {
|
|
188
|
-
throw result;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
{
|
|
192
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('z/a/c/'));
|
|
193
|
-
if (result !== '{"id":{"package":"node_modules/z/a","path":["c","index.js"]},"source":"return \\"c/index.js\\""}') {
|
|
194
|
-
throw result;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
12: () => {
|
|
199
|
-
const packages = {
|
|
200
|
-
'': {
|
|
201
|
-
dependency: x => {
|
|
202
|
-
const path = `node_modules/${x}`;
|
|
203
|
-
return at(path)(packages) !== null ? path : null;
|
|
204
|
-
},
|
|
205
|
-
file: todo
|
|
206
|
-
},
|
|
207
|
-
'node_modules/z/a/c': {
|
|
208
|
-
dependency: () => todo(),
|
|
209
|
-
file: i({
|
|
210
|
-
'': 'throw',
|
|
211
|
-
'.js': 'throw',
|
|
212
|
-
'index.js': 'return "a/c"'
|
|
213
|
-
}),
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
const result = stringify(_.parseAndFind(i(packages))({ package: '', path: ['a', 'b'] })('z/a/c'));
|
|
217
|
-
if (result !== '{"id":{"package":"node_modules/z/a/c","path":["index.js"]},"source":"return \\"a/c\\""}') {
|
|
218
|
-
throw result;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
};
|