1.0.10 • Published 10 months ago

@idlebox/json-extends-loader v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

json extends loader

Read json config file chains. Like:

{
	"extends": "...",
	...
}

Usage:

import { loadInheritedJson } from '@idlebox/json-extends-loader';

const config = loadInheritedJson('src/tsconfig.json', { cwd: __dirname });

Options (2nd argument)

All optional.

paramtypedefaultdescription
readJsonFile(absPath: string) => any i.e. IJsonLoaderread file and parse by comment-jsonread given file, you can read anything (eg. yaml) by this function
cwdstringprocess.cwd()if 1st arg is relative, join it with cwd, otherwize no effect
extendsFieldstring"extends"change "extends" to other field name
nodeResolutionbooleantrueif false, node_modules is not searched, only able to extends relative path
arrayMerge<T>(target: T[], source: T[], options?: Options): T[]simple override by later valuesee this

Utils

readJsonFile(filePath: string): any

Read json file and parse by comment-json.

createDynamicReader(processor: IProcess): IJsonLoader

interface IProcess {
	(file: string, data: any): void;
}

create a function, feat for readJsonFile option. you can modify data as you want.

const tsconfigReader: IJsonLoader

a pre-defined loader, can use when load tsconfig.json, it resolve many path-related option.

class NotFoundError

Error object

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.10

10 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago