mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-11 09:31:14 +00:00
Added frontend to the repo
This commit is contained in:
+24
-2
@@ -1,2 +1,24 @@
|
||||
node_modules
|
||||
dist
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/backend/node_modules
|
||||
/frontend/node_modules
|
||||
|
||||
# testing
|
||||
/backend/coverage
|
||||
/frontend/coverage
|
||||
|
||||
# production
|
||||
/backend/build
|
||||
/frontend/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
{
|
||||
"name": "dotstats-server",
|
||||
"name": "dotstats-backend",
|
||||
"version": "0.1.0",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "tsc && node dist/index.js",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"author": "Parity Technologies Ltd. <admin@parity.io>",
|
||||
"license": "GPL-3.0",
|
||||
"description": "Polkadot Telemetry frontend",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "tsc && node build/index.js",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/express": "^4.16.0",
|
||||
"@types/node": "^10.3.3",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"outDir": "dist",
|
||||
"outDir": "build",
|
||||
"strictNullChecks": true,
|
||||
"sourceMap": true,
|
||||
"moduleResolution": "node",
|
||||
|
||||
Submodule
+1
Submodule frontend added at f4c58d01a7
@@ -0,0 +1,35 @@
|
||||
import { Opaque } from './types';
|
||||
|
||||
/**
|
||||
* Unique type-constrained Id number.
|
||||
*/
|
||||
export type Id<T> = Opaque<number, T>;
|
||||
|
||||
/**
|
||||
* Higher order function producing new auto-incremented `Id`s.
|
||||
*/
|
||||
export function idGenerator<T>(): () => Id<T> {
|
||||
let current = 0;
|
||||
|
||||
return () => current++ as Id<T>;
|
||||
}
|
||||
|
||||
interface HasId<T> {
|
||||
id: Id<T>;
|
||||
}
|
||||
|
||||
export class IdSet<T> {
|
||||
private map: Map<Id<T>, T> = new Map();
|
||||
|
||||
public add(item: T & HasId<T>) {
|
||||
this.map.set(item.id, item);
|
||||
}
|
||||
|
||||
public remove(item: T & HasId<T>) {
|
||||
this.map.delete(item.id);
|
||||
}
|
||||
|
||||
public get entries(): IterableIterator<T> {
|
||||
return this.map.values();
|
||||
}
|
||||
}
|
||||
+3
-109
@@ -1,109 +1,3 @@
|
||||
/**
|
||||
* PhantomData akin to Rust, because sometimes you need to be smarter than
|
||||
* the compiler.
|
||||
*/
|
||||
export class PhantomData<P> { private __PHANTOM__: P }
|
||||
|
||||
/**
|
||||
* Opaque type, similar to `opaque type` in Flow, or new types in Rust/C.
|
||||
* These should be produced only by manually casting `t as Opaque<T, P>`.
|
||||
*
|
||||
* `P` can be anything as it's never actually used. Using strings is okay:
|
||||
*
|
||||
* ```
|
||||
* type MyType = Opaque<number, 'MyType'>;
|
||||
* ```
|
||||
*/
|
||||
export type Opaque<T, P> = T & PhantomData<P>;
|
||||
|
||||
/**
|
||||
* Just a readable shorthand for null-ish-able types, akin to `T?` in Flow.
|
||||
*/
|
||||
export type Maybe<T> = T | null | undefined;
|
||||
|
||||
/**
|
||||
* Higher order function producing new auto-incremented `Id`s.
|
||||
*/
|
||||
export function idGenerator<T>(): () => Id<T> {
|
||||
let current = 0;
|
||||
|
||||
return () => current++ as Id<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique type-constrained Id number.
|
||||
*/
|
||||
export type Id<T> = Opaque<number, T>;
|
||||
|
||||
interface HasId<T> {
|
||||
id: Id<T>;
|
||||
}
|
||||
|
||||
export class IdSet<T> {
|
||||
private map: Map<Id<T>, T> = new Map();
|
||||
|
||||
public add(item: T & HasId<T>) {
|
||||
this.map.set(item.id, item);
|
||||
}
|
||||
|
||||
public remove(item: T & HasId<T>) {
|
||||
this.map.delete(item.id);
|
||||
}
|
||||
|
||||
public get entries(): IterableIterator<T> {
|
||||
return this.map.values();
|
||||
}
|
||||
}
|
||||
|
||||
export function* map<T, U>(iter: IterableIterator<T>, fn: (item: T) => U): IterableIterator<U> {
|
||||
for (const item of iter) yield fn(item);
|
||||
}
|
||||
|
||||
export function* chain<T>(a: IterableIterator<T>, b: IterableIterator<T>): IterableIterator<T> {
|
||||
yield* a;
|
||||
yield* b;
|
||||
}
|
||||
|
||||
export function* zip<T, U>(a: IterableIterator<T>, b: IterableIterator<U>): IterableIterator<[T, U]> {
|
||||
let itemA = a.next();
|
||||
let itemB = b.next();
|
||||
|
||||
while (!itemA.done && !itemB.done) {
|
||||
yield [itemA.value, itemB.value];
|
||||
|
||||
itemA = a.next();
|
||||
itemB = b.next();
|
||||
}
|
||||
}
|
||||
|
||||
export function* take<T>(iter: IterableIterator<T>, n: number): IterableIterator<T> {
|
||||
for (const item of iter) {
|
||||
if (n-- === 0) return;
|
||||
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
|
||||
export function skip<T>(iter: IterableIterator<T>, n: number): IterableIterator<T> {
|
||||
while (n-- !== 0 && !iter.next().done) {}
|
||||
|
||||
return iter;
|
||||
}
|
||||
|
||||
export function reduce<T, R>(iter: IterableIterator<T>, fn: (accu: R, item: T) => R, accumulator: R): R {
|
||||
for (const item of iter) accumulator = fn(accumulator, item);
|
||||
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export function join(iter: IterableIterator<{ toString: () => string }>, glue: string): string {
|
||||
const first = iter.next();
|
||||
|
||||
if (first.done) return '';
|
||||
|
||||
let result = first.value.toString();
|
||||
|
||||
for (const item of iter) result += glue + item;
|
||||
|
||||
return result;
|
||||
}
|
||||
export * from './id';
|
||||
export * from './iterators';
|
||||
export * from './types';
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
export function* map<T, U>(iter: IterableIterator<T>, fn: (item: T) => U): IterableIterator<U> {
|
||||
for (const item of iter) {
|
||||
yield fn(item);
|
||||
}
|
||||
}
|
||||
|
||||
export function* chain<T>(a: IterableIterator<T>, b: IterableIterator<T>): IterableIterator<T> {
|
||||
yield* a;
|
||||
yield* b;
|
||||
}
|
||||
|
||||
export function* zip<T, U>(a: IterableIterator<T>, b: IterableIterator<U>): IterableIterator<[T, U]> {
|
||||
let itemA = a.next();
|
||||
let itemB = b.next();
|
||||
|
||||
while (!itemA.done && !itemB.done) {
|
||||
yield [itemA.value, itemB.value];
|
||||
|
||||
itemA = a.next();
|
||||
itemB = b.next();
|
||||
}
|
||||
}
|
||||
|
||||
export function* take<T>(iter: IterableIterator<T>, n: number): IterableIterator<T> {
|
||||
for (const item of iter) {
|
||||
if (n-- === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
|
||||
export function skip<T>(iter: IterableIterator<T>, n: number): IterableIterator<T> {
|
||||
while (n-- !== 0 && !iter.next().done) {}
|
||||
|
||||
return iter;
|
||||
}
|
||||
|
||||
export function reduce<T, R>(iter: IterableIterator<T>, fn: (accu: R, item: T) => R, accumulator: R): R {
|
||||
for (const item of iter) {
|
||||
accumulator = fn(accumulator, item);
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export function join(iter: IterableIterator<{ toString: () => string }>, glue: string): string {
|
||||
const first = iter.next();
|
||||
|
||||
if (first.done) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let result = first.value.toString();
|
||||
|
||||
for (const item of iter) {
|
||||
result += glue + item;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* PhantomData akin to Rust, because sometimes you need to be smarter than
|
||||
* the compiler.
|
||||
*/
|
||||
export class PhantomData<P> { private __PHANTOM__: P }
|
||||
|
||||
/**
|
||||
* Opaque type, similar to `opaque type` in Flow, or new types in Rust/C.
|
||||
* These should be produced only by manually casting `t as Opaque<T, P>`.
|
||||
*
|
||||
* `P` can be anything as it's never actually used. Using strings is okay:
|
||||
*
|
||||
* ```
|
||||
* type MyType = Opaque<number, 'MyType'>;
|
||||
* ```
|
||||
*/
|
||||
export type Opaque<T, P> = T & PhantomData<P>;
|
||||
|
||||
/**
|
||||
* Just a readable shorthand for null-ish-able types, akin to `T?` in Flow.
|
||||
*/
|
||||
export type Maybe<T> = T | null | undefined;
|
||||
Reference in New Issue
Block a user