Skip to content

Commit

Permalink
import lodash methods by method instead of named imports
Browse files Browse the repository at this point in the history
  • Loading branch information
steelsojka committed May 3, 2017
1 parent d2c35ea commit 4efdd7c
Show file tree
Hide file tree
Showing 41 changed files with 88 additions and 85 deletions.
4 changes: 2 additions & 2 deletions src/after.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { after } from 'lodash';
import after = require('lodash/after');

import { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';
import { PostValueApplicator } from './applicators';
Expand All @@ -23,4 +23,4 @@ export const After: (n: number) => LodashDecorator = DecoratorFactory.createInst
new DecoratorConfig(after, new PostValueApplicator(), { setter: true })
);
export { After as after };
export default After;
export default After;
2 changes: 1 addition & 1 deletion src/afterAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { after } from 'lodash';
import after = require('lodash/after');

import { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';
import { PostValueApplicator } from './applicators';
Expand Down
6 changes: 3 additions & 3 deletions src/applicators/ComposeApplicator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { identity } from 'lodash';
import identity = require('lodash/identity');

import { Applicator, ApplicateOptions } from './Applicator';
import { resolveFunction } from '../utils';
Expand All @@ -11,7 +11,7 @@ export class ComposeApplicator extends Applicator {
get post(): boolean {
return this._config.post === true;
}

apply({ config: { execute }, value = identity, args, target }: ApplicateOptions): any {
const applicator = this;

Expand All @@ -29,4 +29,4 @@ export class ComposeApplicator extends Applicator {
return execute(..._args).apply(this, invokeArgs);
};
}
}
}
5 changes: 3 additions & 2 deletions src/applicators/MemoizeApplicator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isFunction, isObject } from 'lodash';
import isFunction = require('lodash/isFunction');
import isObject = require('lodash/isObject');

import { Applicator, ApplicateOptions } from './Applicator';
import { resolveFunction } from '../utils';
Expand Down Expand Up @@ -30,4 +31,4 @@ export class MemoizeApplicator extends Applicator {

return memoized;
}
}
}
4 changes: 2 additions & 2 deletions src/applicators/PartialedApplicator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { partial } from 'lodash';
import partial = require('lodash/partial');

import { Applicator, ApplicateOptions } from './Applicator';

export class PartialedApplicator extends Applicator {
apply({ config: { execute }, value, args }: ApplicateOptions): any {
return partial(execute, value, ...args);
}
}
}
2 changes: 1 addition & 1 deletion src/ary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ary } from 'lodash';
import ary = require('lodash/ary');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down
3 changes: 2 additions & 1 deletion src/attempt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { attempt, partial } from 'lodash';
import attempt = require('lodash/attempt');
import partial = require('lodash/partial');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down
4 changes: 2 additions & 2 deletions src/before.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { before } from 'lodash';
import before = require('lodash/before');

import { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';
import { PostValueApplicator } from './applicators';
Expand Down Expand Up @@ -30,4 +30,4 @@ export const Before: (n: number) => LodashDecorator = DecoratorFactory.createIns
new DecoratorConfig(before, new PostValueApplicator(), { setter: true })
);
export { Before as before };
export default Before;
export default Before;
2 changes: 1 addition & 1 deletion src/beforeAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { before } from 'lodash';
import before = require('lodash/before');

import { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';
import { PostValueApplicator } from './applicators';
Expand Down
4 changes: 2 additions & 2 deletions src/bind.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bind } from 'lodash';
import bind = require('lodash/bind');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { BindApplicator } from './applicators';
Expand Down Expand Up @@ -31,4 +31,4 @@ export const Bind: (...partials: any[]) => LodashMethodDecorator = DecoratorFact
new DecoratorConfig(bind, new BindApplicator())
);
export { Bind as bind };
export default Bind;
export default Bind;
4 changes: 2 additions & 2 deletions src/curry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curry } from 'lodash';
import curry = require('lodash/curry');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -32,4 +32,4 @@ export const Curry: (arity?: number) => LodashMethodDecorator = DecoratorFactory
new DecoratorConfig(curry, new PreValueApplicator(), { bound: true })
);
export { Curry as curry };
export default Curry;
export default Curry;
4 changes: 2 additions & 2 deletions src/curryAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curry } from 'lodash';
import curry = require('lodash/curry');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -30,4 +30,4 @@ export const CurryAll: (arity?: number) => LodashMethodDecorator = DecoratorFact
new DecoratorConfig(curry, new PreValueApplicator())
);
export { CurryAll as curryAll };
export default CurryAll;
export default CurryAll;
4 changes: 2 additions & 2 deletions src/curryRight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curryRight } from 'lodash';
import curryRight = require('lodash/curryRight');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -32,4 +32,4 @@ export const CurryRight: (arity?: number) => LodashMethodDecorator = DecoratorFa
new DecoratorConfig(curryRight, new PreValueApplicator(), { bound: true })
);
export { CurryRight as curryRight };
export default CurryRight;
export default CurryRight;
4 changes: 2 additions & 2 deletions src/curryRightAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curryRight } from 'lodash';
import curryRight = require('lodash/curryRight');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -30,4 +30,4 @@ export const CurryRightAll: (arity?: number) => LodashMethodDecorator = Decorato
new DecoratorConfig(curryRight, new PreValueApplicator())
);
export { CurryRightAll as curryRightAll };
export default CurryRightAll;
export default CurryRightAll;
4 changes: 2 additions & 2 deletions src/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce } from 'lodash';
import debounce = require('lodash/debounce');

import { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -43,4 +43,4 @@ export const Debounce: (wait?: number, options?: DebounceOptions) => LodashDecor
);

export { Debounce as debounce };
export default Debounce;
export default Debounce;
4 changes: 2 additions & 2 deletions src/debounceAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce } from 'lodash';
import debounce = require('lodash/debounce');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -44,4 +44,4 @@ export const DebounceAll: (wait?: number, options?: DebounceOptions) => LodashMe
new DecoratorConfig(debounce, new PreValueApplicator())
);
export { DebounceAll as debounceAll };
export default DebounceAll;
export default DebounceAll;
4 changes: 2 additions & 2 deletions src/defer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defer } from 'lodash';
import defer = require('lodash/defer');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { InvokeApplicator } from './applicators';
Expand Down Expand Up @@ -31,4 +31,4 @@ export const Defer: (...args: any[]) => LodashMethodDecorator = DecoratorFactory
new DecoratorConfig(defer, new InvokeApplicator(), { setter: true })
);
export { Defer as defer };
export default Defer;
export default Defer;
4 changes: 2 additions & 2 deletions src/delay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay } from 'lodash';
import delay = require('lodash/delay');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand Down Expand Up @@ -40,4 +40,4 @@ export const Delay: (wait: number, ...args: any[]) => LodashMethodDecorator = De
)
);
export { Delay as delay };
export default Delay;
export default Delay;
18 changes: 9 additions & 9 deletions src/factory/DecoratorFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isFunction } from 'lodash';
import isFunction = require('lodash/isFunction');

import {
InstanceChainMap,
import {
InstanceChainMap,
LodashDecorator,
InstanceChainContext
} from './common';
Expand Down Expand Up @@ -60,7 +60,7 @@ export class InternalDecoratorFactory {
}

return copyMetadata(
applicator.apply({ args, target, instance, value: fn, config }),
applicator.apply({ args, target, instance, value: fn, config }),
fn
);
});
Expand All @@ -83,11 +83,11 @@ export class InternalDecoratorFactory {
// If we have a getter apply the decorators to the getter and assign it to the instance.
if (isGetter) {
getter = applyChain(get, { value: get, getter: true }, instance);
}
}

if (isSetter) {
setter = applyChain(set, { value: set, setter: true }, instance);
}
}

