- [Vim]
- Disable
CTRL+C
andCTRL+V
"vim.handleKeys": { "<C-c>": false, "<C-v>": false }
- Disable
- Singleton
- Fluent Interface
- Observer
- Composite
- Abstract factory
https://www.netguru.com/codestories/top-5-most-used-patterns-in-oop-with-typescript
https://debugpointer.com/check-if-an-object-is-a-promise/
function isPromise(p) {
return p && Object.prototype.toString.call(p) === "[object Promise]";
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Dictionary<T> = { | |
[key: string]: T; | |
}; | |
export class GlobalStore { | |
static get(key: string) { | |
if (getGlobalStore().data === undefined) | |
getGlobalStore().data = {}; | |
if (getGlobalStore().data[key] === undefined) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'reflect-metadata'; | |
import { ReflectiveInjector, Injectable, Injector } from 'injection-js'; | |
class Service { | |
get() { | |
return "my service"; | |
} | |
} | |
class Service2 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit | |
// https://www.stevefenton.co.uk/2014/07/creating-typescript-classes-dynamically | |
// https://gist.github.com/mfdeveloper/c337408608d6033fde967fc2e76b12c4 | |
interface ObjectKeyString { | |
[key: string]: any; | |
} | |
class InstanceLoader { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
const { format } = winston; | |
const formatConsole = format.printf(( { message, level, timestamp }: any ) => { | |
return `${timestamp} ${level}: ${message}`; | |
}); | |
const formatFile = format.printf(( { message, level, timestamp }: any ) => { | |
return JSON.stringify({ message, level, timestamp }); | |
}); |