Comparing version
Change Log | ||
========== | ||
### 3.3.3 | ||
- array dependencies were being incorrectly flattened | ||
### 3.3.1 | ||
@@ -4,0 +7,0 @@ - publicPath relative imports was checking the incorrect path property |
import { JpexInstance, SetupConfig } from './types'; | ||
import { Lifecycle } from './constants'; | ||
declare const jpex: JpexInstance; | ||
export { jpex, JpexInstance, SetupConfig, Lifecycle }; | ||
export { jpex, JpexInstance, SetupConfig, Lifecycle, }; | ||
export default jpex; |
@@ -84,4 +84,4 @@ 'use strict'; | ||
_process = eval('process'); // eslint-disable-line no-eval | ||
} catch (e) {} // No process | ||
// eslint-disable-next-line max-len | ||
} catch (e) {// No process | ||
} // eslint-disable-next-line max-len | ||
@@ -275,3 +275,3 @@ | ||
function isNativeReflectConstruct() { | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
@@ -290,3 +290,3 @@ if (Reflect.construct.sham) return false; | ||
function _construct(Parent, args, Class) { | ||
if (isNativeReflectConstruct()) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
@@ -345,5 +345,3 @@ } else { | ||
var JpexError = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
var JpexError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(JpexError, _Error); | ||
@@ -356,3 +354,3 @@ | ||
return JpexError; | ||
}(_wrapNativeSuper(Error)); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
@@ -586,3 +584,3 @@ var isValidFactory = function isValidFactory(factory) { | ||
var x = resolveOne(jpex, dependency, globalOptions, namedParameters, stack); | ||
return value.concat(x); | ||
return value.concat([x]); | ||
}, []); | ||
@@ -619,5 +617,3 @@ return values; | ||
var Jpex = | ||
/*#__PURE__*/ | ||
function () { | ||
var Jpex = /*#__PURE__*/function () { | ||
function Jpex(options, parent) { | ||
@@ -743,3 +739,3 @@ var _ref; | ||
return function (name, namedParameters) { | ||
var allParams = _objectSpread2({}, $namedParameters, {}, namedParameters); | ||
var allParams = _objectSpread2(_objectSpread2({}, $namedParameters), namedParameters); | ||
@@ -746,0 +742,0 @@ if (Array.isArray(name)) { |
@@ -5,3 +5,3 @@ import { JpexInstance, Definition, Dependency } from '../types'; | ||
[key: string]: any; | ||
}) => any; | ||
}) => unknown; | ||
export declare const resolveDependencies: (jpex: JpexInstance, definition: Definition, namedParameters?: { | ||
@@ -8,0 +8,0 @@ [key: string]: any; |
import { JpexInstance, Dependency, Definition } from '../types'; | ||
export declare const resolveOne: <R extends any>(jpex: JpexInstance, name: Dependency, localOptions: any, namedParameters: { | ||
export declare const resolveOne: <R extends unknown>(jpex: JpexInstance, name: Dependency, localOptions: any, namedParameters: { | ||
[key: string]: any; | ||
@@ -4,0 +4,0 @@ }, stack: string[]) => R; |
@@ -10,3 +10,3 @@ import { AnyFunction } from '../types'; | ||
export declare const unsafeRequire: (target: string) => any; | ||
export declare const extractParameters: (fn: AnyFunction<any>) => string[]; | ||
export declare const extractParameters: (fn: AnyFunction) => string[]; | ||
interface GetLast { | ||
@@ -13,0 +13,0 @@ (str: string): string; |
import { JpexInstance, SetupConfig } from './types'; | ||
import { Lifecycle } from './constants'; | ||
declare const jpex: JpexInstance; | ||
export { jpex, JpexInstance, SetupConfig, Lifecycle }; | ||
export { jpex, JpexInstance, SetupConfig, Lifecycle, }; | ||
export default jpex; |
@@ -82,4 +82,4 @@ var Lifecycle; | ||
_process = eval('process'); // eslint-disable-line no-eval | ||
} catch (e) {} // No process | ||
// eslint-disable-next-line max-len | ||
} catch (e) {// No process | ||
} // eslint-disable-next-line max-len | ||
@@ -273,3 +273,3 @@ | ||
function isNativeReflectConstruct() { | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
@@ -288,3 +288,3 @@ if (Reflect.construct.sham) return false; | ||
function _construct(Parent, args, Class) { | ||
if (isNativeReflectConstruct()) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
@@ -343,5 +343,3 @@ } else { | ||
var JpexError = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
var JpexError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(JpexError, _Error); | ||
@@ -354,3 +352,3 @@ | ||
return JpexError; | ||
}(_wrapNativeSuper(Error)); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
@@ -584,3 +582,3 @@ var isValidFactory = function isValidFactory(factory) { | ||
var x = resolveOne(jpex, dependency, globalOptions, namedParameters, stack); | ||
return value.concat(x); | ||
return value.concat([x]); | ||
}, []); | ||
@@ -617,5 +615,3 @@ return values; | ||
var Jpex = | ||
/*#__PURE__*/ | ||
function () { | ||
var Jpex = /*#__PURE__*/function () { | ||
function Jpex(options, parent) { | ||
@@ -741,3 +737,3 @@ var _ref; | ||
return function (name, namedParameters) { | ||
var allParams = _objectSpread2({}, $namedParameters, {}, namedParameters); | ||
var allParams = _objectSpread2(_objectSpread2({}, $namedParameters), namedParameters); | ||
@@ -744,0 +740,0 @@ if (Array.isArray(name)) { |
@@ -5,3 +5,3 @@ import { JpexInstance, Definition, Dependency } from '../types'; | ||
[key: string]: any; | ||
}) => any; | ||
}) => unknown; | ||
export declare const resolveDependencies: (jpex: JpexInstance, definition: Definition, namedParameters?: { | ||
@@ -8,0 +8,0 @@ [key: string]: any; |
import { JpexInstance, Dependency, Definition } from '../types'; | ||
export declare const resolveOne: <R extends any>(jpex: JpexInstance, name: Dependency, localOptions: any, namedParameters: { | ||
export declare const resolveOne: <R extends unknown>(jpex: JpexInstance, name: Dependency, localOptions: any, namedParameters: { | ||
[key: string]: any; | ||
@@ -4,0 +4,0 @@ }, stack: string[]) => R; |
import { Lifecycle } from '../constants'; | ||
export * from './JpexInstance'; | ||
export type AnyFunction<R = any> = (...args: any[]) => R; | ||
export interface AnyConstructor<T = any> { | ||
new (...args: any[]): T; | ||
new (...args: any[]): T | ||
} | ||
export interface SetupConfig { | ||
lifecycle?: Lifecycle; | ||
inherit?: boolean; | ||
lifecycle?: Lifecycle, | ||
inherit?: boolean, | ||
} | ||
export type Dependency = string | { | ||
[key: string]: any; | ||
}; | ||
export type Dependency = string | { [key: string]: any }; | ||
export interface Definition { | ||
dependencies?: Dependency[]; | ||
dependencies?: Dependency[], | ||
} | ||
export interface Factory extends Definition { | ||
fn: <T, R>(...args: T[]) => R; | ||
resolved?: boolean; | ||
value?: any; | ||
lifecycle?: Lifecycle; | ||
} | ||
fn: <T, R>(...args: T[]) => R, | ||
resolved?: boolean, | ||
value?: any, | ||
lifecycle?: Lifecycle, | ||
} |
import { Lifecycle } from '../constants'; | ||
import { Wrapper } from '../deps/wrapper'; | ||
import { AnyFunction, Dependency, AnyConstructor, SetupConfig, Factory } from './'; | ||
import { | ||
AnyFunction, | ||
Dependency, | ||
AnyConstructor, | ||
SetupConfig, | ||
Factory, | ||
} from './'; | ||
export interface JpexInstance { | ||
constant<T = any>(name: string, obj: T): Wrapper; | ||
constant<T>(obj: T): Wrapper; | ||
factory<T = any>(name: string, fn: AnyFunction<T>): Wrapper; | ||
factory<T = any>(name: string, deps: Dependency[], fn: AnyFunction<T>): Wrapper; | ||
factory<T>(fn: AnyFunction<T>): Wrapper; | ||
factory<T>(deps: Dependency[], fn: AnyFunction<T>): Wrapper; | ||
service<T = any>(name: string, fn: AnyConstructor<T> | AnyFunction): Wrapper; | ||
service<T = any>(name: string, deps: Dependency[], fn: AnyConstructor | AnyFunction): Wrapper; | ||
service<T>(fn: AnyConstructor<T> | AnyFunction): Wrapper; | ||
alias<T = any>(alias: string, name: string): void; | ||
alias<T>(alias: string): void; | ||
resolve<T = any>(name: Dependency): T; | ||
resolve<T>(): T; | ||
resolveWith<T = any>(name: Dependency, namedParameters: { | ||
[key: string]: any; | ||
}): T; | ||
resolveWith<T>(namedParameters: { | ||
[key: string]: any; | ||
}): T; | ||
encase<F extends AnyFunction<AnyFunction>>(fn: F): ReturnType<F> & { | ||
encased: F; | ||
}; | ||
encase<F extends AnyFunction<AnyFunction>>(dependencies: Dependency[], fn: F): ReturnType<F> & { | ||
encased: F; | ||
}; | ||
raw<T = any>(name: Dependency): AnyFunction<T>; | ||
raw<T>(): AnyFunction<T>; | ||
clearCache(): void; | ||
clearCache(name: string): void; | ||
clearCache(names: string[]): void; | ||
extend(): JpexInstance; | ||
extend(config: SetupConfig): JpexInstance; | ||
infer<T>(): string; | ||
$$parent: JpexInstance; | ||
$$defaultLifecycle: Lifecycle; | ||
constant<T = any>(name: string, obj: T): Wrapper | ||
constant<T>(obj: T): Wrapper | ||
factory<T = any>(name: string, fn: AnyFunction<T>): Wrapper | ||
factory<T = any>(name: string, deps: Dependency[], fn: AnyFunction<T>): Wrapper | ||
factory<T>(fn: AnyFunction<T>): Wrapper | ||
factory<T>(deps: Dependency[], fn: AnyFunction<T>): Wrapper | ||
service<T = any>(name: string, fn: AnyConstructor<T> | AnyFunction): Wrapper | ||
service<T = any>(name: string, deps: Dependency[], fn: AnyConstructor | AnyFunction): Wrapper | ||
service<T>(fn: AnyConstructor<T> | AnyFunction): Wrapper | ||
alias<T = any>(alias: string, name: string): void, | ||
alias<T>(alias: string): void, | ||
resolve<T = any>(name: Dependency): T, | ||
resolve<T>(): T, | ||
resolveWith<T = any>( | ||
name: Dependency, | ||
namedParameters: { | ||
[key: string]: any, | ||
}, | ||
): T | ||
resolveWith<T>( | ||
namedParameters: { | ||
[key: string]: any, | ||
}, | ||
): T, | ||
encase<F extends AnyFunction<AnyFunction>>( | ||
fn: F, | ||
): ReturnType<F> & { encased : F }, | ||
encase<F extends AnyFunction<AnyFunction>>( | ||
dependencies: Dependency[], | ||
fn: F, | ||
): ReturnType<F> & { encased: F }, | ||
raw<T = any>(name: Dependency): AnyFunction<T>, | ||
raw<T>(): AnyFunction<T>, | ||
clearCache(): void, | ||
clearCache(name: string): void, | ||
clearCache(names: string[]): void, | ||
extend(): JpexInstance, | ||
extend(config: SetupConfig): JpexInstance, | ||
infer<T>(): string, | ||
$$parent: JpexInstance, | ||
$$defaultLifecycle: Lifecycle, | ||
$$factories: { | ||
[key: string]: Factory; | ||
}; | ||
[key: string]: Factory, | ||
}, | ||
$$resolved: { | ||
[key: string]: any; | ||
}; | ||
} | ||
[key: string]: any, | ||
}, | ||
} |
@@ -10,3 +10,3 @@ import { AnyFunction } from '../types'; | ||
export declare const unsafeRequire: (target: string) => any; | ||
export declare const extractParameters: (fn: AnyFunction<any>) => string[]; | ||
export declare const extractParameters: (fn: AnyFunction) => string[]; | ||
interface GetLast { | ||
@@ -13,0 +13,0 @@ (str: string): string; |
{ | ||
"name": "jpex", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "Javascript Prototype Extension", | ||
@@ -12,9 +12,5 @@ "main": "dist/cjs/jpex.js", | ||
"lint": "eslint './src/**/*.ts' && tsc", | ||
"build:cleanup": "rm -rf dist && rm -rf tmp", | ||
"build:pre": "babel src --out-dir tmp --extensions \".ts\" --keep-file-extension --config-file ./prebuild.babel.config.js", | ||
"build:js": "rollup --config ./rollup.config.js && cp -r tmp/types dist/es", | ||
"build:post": "rm -rf tmp", | ||
"build": "yarn build:cleanup && yarn build:pre && yarn build:js && yarn build:post", | ||
"lcov-fix": "node node_modules/jpex-build-tools/lcov-fix", | ||
"travis-prepublish": "node node_modules/jpex-build-tools/travis-prepublish", | ||
"build:prepare": "rm -rf dist && rm -rf tmp", | ||
"build:js": "rollup --config ./rollup.config.js && cp -r src/types dist/es", | ||
"build": "yarn build:prepare && yarn build:js", | ||
"prepublishOnly": "yarn build" | ||
@@ -63,21 +59,20 @@ }, | ||
"@team-griffin/eslint-config": "^3.2.0", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^13.5.0", | ||
"@types/sinon": "^7.5.1", | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
"@typescript-eslint/parser": "^2.21.0", | ||
"@types/mocha": "^8.0.0", | ||
"@types/node": "^14.0.26", | ||
"@types/sinon": "^9.0.4", | ||
"@typescript-eslint/eslint-plugin": "^3.7.1", | ||
"@typescript-eslint/parser": "^3.7.1", | ||
"ava": "^3.0.0", | ||
"browser-env": "^3.3.0", | ||
"eslint": "^6.8.0", | ||
"eslint": "^7.5.0", | ||
"husky": "^4.0.3", | ||
"jpex-build-tools": "git+https://github.com/jackmellis/jpex-build-tools.git", | ||
"lint-staged": "^8.1.5", | ||
"nyc": "^10.1.2", | ||
"rollup": "^1.29.0", | ||
"nyc": "^15.1.0", | ||
"rollup": "^2.23.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-typescript2": "^0.26.0", | ||
"sinon": "^8.1.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"sinon": "^9.0.2", | ||
"typescript": "^3.8.2" | ||
} | ||
} |
33
-2.94%1984
0.2%84347
-0.28%