Files
agent/packages/uhk-common/src/util/index.ts
Róbert Kiss c4d7318686 chore: make firmware update log shorter (#675)
* chore: add lodash to the roor package.json

* chore: make firmware update log shorter
2018-06-13 10:07:40 +02:00

43 lines
1.2 KiB
TypeScript

export { IpcEvents } from './ipcEvents';
export * from './log';
export * from './constants';
export * from './helpers';
export * from './is-equal-array';
// Source: http://stackoverflow.com/questions/13720256/javascript-regex-camelcase-to-sentence
export function camelCaseToSentence(camelCasedText: string): string {
return camelCasedText.replace(/^[a-z]|[A-Z]/g, function (v, i) {
return i === 0 ? v.toUpperCase() : ' ' + v.toLowerCase();
});
}
export function capitalizeFirstLetter(text: string): string {
return text.charAt(0).toUpperCase() + text.slice(1);
}
/**
* This function coerces a string into a string literal type.
* Using tagged union types in TypeScript 2.0, this enables
* powerful typechecking of our reducers.
*
* Since every action label passes through this function it
* is a good place to ensure all of our action labels
* are unique.
*/
const typeCache: { [label: string]: boolean } = {};
export function type<T>(label: T | ''): T {
if (typeCache[<string>label]) {
throw new Error(`Action type "${label}" is not unique"`);
}
typeCache[<string>label] = true;
return <T>label;
}
export function runInElectron() {
return window && (<any>window).process && (<any>window).process.type;
}