Skip to content

Commit

Permalink
feat(core/utils): extract firstDefined utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Oct 10, 2019
1 parent b553465 commit 2d6c9e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/scripts/modules/core/src/utils/firstDefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { isNil } from 'lodash';

/** returns the first value that is neither null nor undefined */
export function firstDefined<T>(...values: T[]): T {
return values.find(val => !isNil(val));
}
3 changes: 2 additions & 1 deletion app/scripts/modules/core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
///<reference path="./classnames.d.ts" />

export * from './RenderWhenVisible';
export * from './clipboard/CopyToClipboard';
export * from './debug';
export * from './firstDefined';
export * from './json/JsonUtils';
export * from './json/traverseObject';
export * from './noop';
export * from './q';
export * from './renderIfFeature.component';
export * from './RenderWhenVisible';
export * from './scrollTo/scrollTo.service';
export * from './timeFormatters';
export * from './unicodeBase64';
Expand Down

0 comments on commit 2d6c9e7

Please sign in to comment.