How to use iterare - 10 common examples

To help you get started, we’ve selected a few iterare examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjs / nest / packages / core / metadata-scanner.ts View on Github external
*getAllFilteredMethodNames(prototype: any): IterableIterator {
    do {
      yield* iterate(Object.getOwnPropertyNames(prototype))
        .filter(prop => {
          const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
          if (descriptor.set || descriptor.get) {
            return false;
          }
          return !isConstructor(prop) && isFunction(prototype[prop]);
        })
        .toArray();
    } while (
      // tslint:disable-next-line:no-conditional-assignment
      (prototype = Reflect.getPrototypeOf(prototype)) &&
      prototype !== Object.prototype
    );
  }
}
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
private _publishDiagnostics(uri: string, span = new Span()): void {
		const config = this.projectManager.getParentConfiguration(uri);
		if (!config) {
			return;
		}
		const program = config.getProgram(span);
		if (!program) {
			return;
		}
		const sourceFile = program.getSourceFile(uri2path(uri));
		if (!sourceFile) {
			return;
		}
		const tsDiagnostics = ts.getPreEmitDiagnostics(program, sourceFile);
		const diagnostics = iterate(tsDiagnostics)
			// TS can report diagnostics without a file and range in some cases
			// These cannot be represented as LSP Diagnostics since the range and URI is required
			// https://github.com/Microsoft/TypeScript/issues/15666
			.filter(diagnostic => !!diagnostic.file)
			.map(convertTsDiagnostic)
			.toArray();
		this.client.textDocumentPublishDiagnostics({ uri, diagnostics });
	}
github nestjs / nest / packages / core / hooks / on-module-init.hook.ts View on Github external
function callOperator(instances: InstanceWrapper[]): Promise[] {
  return iterate(instances)
    .filter(instance => !isNil(instance))
    .filter(hasOnModuleInitHook)
    .map(async instance => ((instance as any) as OnModuleInit).onModuleInit())
    .toArray();
}
github nestjs / nest / packages / core / hooks / on-app-shutdown.hook.ts View on Github external
function callOperator(
  instances: InstanceWrapper[],
  signal?: string,
): Promise[] {
  return iterate(instances)
    .filter(instance => !isNil(instance))
    .filter(hasOnAppShutdownHook)
    .map(async instance =>
      ((instance as any) as OnApplicationShutdown).onApplicationShutdown(
        signal,
      ),
    )
    .toArray();
}
github nestjs / nest / packages / core / hooks / on-module-destroy.hook.ts View on Github external
function callOperator(instances: InstanceWrapper[]): Promise[] {
  return iterate(instances)
    .filter(instance => !isNil(instance))
    .filter(hasOnModuleDestroyHook)
    .map(async instance =>
      ((instance as any) as OnModuleDestroy).onModuleDestroy(),
    )
    .toArray();
}
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
private _publishDiagnostics(uri: string, span = new Span()): void {
        const config = this.projectManager.getParentConfiguration(uri)
        if (!config) {
            return
        }
        const fileName = uri2path(uri)
        const tsDiagnostics = config
            .getService()
            .getSyntacticDiagnostics(fileName)
            .concat(
                config
                    .getService()
                    .getSemanticDiagnostics(fileName)
                    .filter((e): e is ts.DiagnosticWithLocation => !!e.file)
            )
        const diagnostics = iterate(tsDiagnostics)
            .map(convertTsDiagnostic)
            .toArray()
        this.client.textDocumentPublishDiagnostics({ uri, diagnostics })
    }
github nestjs / nest / packages / core / guards / guards-context-creator.ts View on Github external
public createConcreteContext(
    metadata: T,
    contextId = STATIC_CONTEXT,
    inquirerId?: string,
  ): R {
    if (isEmpty(metadata)) {
      return [] as R;
    }
    return iterate(metadata)
      .filter((guard: any) => guard && (guard.name || guard.canActivate))
      .map(guard => this.getGuardInstance(guard, contextId, inquirerId))
      .filter((guard: CanActivate) => guard && isFunction(guard.canActivate))
      .toArray() as R;
  }
github nestjs / nest / src / core / guards / guards-context-creator.ts View on Github external
public createConcreteContext(metadata: T): R {
        if (isUndefined(metadata) || isEmpty(metadata) || !this.moduleContext) {
            return [] as R;
        }
        const isGlobalMetadata = metadata === this.getGlobalMetadata();
        return isGlobalMetadata ?
            this.createGlobalMetadataContext(metadata) :
            iterate(metadata).filter((metatype: any) => metatype && metatype.name)
                .map((metatype) => this.getInstanceByMetatype(metatype))
                .filter((wrapper: any) => wrapper && wrapper.instance)
                .map((wrapper) => wrapper.instance)
                .filter((guard: CanActivate) => guard && isFunction(guard.canActivate))
                .toArray() as R;
    }
github nestjs / nest / src / microservices / nest-microservice.ts View on Github external
private callModuleDestroyHook(module: Module) {
    const components = [...module.routes, ...module.components];
    iterate(components)
      .map(([key, { instance }]) => instance)
      .filter(instance => !isNil(instance))
      .filter(this.hasOnModuleDestroyHook)
      .forEach(instance => (instance as OnModuleDestroy).onModuleDestroy());
  }
github nestjs / nest / lib / websockets / middlewares-injector.js View on Github external
applyMiddlewares(server, components, tokens) {
        const adapter = this.config.getIoAdapter();
        iterare_1.default(tokens)
            .map(token => this.bindMiddleware(token.name, components))
            .filter(middleware => !shared_utils_1.isNil(middleware))
            .forEach(middleware => adapter.bindMiddleware(server, middleware));
    }
    bindMiddleware(token, components) {

iterare

Array methods for ES6 Iterators

ISC
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular iterare functions