Skip to content

Instantly share code, notes, and snippets.

def level_bfs():
queue = []
queue.append(root)
while queue:
size = len(queue)
node = queue.pop(0)
while size:
if node.left:
// reference: https://github.com/wclr/yalc/issues/22#issuecomment-719903924
"scripts": {
"dev-watch": "tsc-watch --onSuccess \"yalc push\""
}
{
"dependencies": {
"B": "file:./B-1.0.0.tgz"
}
}
$ cd <package>
$ yarn pack
{package}-{version}.tgz file created!
$ cd <project>
$ cp <package>/{package}-{version}.tgz /path/to/project/
$ yarn add /path/to/project/{package}-{version}.tgz
// 런타임에 특정 패키지를 바라보는 경로를 수정
function alias() {
const moduleAlias = require('module-alias')
if (process.env.STAGE !== 'local') {
return
}
// 개발자가 로컬 환경에서 실행하는 경우
const cache: any = {}
const typeorm = 'typeorm'
const entity = new ExampleRepository()
getRepositoryName(entity) // "validRepositoryName" OR Error
// A/getRepositoryName.ts
import { Repository } from "typeorm"
export function getRepositoryName(entity: EntityClass) {
if (entity instanceof Repository) {
return "validRepositoryName"
}
throw new Error("entity is not a valid typeorm Repository")
}
// project/ExampleRepository.ts
import { Repository } from "B"
export class ExampleRepository extends Repository {}
// B/index.ts
export * from "typeorm"
node_modules
packageA
packageB
typeorm x.y.z