Object.defineProperty(instance, name, {
enumerable,
Expand All @@ -96,8 +96,8 @@ export class InternalDecoratorFactory {
set: setter
});
} else if (isMethod || isProperty) {
const newFn = isMethod
? applyChain(value, { value, method: true }, instance)
const newFn = isMethod
? applyChain(value, { value, method: true }, instance)
: applyChain(value, { value, property: true }, instance);

Object.defineProperty(instance, name, {
Expand Down Expand Up @@ -145,7 +145,7 @@ export class InternalDecoratorFactory {

private _isApplicable(context: InstanceChainContext, config: DecoratorConfig): boolean {
return !Boolean(
context.getter && !config.getter
context.getter && !config.getter
|| context.setter && !config.setter
|| context.method && !config.method
|| context.property && !config.property
Expand Down
4 changes: 2 additions & 2 deletions src/flip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flip } from 'lodash';
import flip = require('lodash/flip');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand All @@ -25,4 +25,4 @@ export const Flip: () => LodashMethodDecorator = DecoratorFactory.createDecorato
new DecoratorConfig(flip, new PreValueApplicator())
);
export { Flip as flip };
export default Flip;
export default Flip;
4 changes: 2 additions & 2 deletions src/flow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flow } from 'lodash';
import flow = require('lodash/flow');

import {
DecoratorConfig,
Expand Down Expand Up @@ -32,4 +32,4 @@ export const Flow: (...fns: ResolvableFunction[]) => LodashDecorator = Decorator
new DecoratorConfig(flow, new ComposeApplicator({ post: true }), { property: true })
);
export { Flow as flow };
export default Flow;
export default Flow;
4 changes: 2 additions & 2 deletions src/flowRight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flowRight } from 'lodash';
import flowRight = require('lodash/flowRight');

import {
DecoratorConfig,
Expand Down Expand Up @@ -32,4 +32,4 @@ export const FlowRight: (...fns: ResolvableFunction[]) => LodashDecorator = Deco
new DecoratorConfig(flowRight, new ComposeApplicator({ post: false }), { property: true })
);
export { FlowRight as flowRight };
export default FlowRight;
export default FlowRight;
4 changes: 2 additions & 2 deletions src/memoize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memoize } from 'lodash';
import memoize = require('lodash/memoize');

import {
DecoratorConfig,
Expand All @@ -13,4 +13,4 @@ export const Memoize: (resolver?: ResolvableFunction|MemoizeConfig<any, any>) =>
new DecoratorConfig(memoize, new MemoizeApplicator())
);
export { Memoize as memoize };
export default Memoize;
export default Memoize;
4 changes: 2 additions & 2 deletions src/memoizeAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memoize } from 'lodash';
import memoize = require('lodash/memoize');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { MemoizeApplicator } from './applicators';
Expand All @@ -12,4 +12,4 @@ export const MemoizeAll: (resolver?: Function|MemoizeConfig<any, any>) => Lodash
new DecoratorConfig(memoize, new MemoizeApplicator())
);
export { MemoizeAll as memoizeAll };
export default MemoizeAll;
export default MemoizeAll;
4 changes: 2 additions & 2 deletions src/mixin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assign } from 'lodash';
import assign = require('lodash/assign');

export function Mixin(...srcs: Object[]): ClassDecorator {
return (target: Function) => {
Expand All @@ -8,4 +8,4 @@ export function Mixin(...srcs: Object[]): ClassDecorator {
};
}
export { Mixin as mixin };
export default Mixin;
export default Mixin;
4 changes: 2 additions & 2 deletions src/negate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { negate } from 'lodash';
import negate = require('lodash/negate');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand All @@ -7,4 +7,4 @@ export const Negate: () => LodashMethodDecorator = DecoratorFactory.createDecora
new DecoratorConfig(negate, new PreValueApplicator())
);
export { Negate as negate };
export default Negate;
export default Negate;
4 changes: 2 additions & 2 deletions src/once.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { once } from 'lodash';
import once = require('lodash/once');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand All @@ -7,4 +7,4 @@ export const Once: () => LodashMethodDecorator = DecoratorFactory.createInstance
new DecoratorConfig(once, new PreValueApplicator(), { setter: true })
);
export { Once as once };
export default Once;
export default Once;
4 changes: 2 additions & 2 deletions src/onceAll.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { once } from 'lodash';
import once = require('lodash/once');

import { DecoratorConfig, DecoratorFactory } from './factory';
import { PreValueApplicator } from './applicators';

export const OnceAll = DecoratorFactory.createDecorator(new DecoratorConfig(once, new PreValueApplicator(), { setter: true }))();
export { OnceAll as onceAll };
export default OnceAll;
export default OnceAll;
4 changes: 2 additions & 2 deletions src/overArgs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { overArgs } from 'lodash';
import overArgs = require('lodash/overArgs');

import { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';
import { PreValueApplicator } from './applicators';
Expand All @@ -7,4 +7,4 @@ export const OverArgs: (...transforms: Function[]) => LodashMethodDecorator = De
new DecoratorConfig(overArgs, new PreValueApplicator(), { setter: true })
);
export { OverArgs as overArgs };
export default OverArgs;
export default OverArgs;
Loading

0 comments on commit 4efdd7c

Please sign in to comment.