repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
jmfirth/design-test-harness | src/components/harness.ts | <reponame>jmfirth/design-test-harness
import { createSubscriber } from '@jmfirth/lit-html-redux'
import { TemplateResult, directive } from 'lit-html'
import { html } from 'lit-html/lib/lit-extended'
import { bindActionCreators } from 'redux'
import { grid, horizontalRuler, information } from '.'
import { Config, Grid }... |
jmfirth/design-test-harness | src/store.ts | <gh_stars>0
import * as t from 'io-ts'
import * as redux from 'redux'
import { Config } from './config'
/* Harness */
export const HarnessState = t.interface({
visible: t.boolean
})
export type HarnessState = t.TypeOf<typeof HarnessState>
export const initialHarnessState: HarnessState = {
visible: false
}
expor... |
jmfirth/design-test-harness | src/shims.d.ts | <gh_stars>0
declare module 'hex-rgb' {
type Vector4<T> = [T, T, T, T]
interface RGBA {
red: number
green: number
blue: number
alpha: number
}
interface FormatTypeMap {
array: Vector4<number>
}
type FormatTypes = keyof FormatTypeMap | undefined
export interface Options<F extends For... |
jmfirth/design-test-harness | src/colors.ts | <reponame>jmfirth/design-test-harness
export const carnation = '#ff555f'
|
jmfirth/design-test-harness | webpack.config.ts | import * as webpack from 'webpack';
const config: webpack.Configuration = {
mode: 'production',
entry: './src/design-test-harness.ts',
output: {
path: __dirname + '/dist',
filename: 'design-test-harness.min.js'
},
resolve: {
extensions: ['.js', '.ts']
},
module: {
rules: [
{
... |
jmfirth/design-test-harness | src/components/index.ts | export * from './grid'
export * from './harness'
export * from './horizontal-ruler'
export * from './information'
|
jmfirth/design-test-harness | src/design-test-harness.ts | <filename>src/design-test-harness.ts
import { render } from 'lit-html'
import { createPublisher } from '@jmfirth/lit-html-redux'
import { harness } from './components/harness'
import { Config } from './config'
import { createStore, harnessActions, settingsActions } from './store'
const store = createStore()
function ... |
jmfirth/design-test-harness | src/components/horizontal-ruler.ts | import { TemplateResult } from 'lit-html'
import { html } from 'lit-html/lib/lit-extended'
import * as colors from '../colors'
import { rgba } from '../common'
export const horizontalRuler = () => html`
<style type="text/css">
.harness-horizontal-ruler {
position: absolute;
top: 0;
bottom: 0;
... |
jmfirth/design-test-harness | src/common.ts | <reponame>jmfirth/design-test-harness
import hexRgb from 'hex-rgb'
export const rgba = (hex: string, alpha: number) =>
`rgba(${hexRgb(hex, { format: 'array' })
.slice(0, 3)
.join(', ')}, ${alpha})`
|
jmfirth/design-test-harness | src/components/information.ts | import { TemplateResult } from 'lit-html'
import { html } from 'lit-html/lib/lit-extended'
import { Config } from '../config'
export const information = (config: Config) => {
const gridColumn = 1
const verticalPosition = 30
return html`
<div class="harness-information">
<div class="harness-information... |
sportsreport2/nodeless-trakt-ts | index.d.ts | <reponame>sportsreport2/nodeless-trakt-ts<gh_stars>0
export type Status =
| "ended"
| "returning series"
| "canceled"
| "in production";
export type Type = "movie" | "show" | "episode" | "person" | "list";
export type ExtendedType =
| "full"
| "noseasons"
| "episodes"
| "full,episodes"
| "metadata";
e... |
sportsreport2/nodeless-trakt-ts | tests/index.test.ts | import { Trakt } from '../index';
import { expect } from 'chai';
describe('nodeless-trakt-ts', function () {
it('movies.trending', async function () {
const trakt = new Trakt({
client_id:
"Your Trakt Client Id",
client_secret:
"Your Trakt Secret Id",
});
const movies = await t... |
forgleaner/eslint-config | test/tsx.ts | <reponame>forgleaner/eslint-config
/**
* tsx
*/
import { Component, Inject, Prop, Provide } from 'vue-property-decorator';
const str = "dasdasd what's insdas";
const str2 = `dasdasd what's insdas`;
interface ITest {
das: string;
dd: number;
}
function buzz() {
return 0;
}
const x = 1;
const y = 2;
const fo... |
cosine99/mattermost-webapp | components/common/show_below_reply.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Tooltip} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
import {localizeMessage} from 'utils/utils.jsx';
import OverlayTrigger from 'components/over... |
stepanLav/node_transaction_generator | src/case/CreateCustomToken.ts | <gh_stars>0
import { api } from "@sora-substrate/util";
import { AssetList } from "../database";
import { createKeyringThroughPair, makestring } from "../utils/usefullFunctions";
import { BaseConnection } from "../database/BaseConnection";
import { PolkaswapUser } from "../database/entity/PolkaswapUser";
import { LoadU... |
stepanLav/node_transaction_generator | src/database/entity/Balances.ts | <filename>src/database/entity/Balances.ts
import { Entity, Column, CreateDateColumn, PrimaryGeneratedColumn, ManyToOne, Index } from "typeorm";
import { PolkaswapUser } from "./PolkaswapUser";
import { AssetList } from "./AssetList";
@Entity()
export class Balances {
@Index()
@PrimaryGeneratedColumn({type: "i... |
stepanLav/node_transaction_generator | src/database/BaseConnection.ts | import "reflect-metadata";
import { Connection, createConnection } from "typeorm";
export class BaseConnection {
public connection: Connection
private constructor() {
}
private static instance: BaseConnection;
public static getInstance(): BaseConnection {
if (!BaseConnection.instance) {... |
stepanLav/node_transaction_generator | src/case/CheckBalance.ts | <reponame>stepanLav/node_transaction_generator
import { KnownAssets, KnownSymbols } from "@sora-substrate/util";
import { BaseConnection } from "../database/BaseConnection";
import { PolkaswapUser, Balances } from "../database";
import { LoadUser } from "../userInteraction/LoadUser";
import { In } from "typeorm";
clas... |
stepanLav/node_transaction_generator | src/database/index.ts | export * from './entity/AssetList'
export * from './entity/Balances'
export * from './entity/PolkaswapUser' |
stepanLav/node_transaction_generator | src/database/entity/PolkaswapUser.ts | import { Entity, Column, CreateDateColumn, PrimaryGeneratedColumn, BeforeInsert, OneToMany, Index } from "typeorm";
import { Balances } from "./Balances";
@Entity()
export class PolkaswapUser {
@PrimaryGeneratedColumn({ type: "int" })
user_id: number;
@Column({ type: "text" })
address: string;
@... |
stepanLav/node_transaction_generator | src/case/MintXorToUsers.ts | import { KnownAssets, KnownSymbols } from "@sora-substrate/util";
import { BaseConnection } from "../database/BaseConnection";
import { PolkaswapUser } from "../database/entity/PolkaswapUser";
import { LoadUser } from "../userInteraction/LoadUser";
import { createArrayOfTransactions, createKeyringFromMnemonic } from '.... |
stepanLav/node_transaction_generator | src/database/entity/AssetList.ts | <reponame>stepanLav/node_transaction_generator<filename>src/database/entity/AssetList.ts
import { Entity, Column, CreateDateColumn, PrimaryColumn, UpdateDateColumn, OneToMany } from "typeorm";
import { Balances } from "./Balances";
@Entity()
export class AssetList {
@PrimaryColumn({type: "text"})
token_addres... |
stepanLav/node_transaction_generator | src/case/CreateUsers.ts | <filename>src/case/CreateUsers.ts
import { BaseConnection } from "../database/BaseConnection";
import { PolkaswapUser } from "../database/entity/PolkaswapUser";
import { LoadUser } from "../userInteraction/LoadUser";
import { encodeAddress } from '@polkadot/keyring'
import { mnemonicGenerate, naclKeypairFromSeed, mnemo... |
stepanLav/node_transaction_generator | src/utils/usefullFunctions.ts | <filename>src/utils/usefullFunctions.ts
import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
import { KeypairType, Keypair } from '@polkadot/util-crypto/types'
import { KeyringPair } from '@polkadot/keyring/types'
import { Keyring } from '@polkadot/keyring'
export function createArrayOfTransacti... |
stepanLav/node_transaction_generator | src/App.ts | <reponame>stepanLav/node_transaction_generator<filename>src/App.ts
// import "reflect-metadata"
import loadGenerator from './userInteraction/LoadUserGenerator'
import scenario from './case/CreateUsers'
import { LoadUser } from './userInteraction/LoadUser'
import * as Parallel from 'async-parallel'
import { BaseConnecti... |
stepanLav/node_transaction_generator | src/userInteraction/LoadUser.ts | <gh_stars>0
import { connection, Api } from '@sora-substrate/util'
export class LoadUser {
public api: Api
public count: Number
private connection: any
constructor(public iterations: number){}
public async create(url: string, created: any) {
this.api = new Api()
this.api.initial... |
stepanLav/node_transaction_generator | src/userInteraction/LoadUserGenerator.ts | <gh_stars>0
import { LoadUser } from './LoadUser'
class LoadUserGenerator {
public users: any = []
public async generate(url: string, count: number, iterations: number): Promise<[LoadUser]>{
while (count > 0) {
await new Promise(async (resolve, _reject) =>{
const user = ne... |
os33/qrcode-with-logos | types/index.d.ts | export interface Logo {
src: string;
logoRadius?: number;
logoSize?: number;
borderRadius?: number;
borderColor?: string;
borderSize?: number;
bgColor?: string;
crossOrigin?: string;
}
export interface NodeQrCodeOptions {
margin?: number;
color?: {
dark?: string;
light?: string;
};
erro... |
os33/qrcode-with-logos | src/toImage.ts | /*
* @Author: super
* @Date: 2019-06-27 16:29:39
* @Last Modified by: super
* @Last Modified time: 2019-06-27 16:46:46
*/
import { BaseOptions } from "../types/index";
import { toCanvas } from "./toCanvas";
import { isFunction, isString } from "./utils";
import { Logo } from '../types/index'
export const toImage ... |
os33/qrcode-with-logos | src/toCanvas.ts | /*
* @Author: super
* @Date: 2019-06-27 16:29:34
* @Last Modified by: super
* @Last Modified time: 2019-06-27 16:47:22
*/
import { renderQrCode } from "./draw-canvas";
import { BaseOptions } from "../types/index";
import { drawLogo } from "./draw-logo";
export const toCanvas = (options: BaseOptions): Promise<voi... |
os33/qrcode-with-logos | src/server.ts | /*
* @Author: super
* @Date: 2019-06-27 16:29:26
* @Last Modified by: super
* @Last Modified time: 2019-07-01 15:51:26
*/
import QrCodeWithLogo from "./index";
//@ts-ignore
import Logo = require("./super.jpg");
let demo = new QrCodeWithLogo({
canvas: document.getElementById("canvas") as HTMLCanvasElement,
cont... |
os33/qrcode-with-logos | src/index.ts | /*
* @Author: super
* @Date: 2019-06-27 16:29:31
* @Last Modified by: suporka
* @Last Modified time: 2020-03-04 12:24:50
*/
import { toCanvas } from "./toCanvas";
import { toImage, saveImage } from "./toImage";
import { BaseOptions } from "../types/index";
const { version } = require('../package.json')
class QrCo... |
os33/qrcode-with-logos | src/draw-canvas.ts | /*
* @Author: super
* @Date: 2019-06-27 16:29:19
* @Last Modified by: super
* @Last Modified time: 2019-06-27 17:40:58
*/
import { BaseOptions, NodeQrCodeOptions } from "../types/index";
import { promisify } from "./utils";
// @ts-ignore
// import QRCode from "qrcode"
const QRCode = require("qrcode")
const toCanv... |
os33/qrcode-with-logos | src/draw-logo.ts | <reponame>os33/qrcode-with-logos
/*
* @Author: super
* @Date: 2019-06-26 18:01:57
* @Last Modified by: suporka
* @Last Modified time: 2020-03-04 12:23:09
*/
import { BaseOptions } from "../types/index";
import { isString } from "./utils";
import { Logo } from '../types/index'
export const drawLogo = ({ canvas, lo... |
jasona/XtermBlazor | XtermBlazor/scripts/XtermBlazor.ts | import { Terminal, ITerminalOptions } from 'xterm'
declare var DotNet: any
class XtermBlazor {
private readonly _ASSEMBLY_NAME = 'XtermBlazor'
private readonly _terminals = new Map<string, Terminal>()
registerTerminal(id: string, ref: HTMLElement, options: ITerminalOptions) {
// Setup the XTerm terminal
const... |
practicajs/practica | src/code-templates/services/order-service/test/global-teardown.ts | <reponame>practicajs/practica
import isCI from "is-ci";
import dockerCompose from "docker-compose";
import OrderRepository from "../data-access/order-repository";
module.exports = async () => {
if (isCI) {
// ️️️✅ Best Practice: Leave the DB up in dev environment
dockerCompose.down();
} else {
// ✅ Bes... |
practicajs/practica | src/code-templates/libraries/message-queue-client/message-queue-client.ts | import { EventEmitter } from "events";
import {
errorHandler,
} from "../../libraries/error-handling/error-handling";
import { FakeMessageQueueProvider } from "./fake-message-queue-provider";
import amqplib from "amqplib";
// This is a simplistic client for a popular message queue product - RabbitMQ
// It's generic ... |
practicajs/practica | src/code-templates/libraries/error-handling/error-handling.ts | <filename>src/code-templates/libraries/error-handling/error-handling.ts
import * as logger from "../../libraries/logger/logger";
// This file simulates real-world error handler that makes this component observable
const errorHandler = {
handleError: async (errorToHandle) => {
try {
logger.error(errorToHand... |
practicajs/practica | src/code-generator/entry-points/non-interactive-cli.tsx | import {
factorDefaultOptions,
} from "../generation-logic/generation-options";
import { generateApp } from "../generation-logic/generate-service";
export function handleNonInteractiveCommand(options: any) {
const generationOptions = factorDefaultOptions({
installDependencies: options.installDependencies,
... |
practicajs/practica | src/code-templates/services/order-service/test/global-setup.ts | <reponame>practicajs/practica<gh_stars>10-100
import isPortReachable from "is-port-reachable";
import path from "path";
import dockerCompose from "docker-compose";
import { execSync } from "child_process";
module.exports = async () => {
console.time("global-setup");
// ️️️✅ Best Practice: Speed up during developm... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/heap-sort.ts | <gh_stars>100-1000
/**
* Swap elements at idx1 and idx2 in arr.
* @param arr - array containing two elements to swap
* @param idx1 - index of first element
* @param idx2 - index of second element
*/
const swap = (arr: number[], idx1: number, idx2: number): void => {
const temp = arr[idx2]
arr[idx2] = arr[idx1]... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/sequences/deque.test.ts | <filename>test/data-structures/sequences/deque.test.ts
import { Deque } from '../../../src/data-structures/sequences/queue'
describe('Deque', () => {
let deque: Deque<number>
beforeEach(() => {
deque = new Deque()
})
describe('empty deque', () => {
it('returns null when pop() is called on empty stack... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/test-cases.ts | <gh_stars>100-1000
interface TestCases {
[key: string]: number[]
}
const testCases: TestCases = {
'empty array': [],
'array of length 1': [9],
'array with an even number of elements': [7, 9, 5, 2, 1, 3],
'array with an odd number of elements': [-5, -13, -3, 0, 6, 2, 8],
'array of increasing elements': [-5,... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/topological-sort.test.ts | <reponame>jeffzh4ng/Data-Structures-and-Algorithms
import { GraphNode } from '../../../src/algorithms/graphs/graph-node'
import { topologicalSortDepthFirst } from '../../../src/algorithms/sort/topological-sort-dfs'
import { topologicalSortKahn } from '../../../src/algorithms/sort/topological-sort-kahn'
describe('Topol... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/heaps/lazy-min-binomial-heap.test.ts | <filename>test/data-structures/heaps/lazy-min-binomial-heap.test.ts
import LazyMinBinomialHeap from '../../../src/data-structures/priority-queues/mergeable-heaps/lazy-min-binomial-heap'
describe('MinBinomialHeap', () => {
let heap: LazyMinBinomialHeap<number>
beforeEach(() => {
heap = new LazyMinBinomialHeap(... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/graphs/shortest-paths/dijkstras-shortest-path.ts | import { MinBinaryHeap } from '../../../data-structures/priority-queues'
import { GraphNode, PrevVertices, ShortestDistances, WeightedGraph } from '../graph-node'
/**
* Perform Dijkstra's shortest path algorithm.
* Find the shortest path between two vertices in a directed graph with positive weights.
*
* Time comp... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/bucket-sort.ts | <filename>src/algorithms/sort/bucket-sort.ts
/**
* Sort an array of positive numbers in-place and in ascending order using bucket sort.
* Individual buckets are sorted using the JS sort function.
* @param arr - array of positive numbers to sort
* @param n - number of buckets
*/
const bucketSortPositives = (arr: nu... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/quick-sort.test.ts | <reponame>jeffzh4ng/Data-Structures-and-Algorithms<filename>test/algorithms/sort/quick-sort.test.ts
import quickSort from '../../../src/algorithms/sort/quick-sort'
import testCases from './test-cases'
describe('quickSort', () => {
for (const [description, inputArray] of Object.entries(testCases)) {
it(`correctly... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/graphs/shortest-paths/floyd-warshall-shortest-path.ts | <gh_stars>100-1000
import { GraphNode, WeightedGraph } from '../graph-node'
type U = GraphNode<number>
type V = GraphNode<number>
type Weight = number
type DP = Array<Array<number>>
type Next = Array<Array<GraphNode<number> | null>>
export const shortestPath = (
next: Next,
source: GraphNode<number>,
target: G... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/graphs/graph-node.ts | <reponame>jeffzh4ng/Data-Structures-and-Algorithms
export class GraphNode<T> {
val: T
constructor(val: T) {
this.val = val
}
}
type EdgeList<T> = Map<GraphNode<T>, number>
export type WeightedGraph<T> = Map<GraphNode<T>, EdgeList<T>>
export type ShortestDistances<T> = Map<GraphNode<T>, number>
export type P... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/counting-sort.test.ts | <reponame>jeffzh4ng/Data-Structures-and-Algorithms
import countingSort from '../../../src/algorithms/sort/counting-sort'
import testCases from './test-cases'
describe('countingSort', () => {
console.error = jest.fn()
beforeEach(() => {
jest.clearAllMocks()
})
for (const [description, inputArray] of Objec... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/quick-sort.ts | <filename>src/algorithms/sort/quick-sort.ts
/**
* Returns a random integer between min and max.
* @param min - lower bound (returned int will be greater than or equal to min)
* @param max - upper bound (returned int will be less than max)
*/
const getRandomInt = (min: number, max: number): number => {
min = Math.... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/search/breadth-first-search.ts | import { Queue } from '../../data-structures/sequences/queue'
import { GraphNode } from '../graphs/graph-node'
/**
* Perform a breadth-first search through a directed graph.
*
* Time complexity: O(V+E)
* Space complexity: O(V)
*
* @param {GraphNode<T>} root
* @param {Map<GraphNode<T>, Array<GraphNode<T>>} graph... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/trees/avl-tree.test.ts | import AVLTree from '../../../src/data-structures/trees/avl-tree'
import AVLTreeNode from '../../../src/data-structures/trees/avl-tree/avl-tree-node'
describe('AVL Tree', () => {
let tree: AVLTree<number>
beforeEach(() => {
tree = new AVLTree()
})
describe('Inspection', () => {
it('size()', () => {
... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/trees/b-tree.test.ts | import BTree from '../../../src/data-structures/trees/b-tree/b-tree'
describe('AVL Tree', () => {
let tree: BTree<number>
beforeEach(() => {
tree = new BTree(2)
})
describe('inspection', () => {
it('isEmpty()', () => {
expect(tree.size()).toBe(0)
expect(tree.isEmpty()).toBe(true)
ex... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/bucket-sort.test.ts | <gh_stars>100-1000
import bucketSort from '../../../src/algorithms/sort/bucket-sort'
import testCases from './test-cases'
describe('bucketSort', () => {
console.error = jest.fn()
beforeEach(() => {
jest.clearAllMocks()
})
for (const [description, inputArray] of Object.entries(testCases)) {
it(`correc... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/topological-sort-dfs.ts | import LinkedList from '../../data-structures/sequences/linked-list'
import { GraphNode } from '../graphs/graph-node'
/**
* Perform a topological sort through a directed graph using the depth first technique.
*
* Time complexity: O(V+E)
* Space complexity: O(V) (recursion and output)
*
* @param startNode - The n... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/sequences/queue.test.ts | <gh_stars>100-1000
import { Queue } from '../../../src/data-structures/sequences/queue'
describe('Queue', () => {
let queue: Queue<number>
beforeEach(() => {
queue = new Queue()
})
describe('empty queue', () => {
it('returns null when pop() is called on empty stack', () => {
expect(queue.dequeu... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/graph/shortest-paths/floyd-warshall-shortest-path.test.ts | <gh_stars>100-1000
import { GraphNode, WeightedGraph } from '../../../../src/algorithms/graphs/graph-node'
import {
floydWarshall,
shortestPath,
} from '../../../../src/algorithms/graphs/shortest-paths/floyd-warshall-shortest-path'
describe('Floyd Warshall', () => {
test('Basic graph', () => {
const zero = n... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/trees/binary-search-tree.test.ts | <filename>test/data-structures/trees/binary-search-tree.test.ts<gh_stars>100-1000
import BinarySearchTree from '../../../src/data-structures/trees/binary-search-tree'
import TreeNode from '../../../src/data-structures/trees/binary-search-tree/tree-node'
describe('Binary Search Tree', () => {
let tree: BinarySearchTr... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/counting-sort.ts | <gh_stars>100-1000
/**
* Sort an array of integers in-place and in ascending order using counting sort.
*
* Time complexity: O(n + k), where n is the number of elements in arr
* and k is the range of numbers in arr.
*
* Space complexity: O(n + k)
*
* @param arr - array of integers to sort
*/
const countingSort... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/graph/shortest-paths/dijkstras-shortest-path.test.ts | import { GraphNode, WeightedGraph } from '../../../../src/algorithms/graphs/graph-node'
import { shortestPath } from '../../../../src/algorithms/graphs/shortest-paths/dijkstras-shortest-path'
describe('Dijksras Shortest Path', () => {
test('Basic Graph', () => {
const a = new GraphNode('a')
const b = new Gra... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/search/breadth-first-search.test.ts | import { GraphNode } from '../../../src/algorithms/graphs/graph-node'
import { bfs } from '../../../src/algorithms/search/breadth-first-search'
describe('Breadth First Search', () => {
test('Basic search', () => {
const a = new GraphNode('a')
const b = new GraphNode('b')
const c = new GraphNode('c')
... |
jeffzh4ng/Data-Structures-and-Algorithms | src/data-structures/priority-queues/min-binary-heap.ts | <filename>src/data-structures/priority-queues/min-binary-heap.ts
import * as utils from '../utils'
/*******************************************************************************
* A min binary heap implements the Priority Queue ADT. It has constant access
* to the min element of the heap, with logarithmic insertio... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/search/binary-search.ts | export type Item = number | string
/**
* Iteratively search an array of sorted items for a target item and returns its index.
*
* Time complexity:
* - for an array of numbers: O(log(n)),
* - for an array of strings: O(m*log(n)),
* - where n is the number of array elements and m is the average string len... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/search/depth-first-search.test.ts | import { GraphNode } from '../../../src/algorithms/graphs/graph-node'
import { dfs } from '../../../src/algorithms/search/depth-first-search'
describe('Depth First Search', () => {
test('Basic depth first search', () => {
const a = new GraphNode('a')
const b = new GraphNode('b')
const c = new GraphNode('... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/graph/shortest-paths/bellman-ford-shortest-path.test.ts | import { GraphNode, WeightedGraph } from '../../../../src/algorithms/graphs/graph-node'
import { shortestPath } from '../../../../src/algorithms/graphs/shortest-paths/bellman-ford-shortest-path'
describe('Bellman-Ford Shortest Path', () => {
test('Basic Graph', () => {
const a = new GraphNode('a')
const b = ... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/sequences/stack.test.ts | import Stack from '../../../src/data-structures/sequences/stack'
describe('Stack', () => {
let stack: Stack<number>
beforeEach(() => {
stack = new Stack()
})
describe('empty stack', () => {
it('returns null when pop() is called on empty stack', () => {
expect(stack.pop()).toBe(null)
})
... |
jeffzh4ng/Data-Structures-and-Algorithms | test/data-structures/sequences/circular-buffer.test.ts | import CircularBuffer from '../../../src/data-structures/sequences/circular-buffer'
describe('Circular Buffer', () => {
let buffer: CircularBuffer<number>
beforeEach(() => {
buffer = new CircularBuffer(4)
})
describe('empty', () => {
it('returns null when dequeue is called on empty buffer', () => {
... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/graphs/shortest-paths/bellman-ford-shortest-path.ts | <gh_stars>100-1000
import { GraphNode, PrevVertices, ShortestDistances, WeightedGraph } from '../graph-node'
/**
* Perform Bellman-Ford shortest path algorithm.
* Find the shortest path between two vertices in a directed graph with positive weights.
*
* Time complexity: O[VE]
* Space complexity: O(V+E)
*
* @par... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/merge-sort.ts | /**
* Helper function to merge left half and right half of a subarray.
* The sorted left half is arr[left : mid+1].
* The sorted right half is arr[mid+1 : right+1].
* Merging occurs in-place such that arr[left : right+1] will be sorted after function is executed.
*
* @param arr - array of numbers to be sorted
* ... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/search/binary-search.test.ts | <filename>test/algorithms/search/binary-search.test.ts
import {
binarySearchIterative,
binarySearchRecursive,
Item,
} from '../../../src/algorithms/search/binary-search'
describe('binarySearch', () => {
type BinarySearch = (arr: Item[], target: Item) => number
const runTest = (binarySearch: BinarySearch) =>... |
jeffzh4ng/Data-Structures-and-Algorithms | test/algorithms/sort/heap-sort.test.ts | import heapSort from '../../../src/algorithms/sort/heap-sort'
import testCases from './test-cases'
describe('heapSort', () => {
for (const [description, inputArray] of Object.entries(testCases)) {
it(`correctly sorts ${description}`, () => {
const soln = [...inputArray]
soln.sort((a, b) => a - b) // ... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/search/depth-first-search.ts | import { GraphNode } from '../graphs/graph-node'
/**
* Perform a depth-first search through a directed graph.
*
* Time complexity: O(V+E)
* Space complexity: O(V)
*
* @param {GraphNode<T>} startNode
* @param {Map<GraphNode<T>, Array<GraphNode<T>>} graph
* @return {Array<GraphNode<T>>}
*/
export const dfs = <T... |
jeffzh4ng/Data-Structures-and-Algorithms | src/algorithms/sort/topological-sort-kahn.ts | import { Queue } from '../../data-structures/sequences/queue'
import { GraphNode } from '../graphs/graph-node'
/**
* Perform a topological sort on a directed graph using Kahn's algorithm.
*
* Time complexity: O(V+E)
* Space complexity: O(V)
*
* @param {Map<GraphNode<T>, Array<GraphNode<T>>} graph
* @return {Arr... |
stephanbaker/hello-gatsby | src/templates/docPage.tsx | import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/Layout"
import rehypeReact from "rehype-react"
import ClickCounter from "../components/ClickCounter"
export const query = graphql`
query($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
... |
stephanbaker/hello-gatsby | src/pages/docs.tsx | <reponame>stephanbaker/hello-gatsby
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/Layout"
import Menu from "../components/Menu"
export const query = graphql`
query DocsMenuQuery {
site {
siteMetadata {
sectionsOverride
}
}
allMarkdo... |
stephanbaker/hello-gatsby | src/components/SiteContent.tsx | <filename>src/components/SiteContent.tsx
import React from "react"
interface SiteContentProps {
children: any
}
export default class SiteContent extends React.Component {
render = () => {
return (
<main>
<div style={{
margin: '0 auto 0 auto',
maxWidth: 960,
padding:... |
stephanbaker/hello-gatsby | src/components/SiteFooter.tsx | <filename>src/components/SiteFooter.tsx
import React from "react"
export default class SiteFooter extends React.Component {
render = () => {
return (
<footer style={{
margin: `0 auto 0 auto`,
maxWidth: 960,
padding: `1.45rem 1.0875rem`,
textDecoration: 'none',
}}>
... |
stephanbaker/hello-gatsby | src/pages/posts.tsx | <reponame>stephanbaker/hello-gatsby
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/Layout"
import BlogIndex from "../components/BlogIndex"
export const query = graphql`
query PostsQuery {
allMarkdownRemark(
filter: {fileAbsolutePath: {regex: "/.*\\/conten... |
stephanbaker/hello-gatsby | src/components/ClickCounter.tsx | <filename>src/components/ClickCounter.tsx
import React from "react"
const buttonStyle = {
backgroundColor: "rebeccapurple",
border: "none",
color: "white",
padding: "15px 32px",
textAlign: "center" as "center",
textDecoration: "none",
display: "inline-block",
fontSize: "16px",
margin: "4px 2px",
cu... |
stephanbaker/hello-gatsby | src/pages/index.tsx | import React from "react"
import { Link } from "gatsby"
import Layout from "../components/Layout"
import Image from "../components/Image"
export default class IndexPage extends React.Component {
render = () => {
return (
<Layout>
<h1>This is a Gatsby Site!</h1>
<p>This project is just a play... |
stephanbaker/hello-gatsby | src/components/Layout.tsx | <gh_stars>0
/**
* Layout component that queries for data
* with Gatsby's StaticQuery component
*
* See: https://www.gatsbyjs.org/docs/static-query/
*/
import * as React from "react";
import { graphql, useStaticQuery } from "gatsby"
import SiteFooter from "./SiteFooter"
import SiteHeader from "./SiteHeader"
impor... |
stephanbaker/hello-gatsby | src/components/BlogIndex.tsx | <reponame>stephanbaker/hello-gatsby
import React from "react"
import { Link } from "gatsby"
interface Edge {
node: {
frontmatter: {
title: string,
path: string
}
}
}
interface BlogIndexProps {
data: {
allMarkdownRemark: {
edges: Edge[]
}
}
}
// const BlogIndex = ({data}) => ... |
stephanbaker/hello-gatsby | src/components/Menu.tsx | import React from "react"
interface Node {
frontmatter: {
title: string,
path: string
}
}
interface Section {
title: string,
nodes: Node[]
}
interface MenuProps {
sections: Section[],
sectionsOverride: string[]
}
export default class Menu extends React.Component<MenuProps, {}> {
getSections = ... |
stephanbaker/hello-gatsby | src/components/TitleAndDescription.tsx | import React from "react"
import { string } from "prop-types";
interface TitleAndDescriptionProps {
data: {
site: {
siteMetadata: {
title: string,
description: string
}
}
}
}
export default class TitleAndDescription extends React.Component<TitleAndDescriptionProps, {}> {
rend... |
mikita-kandratsyeu/crypto-wallet-app | src/constants/constants.ts | <reponame>mikita-kandratsyeu/crypto-wallet-app<filename>src/constants/constants.ts<gh_stars>0
export interface MarketTab {
id: string;
title: string;
ref?: any;
}
const marketTabs: MarketTab[] = [
{
id: '1',
title: 'Cryptoassets',
},
{
id: '2',
title: 'Exchanges',
},
];
// API
// My Hold... |
mikita-kandratsyeu/crypto-wallet-app | src/store/market/market.reducer.ts | <filename>src/store/market/market.reducer.ts<gh_stars>0
import { MarketState } from '../types';
import * as marketActions from './market.actions';
const initialState: MarketState = {
myHoldings: [],
coins: [],
error: null,
loading: false,
};
const marketReducer = (state = initialState, action: any) => {
swi... |
mikita-kandratsyeu/crypto-wallet-app | src/store/market/market.actions.ts | import axios from 'axios';
import { Dispatch } from 'redux';
export const GET_HOLDINGS_BEGIN = 'GET_HOLDINGS_BEGIN';
export const GET_HOLDINGS_SUCCESS = 'GET_HOLDINGS_SUCCESS';
export const GET_HOLDINGS_FAILURE = 'GET_HOLDINGS_FAILURE';
export const GET_COIN_MARKET_BEGIN = 'GET_COIN_MARKET_BEGIN';
export const GET_COI... |
mikita-kandratsyeu/crypto-wallet-app | src/constants/routes.ts | enum stackRoutes {
MainLayout = 'MainLayout',
Home = 'Home',
Portfolio = 'Portfolio',
Trade = 'Trade',
Market = 'Market',
Profile = 'Profile',
}
export default stackRoutes;
|
mikita-kandratsyeu/crypto-wallet-app | src/components/types.ts | <gh_stars>0
import { Animated } from 'react-native';
import { icons } from './Icon';
export type IconTypes = keyof typeof icons;
export interface ChartProps {
containerStyle?: any;
chartPrices: any[];
}
export interface BalanceInfoProps {
title: string;
displayAmount: string | number;
changePct: string | n... |
mikita-kandratsyeu/crypto-wallet-app | src/screens/Portfolio.tsx | import React, { useCallback, useState } from 'react';
import { useFocusEffect } from '@react-navigation/core';
import {
View,
Text,
TouchableOpacity,
FlatList,
StyleSheet,
Image,
} from 'react-native';
import { connect } from 'react-redux';
// @ts-ignore
import AnimateNumber from 'react-native-countup';
imp... |
mikita-kandratsyeu/crypto-wallet-app | src/components/Icon.tsx | // @ts-nocheck
import React from 'react';
import { colors } from '../constants';
import Close from '../../assets/icons/close.svg';
import Briefcase from '../../assets/icons/briefcase.svg';
import Home from '../../assets/icons/home.svg';
import Market from '../../assets/icons/market.svg';
import Profile from '../../asse... |
mikita-kandratsyeu/crypto-wallet-app | src/components/TextButton.tsx | import React from 'react';
import { StyleSheet, Text } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { colors, fonts, sizes } from '../constants';
import { TextButtonProps } from './types';
export const TextButton: React.FC<TextButtonProps> = props => {
const { label, o... |
mikita-kandratsyeu/crypto-wallet-app | src/constants/messages.ts | <gh_stars>0
enum messages {
home = 'Home',
portfolio = 'Portfolio',
trade = 'Trade',
market = 'Market',
profile = 'Profile',
transfer = 'Transfer',
withdraw = 'Withdraw',
yourWallet = 'Your Wallet',
changes7d = '7d changes',
changes7dShort = '% (7d)',
usd = 'USD',
topCryptoCurrency = 'Top Crypto... |
mikita-kandratsyeu/crypto-wallet-app | src/screens/index.ts | import Home from './Home';
import MainLayoutWrapper from './MainLayoutWrapper';
import Portfolio from './Portfolio';
import Market from './Market';
import { Profile } from './Profile';
import { Trade } from './Trade';
export { Home, MainLayoutWrapper, Portfolio, Market, Profile, Trade };
|
mikita-kandratsyeu/crypto-wallet-app | src/components/SectionTitle.tsx | <gh_stars>0
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { colors, fonts, sizes } from '../constants';
import { SectionTitleProps } from './types';
export const SectionTitle: React.FC<SectionTitleProps> = props => {
const { title } = props;
return (
<View style={sty... |
mikita-kandratsyeu/crypto-wallet-app | src/store/types.ts | <filename>src/store/types.ts
export interface Store {
tabReducer: TabState;
marketReducer: MarketState;
}
export interface TabState {
isTradeModalVisible: boolean;
}
export interface MarketState {
loading: boolean;
error: any;
myHoldings: any[];
coins: any[];
}
|
mikita-kandratsyeu/crypto-wallet-app | src/store/tab/tab.reducer.ts | import { TabState } from '../types';
import * as tabActionTypes from './tab.actions';
const initialState: TabState = {
isTradeModalVisible: false,
};
const tabReducer = (state = initialState, action: any) => {
switch (action.type) {
case tabActionTypes.SET_TRADE_MODAL_VISIBILITY:
return {
...sta... |
mikita-kandratsyeu/crypto-wallet-app | src/screens/services.ts | <reponame>mikita-kandratsyeu/crypto-wallet-app
import { Alert, AlertButton } from 'react-native';
const getTotalWallet = <T extends {}>(myHoldings: T[]) =>
myHoldings.reduce((a: number, b: any) => a + (b.total || 0), 0);
const getValueChange = <T extends {}>(myHoldings: T[]) =>
myHoldings.reduce(
(a: number, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.