repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
Mabloq/mabloq-notion
app/src/block/interfaces/blocks/image.interface.ts
import { BaseBlockInterface } from '../block.interface'; import { FileObjectInterface } from '../common/file-object.interface'; export interface ImageBlockInterface extends BaseBlockInterface { image: FileObjectInterface; }
Mabloq/mabloq-notion
app/src/block/tests/services/block.service.spec.ts
<filename>app/src/block/tests/services/block.service.spec.ts import { Test, TestingModule } from '@nestjs/testing'; import { BlockService } from '../../services/block.service'; import { getModelToken } from '@nestjs/mongoose'; import { Query, Model } from 'mongoose'; import { BlockInterface } from '../../interfaces/blo...
Mabloq/mabloq-notion
app/src/block/controllers/page.controller.ts
import { Controller, Get, Post, Body, Patch, Param, Delete, } from '@nestjs/common'; import { CreateDatabaseDto } from '../dto/database/create-database.dto'; import { DatabaseService } from '../services/database.service'; @Controller('/api/rest/v1/page') export class PageController { constructor(privat...
Mabloq/mabloq-notion
app/src/block/schemas/blocks/paragraph.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document } from 'mongoose'; import { BlockInterface, ParagraphInterface, ParagraphBlockInterface, BaseBlockInterface, } from 'src/block/interfaces'; import { RichTextInterface } from 'src/block/interfaces/common/rich-text.interface'; impo...
Mabloq/mabloq-notion
app/src/block/schemas/properties/property-types/select-property.schema.ts
import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose'; import { Document } from 'mongoose'; @Schema() export class SelectProperty { @Prop( raw({ name: { type: String, required: true }, }), ) select: { name: string }; } export const SelectPropertySchema = SchemaFactory.createForClas...
Mabloq/mabloq-notion
app/src/block/block.module.ts
import { Module } from '@nestjs/common'; import { BlockService } from './services/block.service'; import { BlockController } from './controllers/block.controller'; import { MongooseModule } from '@nestjs/mongoose'; import { Block, BlockSchema } from './schemas/block.schema'; import { BlockEnum } from './schemas/common/...
Mabloq/mabloq-notion
app/src/block/interfaces/page.interface.ts
import { HigherOrderBlockInterface } from './high-order-block.interface'; import { PropertyInterface } from './properties/property.interface'; export interface PageInterface extends HigherOrderBlockInterface { properties: { title: PropertyInterface; [key: string | symbol]: PropertyInterface; }; has_conten...
Mabloq/mabloq-notion
app/src/block/interfaces/common/parent.interface.ts
export interface DatabaseParentInterface { type: 'database'; database_id: string; } export interface PageParentInterface { type: 'page'; page_id: string; } export interface WorkspaceParentInterface { type: 'workspace'; workspace_id: string; } export type ParentInerface = | WorkspaceParentInterface | ...
Mabloq/mabloq-notion
app/src/block/dto/append-block-children.dto.ts
<reponame>Mabloq/mabloq-notion<gh_stars>0 import { ApiProperty } from '@nestjs/swagger'; import { BlockModelRefs, BlockDTOs } from './extra-models/block-models'; export class CreateBlockDto { @ApiProperty({ required: true }) block_id: string; @ApiProperty({ type: 'array', items: { anyOf: BlockModel...
Mabloq/mabloq-notion
app/src/block/dto/extra-models/properties/property-types/select-property.dto.ts
<gh_stars>0 import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger'; import { SelectPropertyInterface } from 'src/block/interfaces/properties/property-types/select-property.interface'; @ApiExtraModels() export class SelectNameDto { @ApiProperty() name: string; } @ApiExtraModels() export class ...
Mabloq/mabloq-notion
app/src/block/schemas/properties/property-types/multi-select-property.schema.ts
<filename>app/src/block/schemas/properties/property-types/multi-select-property.schema.ts import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose'; import { Document } from 'mongoose'; @Schema() export class MultiSelectProperty { @Prop( raw({ name: { type: [{ name: String }], required: true }, ...
Mabloq/mabloq-notion
app/src/block/schemas/common/block-enum.ts
export enum BlockEnum { PARAGRAPH = 'paragraph', HEADING1 = 'heading_1', IMAGE = 'image', CODE = 'code', FILE = 'file', } export type BlockType = | BlockEnum.PARAGRAPH | BlockEnum.HEADING1 | BlockEnum.IMAGE | BlockEnum.FILE | BlockEnum.CODE;
Mabloq/mabloq-notion
app/src/block/schemas/blocks/heading-1.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document } from 'mongoose'; import { Heading1BlockInterface, Heading1Interface, } from 'src/block/interfaces'; import { RichTextInterface } from 'src/block/interfaces/common/rich-text.interface'; import { RichTextSchema } from '../common/rich...
Mabloq/mabloq-notion
app/src/block/dto/extra-models/blocks/heading1.dto.ts
import { ApiProperty, ApiExtraModels, getSchemaPath } from '@nestjs/swagger'; import { RichTextDto } from '../common/rich-text.dto'; import { BaseBlockDto } from '../base-block.dto'; @ApiExtraModels(RichTextDto) export class Heading1Dto { @ApiProperty({ required: false }) color: string; @ApiProperty({ requir...
Mabloq/mabloq-notion
app/src/block/dto/extra-models/parents/database-parent.dto.ts
<gh_stars>0 import { ApiExtraModels, ApiProperty } from '@nestjs/swagger'; import { DatabaseParentInterface } from 'src/block/interfaces/common/parent.interface'; @ApiExtraModels() export class DatabaseParentDto implements DatabaseParentInterface { @ApiProperty({ default: 'database', required: true, }) t...
Mabloq/mabloq-notion
app/src/block/interfaces/properties/property-config/select-config.interface.ts
export interface SelectOptionInterface { id: string; color: string; name: string; } export interface SelectConfigInterface { type: 'select'; options: SelectOptionInterface[]; }
Mabloq/mabloq-notion
app/src/block/dto/create-block.dto.ts
<filename>app/src/block/dto/create-block.dto.ts import { BlockDTOs } from './extra-models/block-models'; export type CreateBlockDto = BlockDTOs;
Mabloq/mabloq-notion
app/src/block/schemas/page.schema.ts
<reponame>Mabloq/mabloq-notion<filename>app/src/block/schemas/page.schema.ts import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; import { Block, BlockSchema } from './block.schema'; import { RichText, RichTextSchema } from './common/rich-text.sc...
Mabloq/mabloq-notion
app/src/block/interfaces/high-order-block.interface.ts
import { ParentInerface } from './common/parent.interface'; import { PropertyInterface } from './properties/property.interface'; import { FileObjectInterface } from './common/file-object.interface'; export interface HigherOrderBlockInterface { id?: string; object: string; parent?: ParentInerface; parent_id?: st...
Mabloq/mabloq-notion
app/src/block/interfaces/database.interface.ts
<filename>app/src/block/interfaces/database.interface.ts import { PropertyConfigInterface } from './properties/property.interface'; import { HigherOrderBlockInterface } from './high-order-block.interface'; export interface DatabaseInterface extends HigherOrderBlockInterface { properties: { title: PropertyConfigI...
Mabloq/mabloq-notion
app/src/block/interfaces/properties/property-types/number-property.interface.ts
export interface NumberPropertyInterface { type: 'number'; number: number; }
Mabloq/mabloq-notion
app/src/block/tests/mocks/page/index.ts
<gh_stars>0 import { BlockDTOs } from 'src/block/dto/extra-models/block-models'; import { CreatePageDto } from 'src/block/dto/page/create-page.dto'; import { ParentInerface } from 'src/block/interfaces/common/parent.interface'; import { PageInterface } from 'src/block/interfaces/page.interface'; import { PropertiesInte...
Mabloq/mabloq-notion
app/src/block/utils/page-validators/validators/page-parent-validator.ts
import { CreatePageDto } from '../../../dto/page/create-page.dto'; import IPageValidator from '../page-validator-interface'; import { PropertiesInterface } from '../../../interfaces/properties/property.interface'; export default class PageParentValidator implements IPageValidator { private createPageDto: CreatePageD...
Mabloq/mabloq-notion
app/src/block/schemas/higher-order-block.schema.ts
<filename>app/src/block/schemas/higher-order-block.schema.ts import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; import { ParentSchema } from './parents/parent.schema'; import { ImageSchema } from './common/image.schema'; import { FileObjectInte...
Mabloq/mabloq-notion
app/src/block/dto/extra-models/common/annotations.dto.ts
import { ApiProperty } from '@nestjs/swagger'; export class AnnotationDto { @ApiProperty({ type: 'boolean', default: false, }) bold: boolean; @ApiProperty({ type: 'boolean', default: false, }) italic: boolean; @ApiProperty({ type: 'boolean', default: false, }) strikethrough: b...
Mabloq/mabloq-notion
app/src/block/schemas/common/rich-text.schema.ts
<gh_stars>0 import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose'; @Schema({ _id: false }) export class RichText { @Prop({ required: true, default: 'text' }) type: string; @Prop( raw({ content: { type: String, required: true }, link: { type: String, required: false }, }), ) ...
Mabloq/mabloq-notion
app/src/block/services/database.service.ts
<reponame>Mabloq/mabloq-notion import { Injectable } from '@nestjs/common'; import { CreateDatabaseDto } from '../dto/database/create-database.dto'; import { Model, FilterQuery } from 'mongoose'; import { InjectModel } from '@nestjs/mongoose'; import { HigherOrderBlock } from '../schemas/higher-order-block.schema'; imp...
Mabloq/mabloq-notion
app/src/block/schemas/common/file-object.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { FileObjectInterface } from 'src/block/interfaces/common/file-object.interface'; @Schema({ _id: false }) export class FileObject implements FileObjectInterface { @Prop({ default: 'external' }) type: string; @Prop({ required: true }) url: s...
joejensen/react-bouncing-balls
src/Vector.tsx
/** * A basic 3d vector used to track position and velocity of the balls */ export class Vector { constructor(public x: number, public y: number, public z: number) { } setValue(x: number, y: number, z: number): void { this.x = x; this.y = y; this.z = z; } }
joejensen/react-bouncing-balls
src/BouncingBallsDiv.tsx
/** * @class BouncingBallsDivComponent */ import * as React from 'react'; import {RefObject} from "react"; import {PointCollection} from "./PointCollection"; export type BouncingBallsDivProps = { src: string; width: number; height: number; cellSize: number; } export default class BouncingBallsDivComponent e...
joejensen/react-bouncing-balls
src/Point.tsx
import {Vector} from './vector'; /** * A point tracks the size and position of each ball */ export class Point { public curPos: Vector; public friction: number; public originalPos: Vector; public radius: number; public size: number; public springStrength: number; public targetPos: Vector; public velo...
joejensen/react-bouncing-balls
src/BouncingBallsCanvas.tsx
/** * @class BouncingBallsCanvasComponent */ import * as React from 'react'; import {RefObject} from "react"; import {PointCollection} from "./PointCollection"; import {BouncingBallsDivProps} from "./BouncingBallsDiv"; export type BouncingBallsCanvasProps = { src: string; width: number; height: number; cellS...
joejensen/react-bouncing-balls
src/PointCollection.tsx
import {Vector} from './vector'; import {Point} from './point'; /** * A collection of points / balls to be rendered to either a canvas or the dom as well as utilities to populate it */ export class PointCollection { public mousePos: Vector = new Vector(0, 0, 0); public points: Point[] = []; /** * Generates...
joejensen/react-bouncing-balls
src/index.tsx
<reponame>joejensen/react-bouncing-balls import BouncingBallsCanvasComponent from './BouncingBallsCanvas'; import BouncingBallsDivComponent from './BouncingBallsDiv'; import './index.css'; export {BouncingBallsDivComponent, BouncingBallsCanvasComponent}; export default {BouncingBallsDivComponent, BouncingBallsCanvasCo...
virginiah894/Quotes
src/app/highlight.directive.ts
import { Directive, ElementRef , HostListener} from '@angular/core'; @Directive({ selector: '[appHighlight]' }) export class HighlightDirective { constructor(private elem:ElementRef) { // @HostListener("mouseenter") onmouseenter(){ // this.colorChange("red") // } // @HostListener("mouseleave") onmousele...
virginiah894/Quotes
src/app/dates.pipe.ts
<reponame>virginiah894/Quotes<filename>src/app/dates.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'dates' }) export class DatesPipe implements PipeTransform { transform(value: any):number{ let today:Date = new Date(); //get current date and time let todayWithNoTime:any = new Date(tod...
virginiah894/Quotes
src/app/quote.ts
<gh_stars>1-10 export class Quote { showAuthor:boolean; constructor(public id:number,public name:string,public author:string,public datePublished:Date,public submitter:string, public upvote:number,public downvote:number,){ this.showAuthor=false; } }
syrflover/iterator-helper
deno/methods/min.ts
import { compare } from "../lib/compare/mod.ts"; import { minBy } from "./minBy.ts"; export function min<T>(iter: AsyncIterable<T>): Promise<T | undefined> { return minBy(compare, iter); }
syrflover/iterator-helper
deno/lib/iterable/toAsyncIterable.ts
<filename>deno/lib/iterable/toAsyncIterable.ts import { isArrayLikeOrString } from '../../types/guards/isArrayLikeOrString.ts'; import { toIterable } from './toIterable.ts'; export function toAsyncIterable<T>( iter: Iterable<T> | AsyncIterable<T> | Promise<Iterable<T>> | Promise<AsyncIterable<T>>, ): AsyncIterabl...
syrflover/iterator-helper
src/lib/iterable/toAsyncIterable_test.ts
<filename>src/lib/iterable/toAsyncIterable_test.ts import { assertEquals, assert } from 'https://deno.land/std/testing/asserts.ts'; import { toAsyncIterable } from './mod.ts'; function* iterable(): Iterable<number> { yield 1; yield 2; yield 3; yield 4; } async function* asyncIterable(): AsyncIterable...
syrflover/iterator-helper
deno/lib/iterable/init.ts
import { initLast } from './initLast.ts'; export async function* init<T>(iter: AsyncIterable<T>) { const [r] = await initLast(iter); yield* r; }
syrflover/iterator-helper
deno/methods/scan.ts
<reponame>syrflover/iterator-helper import type { ScanFn } from "../types/functions/mod.ts"; import { _curry, Curry2 } from "../lib/utils/mod.ts"; async function* _scan_impl_fn<A, B>( fn: ScanFn<A, B>, init: B | Promise<B>, iter: AsyncIterable<A>, ): AsyncIterable<B> { let state = await init; yield state; ...
syrflover/iterator-helper
deno/lib/utils/curry.ts
export function curry<P1, P2, R>(f: (p1: P1, p2: P2) => R): Curry2<P1, P2, R>; export function curry<P1, P2, P3, R>(f: (p1: P1, p2: P2, p3: P3) => R): Curry3<P1, P2, P3, R>; export function curry<P1, P2, P3, P4, R>(f: (p1: P1, p2: P2, p3: P3, p4: P4) => R): Curry4<P1, P2, P3, P4, R>; export function curry<P1, P2, P3, P...
syrflover/iterator-helper
src/types/guards/isIterable_test.ts
<filename>src/types/guards/isIterable_test.ts<gh_stars>1-10 import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { isIterable } from './mod.ts'; function* iterable() { yield 1; yield 2; yield 3; yield 4; } async function* asyncIterable() { yield 1; yield 2; yiel...
syrflover/iterator-helper
src/methods/cycle.ts
import { getLogger } from '../logger.ts'; const logger = await getLogger('methods/cycle'); async function* _cycle_impl_fn<T>(iter: AsyncIterable<T>): AsyncIterable<T> { logger.trace('cycle()'); const r: T[] = []; for await (const elem of iter) { yield elem; r.push(elem); } while ...
syrflover/iterator-helper
src/types/guards/isString_test.ts
<gh_stars>1-10 import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { isString } from './mod.ts'; Deno.test('isString() string', () => { const actual = isString('hello'); const expected = true; assertEquals(actual, expected); }); Deno.test('isString() array', () => { const...
syrflover/iterator-helper
scripts/lib/readDir.ts
<gh_stars>1-10 /* eslint-disable */ export async function* readDir(dir: string, ex: string[] = []): AsyncIterable<string> { const files = Deno.readDir(dir); // const entries: string[] = []; for await (const file of files) { try { if (ex.includes(`${dir}/${file.name}`)) { ...
syrflover/iterator-helper
src/lib/utils/flip_test.ts
<filename>src/lib/utils/flip_test.ts<gh_stars>1-10 import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { flip } from './mod.ts'; Deno.test('flip() div', () => { const actual = flip((a, b) => a / b, 1, 2); const expected = 2 / 1; assertEquals(actual, expected); });
syrflover/iterator-helper
deno/lib/utils/flip.ts
// (A -> B -> C) -> B -> A -> C export function flip<A, B, C>(fn: (a: A, b: B) => C, b: B, a: A) { return fn(a, b); }
syrflover/iterator-helper
deno/lib/compare/compare.ts
<filename>deno/lib/compare/compare.ts import { Ord } from '../../types/ordering.ts'; export function compare<T>(a: T, b: T): Ord { if (a < b) { return Ord.Less; } if (a > b) { return Ord.Greater; } return Ord.Equal; }
syrflover/iterator-helper
deno/methods/take.ts
<reponame>syrflover/iterator-helper<filename>deno/methods/take.ts import { _curry } from "../lib/utils/mod.ts"; async function* _take_impl_fn<T>( limit: number, iter: AsyncIterable<T>, ): AsyncIterable<T> { let current = 1; for await (const elem of iter) { if (current > limit) { return; } y...
syrflover/iterator-helper
src/types/guards/isArrayLike.ts
export function isTypedArray(a: any) { return ArrayBuffer.isView(a); } export function isArrayLike(a: any): a is any[] { return Array.isArray(a) || isTypedArray(a); }
syrflover/iterator-helper
src/methods/inspect_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('inspect() [1, 2, 3, 4]', async () => { const a = iterator([1, 4, 2, 3]); const actual: number[] = []; const expected = [1, 4, 2, 3]; const i = a.inspect((e) => { actual.p...
syrflover/iterator-helper
src/methods/unzip_test.ts
<reponame>syrflover/iterator-helper import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import type { Pair } from '../types/mod.ts'; import { iterator } from '../mod.ts'; Deno.test('unzip() [[1, 5], [2, 6], [3, 7], [4, 8]]', async () => { const a = iterator<Pair<number, number>>([ [1,...
syrflover/iterator-helper
src/methods/max.ts
import { getLogger } from '../logger.ts'; import { compare } from '../lib/compare/mod.ts'; import { maxBy } from './maxBy.ts'; const logger = await getLogger('methods/max'); export function max<T>(iter: AsyncIterable<T>): Promise<T | undefined> { logger.trace('max()'); return maxBy(compare, iter); }
syrflover/iterator-helper
deno/methods/average.ts
import { Pair, pair } from "../types/mod.ts"; import { fold } from "./fold.ts"; export async function _average_impl_fn(iter: AsyncIterable<number>) { const [count, summed] = await fold( ([current, value]: Pair<number, number>, e: number) => pair(current + 1, value + e), pair(0, 0), iter, ); re...
syrflover/iterator-helper
deno/lib/compare/min.ts
<filename>deno/lib/compare/min.ts import { id } from '../utils/mod.ts'; import { compare } from './compare.ts'; import { minBy } from './minBy.ts'; export function min<T>(a: T, b: T): Promise<T> { return minBy(id, compare, a, b); }
syrflover/iterator-helper
src/methods/find_test.ts
<filename>src/methods/find_test.ts import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('find(3) === 3', async () => { const a = iterator([1, 2, 3, 4, 5]); const actual = await a.find((e) => e === 3); const expected = 3; assertEqual...
syrflover/iterator-helper
deno/methods/map.ts
import type { MapFn } from "../types/functions/mod.ts"; import { _curry } from "../lib/utils/mod.ts"; async function* _map_impl_fn<T, R>( fn: MapFn<T, R>, iter: AsyncIterable<T>, ): AsyncIterable<R> { for await (const elem of iter) { const mapped = await fn(elem); yield mapped; } } export interface ...
syrflover/iterator-helper
src/lib/iterable/init_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { init } from './mod.ts'; async function* asyncIterable() { yield 1; yield 2; yield 3; yield 4; } Deno.test('init() [1, 2, 3, 4]', async () => { const actual: number[] = []; const expected = [1, 2, 3]; for aw...
syrflover/iterator-helper
scripts/deno_build.ts
/* eslint-disable */ import { dirname } from 'https://deno.land/std/path/mod.ts'; import { readDir } from './lib/readDir.ts'; const encoder = new TextEncoder(); const decoder = new TextDecoder('utf8'); const entries = readDir('src', ['src/playground.ts', 'src/logger.ts']); for await (const entry of entries) { i...
syrflover/iterator-helper
src/methods/product.ts
<gh_stars>1-10 import { getLogger } from '../logger.ts'; import { fold } from './fold.ts'; const logger = await getLogger('methods/product'); export function product(iter: AsyncIterable<number>): Promise<number> { logger.trace('product()'); return fold((acc, e) => acc * e, 1, iter); }
syrflover/iterator-helper
src/types/guards/isNull_test.ts
<filename>src/types/guards/isNull_test.ts import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { isNull } from './mod.ts'; Deno.test('isNull() null', () => { const actual = isNull(null); const expected = true; assertEquals(actual, expected); }); Deno.test('isNull() undefined',...
syrflover/iterator-helper
deno/methods/zip.ts
<gh_stars>1-10 import { Pair, pair } from "../types/mod.ts"; import { next_async, sequence } from "../lib/iterable/mod.ts"; import { _curry } from "../lib/utils/mod.ts"; async function* _zip_impl_fn<T, U>( other: AsyncIterable<U | Promise<U>>, iter: AsyncIterable<T>, ): AsyncIterable<Pair<T, U>> { for await (co...
syrflover/iterator-helper
src/methods/scan_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('scan() state + elem', async () => { const a = iterator([1, 2, 3, Promise.resolve(4), 5]); const actual_elements: number[] = []; const expected_elements = [1, 2, 3, 4, 5]; const a...
syrflover/iterator-helper
src/types/guards/isPromise.ts
<filename>src/types/guards/isPromise.ts import { isNull } from './isNull.ts'; export function isPromise(a: any): a is Promise<any> { return isNull(a) ? false : a.constructor === Promise; }
syrflover/iterator-helper
src/lib/iterable/initLast_test.ts
<reponame>syrflover/iterator-helper<filename>src/lib/iterable/initLast_test.ts /* eslint no-empty-function: "off" */ import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { initLast } from './mod.ts'; async function* asyncIterable(): AsyncIterable<number> { yield 1; yield 2; yiel...
syrflover/iterator-helper
deno/lib/iterable/toIterable.ts
<filename>deno/lib/iterable/toIterable.ts export function* toIterable<T>(iter: Iterable<T>): Iterable<T> { yield* iter; }
syrflover/iterator-helper
src/methods/fold1.ts
import type { FoldFn } from '../types/functions/mod.ts'; import { getLogger } from '../logger.ts'; import { next_async } from '../lib/iterable/mod.ts'; import { _curry } from '../lib/utils/mod.ts'; import { fold } from './fold.ts'; const logger = await getLogger('methods/fold1'); async function _fold1_impl_fn<T>(f...
syrflover/iterator-helper
deno/types/global.ts
import type { EP } from "./promise.ts"; import { iterator, ToAsyncIterator } from "../mod.ts"; declare global { interface String { iter(): ToAsyncIterator<string>; } interface Array<T> { iter(): ToAsyncIterator<EP<T>>; } interface Int8Array { iter(): ToAsyncIterator<number>; } interface I...
syrflover/iterator-helper
src/methods/chain.ts
import { getLogger } from '../logger.ts'; import { _curry } from '../lib/utils/mod.ts'; const logger = await getLogger('methods/chain'); async function* _chain_impl_fn<T>(other: Iterable<T | Promise<T>> | AsyncIterable<T | Promise<T>>, iter: AsyncIterable<T>): AsyncIterable<T> { logger.trace('chain()'); yiel...
syrflover/iterator-helper
src/methods/any_test.ts
<filename>src/methods/any_test.ts import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import type { Pair } from '../types/mod.ts'; import { iterator } from '../mod.ts'; Deno.test('any() x > 0', async () => { const a = iterator([1, 2, 3]); const actual: Pair<boolean, number[]> = [await a....
syrflover/iterator-helper
src/methods/stepBy_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('stepBy(2)', async () => { const a = iterator([0, 1, 2, 3, 4, 5]); const actual: number[] = []; const expected = [0, 2, 4]; const it = a.stepBy(2); for await (const _ of it) ...
syrflover/iterator-helper
src/lib/iterable/next_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { next_sync, next_async } from './mod.ts'; function* iterable(): Iterable<number> { yield 1; yield 2; yield 3; } Deno.test('prepend(0, [1])', async () => { const it = iterable(); assertEquals(next_sync(it), { done: f...
syrflover/iterator-helper
deno/methods/any.ts
import type { PredicateFn } from "../types/functions/mod.ts"; import { _curry } from "../lib/utils/mod.ts"; async function _any_impl_fn<T>( fn: PredicateFn<T>, iter: AsyncIterable<T>, ): Promise<boolean> { for await (const elem of iter) { const condition = await fn(elem); if (condition) { return ...
syrflover/iterator-helper
src/methods/flatten_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('flatten() [1,2,3,Promise<4>,5,[Promise<6>,7],AsyncIterator_<8,9>,10]', async () => { const a = iterator([1, 2, 3, Promise.resolve(4), 5, [Promise.resolve(6), 7], iterator([8, 9]), 10]); c...
syrflover/iterator-helper
deno/methods/unzip.ts
import { Pair, pair } from "../types/mod.ts"; import { append, sequence } from "../lib/iterable/mod.ts"; import { fold } from "./fold.ts"; async function _unzip_impl_fn<T, U>( iter: AsyncIterable<Pair<T, U>>, ): Promise<Pair<AsyncIterable<T>, AsyncIterable<U>>> { return fold( (acc, elem) => { const [le...
syrflover/iterator-helper
src/methods/filterMap_test.ts
<filename>src/methods/filterMap_test.ts import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('filterMap() parseInt', async () => { const a = iterator(['a', 'b', '1', '2', '3', 'c', '4', 'd']); const actual: number[] = []; const expected ...
syrflover/iterator-helper
src/methods/count.ts
<filename>src/methods/count.ts<gh_stars>1-10 import { getLogger } from '../logger.ts'; import { fold } from './fold.ts'; const logger = await getLogger('methods/count'); // [a] -> Int export function count<T>(iter: AsyncIterable<T>): Promise<number> { logger.trace('count()'); return fold((count_: number) => ...
syrflover/iterator-helper
deno/methods/position.ts
import type { PredicateFn } from "../types/functions/mod.ts"; import { _curry } from "../lib/utils/mod.ts"; async function _position_impl_fn<T>( fn: PredicateFn<T>, iter: AsyncIterable<T>, ): Promise<number | undefined> { let pos = 0; for await (const elem of iter) { const condition = await fn(elem); ...
syrflover/iterator-helper
bench/main.ts
<filename>bench/main.ts import { bench, runIfMain } from 'https://deno.land/std/testing/bench.ts'; import { filter_bench_0, filter_bench_1, filter_bench_2, filter_bench_3 } from './filter.ts'; const benchmarks = [filter_bench_0, filter_bench_1, filter_bench_2, filter_bench_3]; for (const fn of benchmarks) { benc...
syrflover/iterator-helper
src/methods/map.ts
<reponame>syrflover/iterator-helper<gh_stars>1-10 import type { MapFn } from '../types/functions/mod.ts'; import { getLogger } from '../logger.ts'; import { _curry } from '../lib/utils/mod.ts'; const logger = await getLogger('methods/map'); async function* _map_impl_fn<T, R>(fn: MapFn<T, R>, iter: AsyncIterable<T>)...
syrflover/iterator-helper
src/methods/minByKey.ts
import type { CompareFn, KeyFn } from '../types/functions/mod.ts'; import { getLogger } from '../logger.ts'; import { minBy } from '../lib/compare/mod.ts'; import { next_async } from '../lib/iterable/mod.ts'; import { _curry, Curry2 } from '../lib/utils/mod.ts'; import { fold } from './fold.ts'; const logger = awai...
syrflover/iterator-helper
src/methods/findMap.ts
import type { MapFn } from '../types/functions/mod.ts'; import type { Nullable } from '../types/mod.ts'; import { getLogger } from '../logger.ts'; import { isNull } from '../types/guards/mod.ts'; import { _curry } from '../lib/utils/mod.ts'; const logger = await getLogger('methods/findMap'); async function _find_m...
syrflover/iterator-helper
src/types/guards/isArrayLikeOrString.ts
<filename>src/types/guards/isArrayLikeOrString.ts<gh_stars>1-10 import { isArrayLike } from './isArrayLike.ts'; import { isString } from './isString.ts'; export function isArrayLikeOrString(a: any): a is string | any[] { return isArrayLike(a) || isString(a); }
syrflover/iterator-helper
src/types/functions/scan.ts
<gh_stars>1-10 export type ScanFn<A, B> = (state: B, element: A) => B | Promise<B>; // export type ScanrFn<A, B> = (element: A, state: B) => B | Promise<B>;
syrflover/iterator-helper
src/types/global.ts
<reponame>syrflover/iterator-helper import type { EP } from './promise.ts'; import { getLogger } from '../logger.ts'; import { iterator, ToAsyncIterator } from '../mod.ts'; const logger = await getLogger('global'); declare global { interface String { iter(): ToAsyncIterator<string>; } interface...
syrflover/iterator-helper
src/lib/utils/id_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { id } from './mod.ts'; Deno.test('id()', async () => { const actual = id(1); const expected = 1; assertEquals(actual, expected); });
syrflover/iterator-helper
src/types/guards/isFunction_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { isFunction } from './mod.ts'; Deno.test('isFunction() function', () => { function a() {} const actual = isFunction(a); const expected = true; assertEquals(actual, expected); }); Deno.test('isFunction() arrow function'...
syrflover/iterator-helper
deno/methods/maxBy.ts
<gh_stars>1-10 import type { CompareFn } from "../types/functions/mod.ts"; import { _curry, id } from "../lib/utils/mod.ts"; import { maxByKey } from "./maxByKey.ts"; export interface MaxBy { <T>(fn: CompareFn<T>, iter: AsyncIterable<T>): Promise<T | undefined>; <T>(fn: CompareFn<T>): (iter: AsyncIterable<T>) =>...
syrflover/iterator-helper
src/methods/takeWhile.ts
import type { PredicateFn } from '../types/functions/mod.ts'; import { getLogger } from '../logger.ts'; import { _curry } from '../lib/utils/mod.ts'; const logger = await getLogger('methods/takeWhile'); async function* _take_while_impl_fn<T>(predicate: PredicateFn<T>, iter: AsyncIterable<T>): AsyncIterable<T> { ...
syrflover/iterator-helper
src/types/guards/isArrayLikeOrString_test.ts
<filename>src/types/guards/isArrayLikeOrString_test.ts<gh_stars>1-10 import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { isArrayLikeOrString } from './mod.ts'; Deno.test('isArrayLikeOrString() array', () => { const actual = isArrayLikeOrString([1, 2, 3]); const expected = true; ...
syrflover/iterator-helper
src/methods/chain_test.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts'; import { iterator } from '../mod.ts'; Deno.test('chain() [1,2,3].chain([4,5,6])', async () => { const a = iterator([1, 2, 3]); const actual: number[] = []; const expected = [1, 2, 3, 4, 5, 6]; for await (const _ of a.chain([4, ...
syrflover/iterator-helper
deno/lib/compare/maxBy.ts
<filename>deno/lib/compare/maxBy.ts import type { CompareFn, KeyFn } from '../../types/functions/mod.ts'; import { Ord } from '../../types/mod.ts'; export async function maxBy<T, K>(keyFn: KeyFn<T, K>, cmpFn: CompareFn<K>, a: T, b: T): Promise<T> { const key_a = await keyFn(a); const key_b = await keyFn(b); ...
syrflover/iterator-helper
src/types/guards/mod.ts
<reponame>syrflover/iterator-helper<gh_stars>1-10 export * from './isArrayLike.ts'; export * from './isArrayLikeOrString.ts'; export * from './isAsyncIterable.ts'; export * from './isFunction.ts'; export * from './isIterable.ts'; export * from './isNull.ts'; export * from './isPromise.ts'; export * from './isString.ts'...
syrflover/iterator-helper
src/types/promise.ts
export type ExtractPromise<T> = T extends Promise<infer P> ? P : T; export type EP<T> = ExtractPromise<T>;
syrflover/iterator-helper
src/methods/filter.ts
<filename>src/methods/filter.ts<gh_stars>1-10 import type { PredicateFn } from '../types/functions/mod.ts'; import { getLogger } from '../logger.ts'; import { _curry } from '../lib/utils/mod.ts'; const logger = await getLogger('methods/filter'); async function* _filter_impl_fn<T>(predicate: PredicateFn<T>, iter: As...
syrflover/iterator-helper
src/methods/mod.ts
export { all } from './all.ts'; export { any } from './any.ts'; export { average } from './average.ts'; export { chain } from './chain.ts'; export { collect } from './collect.ts'; export { count } from './count.ts'; export { cycle } from './cycle.ts'; export { enumerate } from './enumerate.ts'; export { filter } from '...
syrflover/iterator-helper
deno/lib/compare/max.ts
<reponame>syrflover/iterator-helper import { id } from '../utils/mod.ts'; import { compare } from './compare.ts'; import { maxBy } from './maxBy.ts'; export function max<T>(a: T, b: T): Promise<T> { return maxBy(id, compare, a, b); }
syrflover/iterator-helper
deno/lib/iterable/prepend.ts
// a -> [a] -> [a] export async function* prepend<T>(x: T, xs: Iterable<T> | AsyncIterable<T>) { yield x; yield* xs; }