repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
sgsonu/covid-vaccine-distribution | services/server/src/models/getPatientTrend/index.ts | import { Brackets, getConnection } from "typeorm";
import { User } from "../../entity/User";
interface PatientTrend {
count: number;
isVaccinated: boolean;
vaccinationDate: string;
}
export const getPatientTrend = async (
lastNumDays?: number,
nextNumDays?: number
): Promise<PatientTrend[]> => {
const dbC... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/user/index.ts | import { Router } from "express";
import { addProfileRouter } from "./addProfile";
export const userRouter = Router();
userRouter.use("/patient_profile", addProfileRouter);
|
sgsonu/covid-vaccine-distribution | services/server/src/models/utils/sendMail/index.ts | <gh_stars>0
import { createTransport } from "nodemailer";
export interface EmailProps {
to: string;
html: string;
subject: string;
}
export const sendMail = async ({ to, html, subject }: EmailProps) => {
const transporter = createTransport({
service: process.env.SMTP_SERVICE,
host: process.env.SMTP_HO... |
sgsonu/covid-vaccine-distribution | services/server/src/models/getAdmins/index.ts | import { Point } from "geojson";
import { getConnection } from "typeorm";
import { User } from "../../entity/User";
interface AdminType {
email: string;
location: Point;
firstName: string;
lastName?: string;
}
export const getAdmins = async (): Promise<AdminType[]> => {
const dbConnection = getConnection();... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/auth/logout.ts | <filename>services/server/src/routers/auth/logout.ts
import { Response, Router } from "express";
import { logout } from "../../models/auth/logout";
export const logoutRouter = Router();
logoutRouter.post(
"/",
(_, res: Response): Response => {
logout(res);
return res.status(200).send({ success: true });
... |
sgsonu/covid-vaccine-distribution | services/server/src/models/middlewares/verifyAdmin.ts | <filename>services/server/src/models/middlewares/verifyAdmin.ts
import { NextFunction, Request, Response } from "express";
export const verifyAdmin = (
req: Request,
res: Response,
next: NextFunction
): void | Response => {
if (!req.user.isAdmin)
return res.status(400).send({ error: "Not authorized" });
... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/auth/signUp/validate.ts | <filename>services/server/src/routers/auth/signUp/validate.ts<gh_stars>0
import { SignUpProps } from "../../../models/auth/signUp";
import { isEmail } from "../../utils/isEmail";
export const validate = ({
email,
firstName,
password,
lat,
lng,
}: SignUpProps): string[] => {
const errors: string[] = [];
... |
sgsonu/covid-vaccine-distribution | services/server/src/models/auth/signUp/index.ts | <gh_stars>0
import { hash } from "bcryptjs";
import { getConnection } from "typeorm";
import { User } from "../../../entity/User";
import { sendMail } from "../../utils/sendMail";
import { v4 as genHash } from "uuid";
export interface SignUpProps {
firstName: string;
lastName?: string;
email: string;
password:... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/auth/refreshToken.ts | import { Router, Request, Response } from "express";
import { refreshToken } from "../../models/auth/refreshToken";
const refreshTokenRouter = Router();
refreshTokenRouter.post(
"/",
async (req: Request, res: Response): Promise<Response> => {
const token: string = req.cookies.jid;
if (!token) {
ret... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/utils/isDate.ts | <filename>services/server/src/routers/utils/isDate.ts
export const isDate = (date: Date): boolean =>
Object.prototype.toString.call(date) === "[object Date]" &&
!isNaN(date.getTime());
|
sgsonu/covid-vaccine-distribution | services/server/src/routers/user/addProfile/index.ts | import { Request, Response, Router } from "express";
import { addPatientProfile } from "../../../models/user/addPatientProfile";
import { verifyUser } from "../../../models/middlewares/verifyUser";
import { validate } from "./validate";
export const addProfileRouter = Router();
addProfileRouter.post(
"/",
verifyU... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/root/signUpAdmin/index.ts | import { Request, Response, Router } from "express";
import { signUp } from "../../../models/auth/signUp";
import { validate } from "../../auth/signUp/validate";
export const signUpAdminRouter = Router();
signUpAdminRouter.post(
"/",
async (req: Request, res: Response): Promise<Response> => {
const errors: st... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/auth/index.ts | import { Router } from "express";
import { loginRouter } from "./login";
import { logoutRouter } from "./logout";
import { refreshTokenRouter } from "./refreshToken";
import { signUpRouter } from "./signUp/signUp";
import { verifyEmailRouter } from "./verifyEmail";
export const authRouter = Router();
authRouter.use("... |
sgsonu/covid-vaccine-distribution | services/server/src/models/utils/pythonExec.ts | <filename>services/server/src/models/utils/pythonExec.ts
import { resolve } from "path";
import { PythonShell } from "python-shell";
export const pythonExec = (
pythonScript: string,
args: string[]
): Promise<string[]> => {
return new Promise((done, reject) =>
PythonShell.run(
resolve(pythonScript),
... |
sgsonu/covid-vaccine-distribution | services/server/src/models/user/addPatientProfile/index.ts | import fetch from "node-fetch";
import { getConnection } from "typeorm";
import { PatientProfile } from "../../../entity/PatientProfile";
import { User } from "../../../entity/User";
export interface AddPatientProfileProps extends PatientProfile {
user: User;
}
const getDateDiff = (date1: string, date2: string): nu... |
sgsonu/covid-vaccine-distribution | services/server/src/models/middlewares/verifyUser.ts | <filename>services/server/src/models/middlewares/verifyUser.ts<gh_stars>0
import { NextFunction, Request, Response } from "express";
import { verify } from "jsonwebtoken";
import { getConnection } from "typeorm";
import { User } from "../../entity/User";
import { Payload } from "../../types/Payload";
export const veri... |
sgsonu/covid-vaccine-distribution | services/server/src/models/admin/scheduleVaccination/timeSlots.ts | <filename>services/server/src/models/admin/scheduleVaccination/timeSlots.ts
export const timeSlots: string[] = [
`9:00 AM - 10:00 AM`,
`10:00 AM - 11:00 AM`,
`11:00 AM - 12:00 PM`,
`12:00 PM - 1:00 PM`,
`2:00 PM - 3:00 PM`,
`3:00 PM - 4:00 PM`,
`4:00 PM - 5:00 PM`,
`5:00 PM - 6:00 PM`,
];
|
sgsonu/covid-vaccine-distribution | services/server/src/routers/admin/scheduleVaccination/index.ts | <filename>services/server/src/routers/admin/scheduleVaccination/index.ts
import { Request, Response, Router } from "express";
import { scheduleVaccination } from "../../../models/admin/scheduleVaccination";
export const scheduleVaccinationRouter = Router();
scheduleVaccinationRouter.post(
"/",
async (req: Request... |
sgsonu/covid-vaccine-distribution | services/server/src/models/auth/logout/index.ts | import { Response } from "express";
export const logout = (res: Response): boolean => {
res.clearCookie("jid", {
httpOnly: true,
path: "/auth/refresh_token",
});
return true;
};
|
sgsonu/covid-vaccine-distribution | services/server/src/models/utils/createRefreshToken.ts | import { sign } from "jsonwebtoken";
import { Payload } from "../../types/Payload";
export const createRefreshToken = (payload: Payload): string =>
sign(payload, process.env.REFRESH_TOKEN_SECRET!, { expiresIn: "7d" });
|
sgsonu/covid-vaccine-distribution | services/server/src/routers/auth/login.ts | import { Request, Response, Router } from "express";
import { login } from "../../models/auth/login";
import { isEmail } from "../utils/isEmail";
export const loginRouter = Router();
loginRouter.post(
"/",
async (req: Request, res: Response): Promise<Response> => {
const errors = [];
const { email, passw... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/getPatientTrend/index.ts | <filename>services/server/src/routers/getPatientTrend/index.ts
import { Router, Response, Request } from "express";
import { getPatientTrend } from "../../models/getPatientTrend";
export const getPatientTrendRouter = Router();
getPatientTrendRouter.get(
"/",
async (req: Request, res: Response): Promise<Response> ... |
sgsonu/covid-vaccine-distribution | services/server/src/routers/root/experimental/index.ts | <filename>services/server/src/routers/root/experimental/index.ts
import { Router } from "express";
import { signUpRandomAdminsUsersRouter } from "./signUpRandomAdminsUsers";
export const experimentalRootRouter = Router();
experimentalRootRouter.use(
"/random_admins_users",
signUpRandomAdminsUsersRouter
);
|
sgsonu/covid-vaccine-distribution | services/server/src/routers/admin/index.ts | import { Router } from "express";
import { getNonScheduledPatientsRouter } from "./getNonScheduledPatients";
import { getRegisteredPatientsRouter } from "./getRegisteredPatients";
import { scheduleVaccinationRouter } from "./scheduleVaccination";
export const adminRouter = Router();
adminRouter.use("/schedule_vaccina... |
sgsonu/covid-vaccine-distribution | services/server/src/types/Payload.ts | <gh_stars>0
import { Point } from "geojson";
export interface Payload {
email: string;
firstName: string;
lastName: string;
isAdmin: boolean;
isSuperUser: boolean;
isProfileAdded: boolean;
vaccinationDate?: string;
location: Point;
}
|
sgsonu/covid-vaccine-distribution | services/server/src/routers/admin/getRegisteredPatients/index.ts | import { Request, Response, Router } from "express";
import { getRegisteredPatients } from "../../../models/admin/getRegisteredPatients";
export const getRegisteredPatientsRouter = Router();
getRegisteredPatientsRouter.get(
"/",
async (req: Request, res: Response): Promise<Response> => {
const { lastNumDays, ... |
Juansereina/protractor-workshop-2019 | src/page/shipping-step.page.ts | import { $, ElementFinder } from 'protractor';
export class ShippingStepPage {
private acceptButton: ElementFinder;
private continueButton: ElementFinder;
constructor () {
this.acceptButton = $('#cgv');
this.continueButton = $('#form > p > button > span');
}
public async acceptAndContinue(): Promis... |
Juansereina/protractor-workshop-2019 | src/page/product-list.page.ts | import { $, ElementFinder, element, by, browser } from 'protractor';
export class ProductListPage {
private addToCartButton: ElementFinder;
private product: ElementFinder;
constructor () {
this.addToCartButton = $('#center_column a.button.ajax_add_to_cart_button.btn.btn-default');
this.product = element... |
Juansereina/protractor-workshop-2019 | src/page/order-summary.page.ts | import { $, ElementFinder } from 'protractor';
export class OrderSummaryPage {
private order: ElementFinder;
constructor () {
this.order = $('#center_column > div > p > strong');
}
public async getSummary():Promise<String> {
return this.order.getText();
}
}
|
Juansereina/protractor-workshop-2019 | test/buy-tshirt.spec.ts | <gh_stars>0
import { browser } from 'protractor';
import {
MenuContentPage,
ProductListPage,
ProductAddedModalPage,
SummaryStepPage,
SignInStepPage,
AddressStepPage,
ShippingStepPage,
PaymentStepPage,
BankPaymentPage,
OrderSummaryPage
} from '../src/page/';
describe('Buy a t-shirt', () => {
const... |
Juansereina/protractor-workshop-2019 | src/page/payment-step.page.ts | import { $, ElementFinder } from 'protractor';
export class PaymentStepPage {
private paymentButton: ElementFinder;
constructor () {
this.paymentButton = $('#HOOK_PAYMENT > div:nth-child(1) > div > p > a');
}
public async pay(): Promise<void> {
await this.paymentButton.click();
}
}
|
Juansereina/protractor-workshop-2019 | src/page/product-added-modal.page.ts | <gh_stars>0
import { $, ElementFinder } from 'protractor';
export class ProductAddedModalPage {
private modal: ElementFinder;
constructor () {
this.modal = $('[style*="display: block;"] .button-container > a');
}
public async open(): Promise<void> {
await this.modal.click();
}
}
|
Juansereina/protractor-workshop-2019 | src/page/summary-step.page.ts | import { $, ElementFinder } from 'protractor';
export class SummaryStepPage {
private summaryPage: ElementFinder;
constructor () {
this.summaryPage = $('.cart_navigation span');
}
public async checkout(): Promise<void> {
await this.summaryPage.click();
}
}
|
MECVxD/nest-library | src/test.ts | <reponame>MECVxD/nest-library
export function getHello(name: string): string {
return 'Hola' + name;
}
export function suma(x: number, y: number): number {
return x + y;
}
export function resta(x: number, y: number): number {
return x - y;
}
|
tvalodia/battletron | webapp/src/app/game-view/game-view.service.spec.ts | import { TestBed } from '@angular/core/testing';
import { GameViewService } from './game-view.service';
describe('GameViewService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: GameViewService = TestBed.get(GameViewService);
expect(service).... |
tvalodia/battletron | webapp/src/app/spectate-game/spectate-game.component.ts | <reponame>tvalodia/battletron<filename>webapp/src/app/spectate-game/spectate-game.component.ts
import {Component, OnInit, ViewChild} from '@angular/core';
import {GameService} from "../api/game.service";
import {WebsocketService} from "../game-view/websocket.service";
import {Game, GameViewService} from "../game-view/g... |
tvalodia/battletron | webapp/src/app/game-view/game-view.component.ts | <reponame>tvalodia/battletron
import {
Component,
ElementRef,
EventEmitter,
NgZone, OnDestroy,
OnInit,
Output,
ViewChild
} from '@angular/core';
import {Game, GameViewService} from "./game-view.service";
@Component({
selector: 'app-game-view',
templateUrl: './game-view.component.html',
styleUrls: [... |
tvalodia/battletron | webapp/src/app/new-game/new-game-player.ts | export class NewGamePlayer {
playerType: string;
aiRemoteHost: string;
}
|
tvalodia/battletron | webapp/src/app/spectate-game/status.pipe.ts | <filename>webapp/src/app/spectate-game/status.pipe.ts
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'status'
})
export class StatusPipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value == "COMPLETED_WINNER") {
return "WINNER";
} else if (value == "COMP... |
tvalodia/battletron | webapp/src/app/spectate-game/spectate-game.ts | export class SpectateGame {
sessionId: string;
}
|
tvalodia/battletron | webapp/src/app/api/game.service.ts | import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {NewGame} from "../new-game/new-game";
import {JoinGame} from "../join-game/join-game";
import {SpectateGame} from "../spectate-game/spectate-game";
@Injectable({
providedIn: 'root'
})
export class GameService {
API... |
tvalodia/battletron | webapp/src/app/game-view/game-view.service.ts | import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Rx';
import {WebsocketService} from './websocket.service';
const GAME_URL = 'ws://' + document.location.host + '/player';
export interface Game {
id: number;
width: number;
height: number;
gameStatus: string;
tickCount: number;
playerOn... |
tvalodia/battletron | webapp/src/app/new-game/new-game.ts | import {NewGamePlayer} from "./new-game-player";
export class NewGame {
sessionId: string;
playerOne: NewGamePlayer = new NewGamePlayer();
playerTwo: NewGamePlayer = new NewGamePlayer();
}
|
tvalodia/battletron | webapp/src/app/app.module.ts | import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {FormsModule, ReactiveFormsModule} f... |
tvalodia/battletron | webapp/src/app/join-game/join-game.ts | export class JoinGame {
sessionId: string;
}
|
tvalodia/battletron | webapp/src/app/app-routing.module.ts | import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {MainMenuComponent} from "./main-menu/main-menu.component";
import {NewGameComponent} from "./new-game/new-game.component";
import {SpectateGameComponent} from "./spectate-game/spectate-game.component";
import {Join... |
tvalodia/battletron | webapp/src/app/material.ts | <gh_stars>0
import {
MatButtonModule,
MatButtonToggleModule,
MatCardModule, MatGridListModule, MatListModule,
MatSelectModule, MatDialogModule, MatInputModule
} from "@angular/material";
import {NgModule} from "@angular/core";
@NgModule({
imports: [MatCardModule, MatButtonModule, MatButtonToggleModule, MatSe... |
tvalodia/battletron | webapp/src/app/join-game/join-game.component.ts | <filename>webapp/src/app/join-game/join-game.component.ts
import {Component, OnInit, ViewChild} from '@angular/core';
import {GameService} from "../api/game.service";
import {WebsocketService} from "../game-view/websocket.service";
import {Game, GameViewService} from "../game-view/game-view.service";
import {GameViewCo... |
tvalodia/battletron | webapp/src/app/new-game/new-game.component.ts | <reponame>tvalodia/battletron<filename>webapp/src/app/new-game/new-game.component.ts
import {Component, OnInit} from '@angular/core';
import {GameViewService} from '../game-view/game-view.service';
import {WebsocketService} from "../game-view/websocket.service";
import {GameService} from "../api/game.service";
import {... |
xiaohuidong99/Ionic2-IonicClub | app/pages/topicDetail/topicDetail.ts | import {Page, Loading, NavController, NavParams, Storage, LocalStorage} from "ionic-angular";
import {IonicService} from "../../services/IonicService";
import {ConfigService} from "../../services/ConfigService";
import {AmTimeAgoPipe} from '../../pipe/AmTimeAgoPipe';
import {AvatarPipe} from "../../pipe/avatarPipe";
im... |
xiaohuidong99/Ionic2-IonicClub | app/pipe/DateFormatPipe.ts | <filename>app/pipe/DateFormatPipe.ts
import {PipeTransform, Pipe} from "angular2/core";
@Pipe({
name: 'dateFormatPipe'
})
export class DateFormatPipe implements PipeTransform {
constructor() {
}
transform(value:string, args:any[]) {
if (value && args) {
value = this.Format(value,args[0]);
}
... |
xiaohuidong99/Ionic2-IonicClub | app/pages/account/account.ts | <reponame>xiaohuidong99/Ionic2-IonicClub
import {Page, NavController, Storage, LocalStorage, Modal, ViewController, Events} from 'ionic-angular';
import {IonicService} from "../../services/IonicService";
import {ConfigService} from "../../services/ConfigService";
import {MyCollectsPage} from "../modal/myCollects/myColl... |
xiaohuidong99/Ionic2-IonicClub | app/pages/modal/myCollects/myCollects.ts | import {Page, NavParams, ViewController, Storage, LocalStorage} from 'ionic-angular';
import {IonicService} from "../../../services/IonicService";
import {ConfigService} from "../../../services/ConfigService";
import {AmTimeAgoPipe} from '../../../pipe/AmTimeAgoPipe';
import {AvatarPipe} from "../../../pipe/avatarPipe"... |
xiaohuidong99/Ionic2-IonicClub | app/services/CommonService.ts | import {Injectable} from 'angular2/core';
@Injectable()
export class CommonService {
constructor(){
}
private _tabs = [{
value: 'share',
label: '分享',
icon:'share'
}, {
value: 'ask',
label: '问答',
icon:'help-circle'
}, {
value: 'job',
label: '招聘',
icon:'bowtie'
}, {
... |
xiaohuidong99/Ionic2-IonicClub | app/pages/modal/myMessages/myMessages.ts | import {Page, NavParams, ViewController, Storage, LocalStorage, Events} from 'ionic-angular';
import {IonicService} from "../../../services/IonicService";
import {ConfigService} from "../../../services/ConfigService";
@Page({
templateUrl: 'build/pages/modal/myMessages/myMessages.html',
providers: [IonicService, C... |
xiaohuidong99/Ionic2-IonicClub | app/services/ConfigService.ts | <reponame>xiaohuidong99/Ionic2-IonicClub<filename>app/services/ConfigService.ts
import {Injectable} from 'angular2/core';
@Injectable()
export class ConfigService {
hostURL:string = "http://ionichina.com";
constructor() {
}
getHost() {
return this.hostURL;
}
}
|
xiaohuidong99/Ionic2-IonicClub | app/app.ts | <reponame>xiaohuidong99/Ionic2-IonicClub
import 'es6-shim';
import {App, Platform, IonicApp} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {CommonService} from "./services/CommonService";
import {RouteConfig} from "angular2/router";
import {TopicsPage} from "./pages/topics/topics";
import {UserPa... |
xiaohuidong99/Ionic2-IonicClub | app/directives/helpers.ts | <filename>app/directives/helpers.ts
import {Directive, ElementRef, Renderer} from 'angular2/core';
import {Platform, Navbar} from 'ionic-angular';
export function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this, args = arguments;
var later = function () {
timeo... |
xiaohuidong99/Ionic2-IonicClub | app/pages/modal/topicAdd/topicAdd.ts | import {Page, NavController, ViewController, Loading, Storage, LocalStorage, Events} from 'ionic-angular';
import {IonicService} from "../../../services/IonicService";
import {ConfigService} from "../../../services/ConfigService";
@Page({
templateUrl: 'build/pages/modal/topicAdd/topicAdd.html',
providers: [IonicSe... |
xiaohuidong99/Ionic2-IonicClub | app/services/IonicService.ts | import {Injectable, Inject} from 'angular2/core';
import {Http, HTTP_PROVIDERS, Response, Headers} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import {ConfigService} from "./ConfigService";
import * as helper from '../directives/helpers';
import 'rxjs/Rx';
@Injectable()
export class IonicServi... |
xiaohuidong99/Ionic2-IonicClub | app/pipe/TabNamePipe.ts | import {PipeTransform, Pipe} from "angular2/core";
import {CommonService} from "../services/CommonService";
@Pipe({
name: 'tabNamePipe'
})
export class TabNamePipe implements PipeTransform {
public tabList;
constructor(private commonService:CommonService) {
this.tabList = this.commonService.getTabs();
}
... |
xiaohuidong99/Ionic2-IonicClub | app/pages/modal/myTopics/myTopics.ts | import {Page, NavParams, ViewController} from 'ionic-angular';
import {ConfigService} from "../../../services/ConfigService";
import {AmTimeAgoPipe} from '../../../pipe/AmTimeAgoPipe';
import {AvatarPipe} from "../../../pipe/avatarPipe";
@Page({
templateUrl: 'build/pages/modal/myTopics/myTopics.html',
pipes: [AmT... |
xiaohuidong99/Ionic2-IonicClub | app/pipe/LinkPipe.ts | import {PipeTransform, Pipe} from "angular2/core";
@Pipe({
name: 'linkPipe'
})
export class LinkPipe implements PipeTransform {
constructor() {
}
transform(value:string, args:any[]) {
if (typeof value === 'string') {
var topicFullLinkRegex = /href="([\S]+)\/topic\/([\S]+)"/gi;
var userF... |
xiaohuidong99/Ionic2-IonicClub | app/pages/topics/topics.ts | <filename>app/pages/topics/topics.ts
import {Page, NavController, NavParams, Modal, Storage, LocalStorage, Events} from 'ionic-angular';
import {IonicService} from "../../services/IonicService";
import {ConfigService} from "../../services/ConfigService";
import {TabNamePipe} from "../../pipe/TabNamePipe";
import {Avata... |
xiaohuidong99/Ionic2-IonicClub | app/pipe/AvatarPipe.ts | import {PipeTransform, Pipe} from "angular2/core";
@Pipe({
name: 'avatarPipe'
})
export class AvatarPipe implements PipeTransform {
constructor() {
}
transform(value:string, args:any[]) {
// add https protocol
if (value) {
value = value.replace("https://avatars.githubusercontent.com", "http://7... |
xiaohuidong99/Ionic2-IonicClub | app/pages/login/login.ts | <reponame>xiaohuidong99/Ionic2-IonicClub<filename>app/pages/login/login.ts
import {Page, Alert, NavController, Storage, LocalStorage, ViewController} from 'ionic-angular';
import {IonicService} from "../../services/IonicService";
import {ConfigService} from "../../services/ConfigService";
import {BarcodeScanner} from '... |
xiaohuidong99/Ionic2-IonicClub | app/pipe/AmTimeAgoPipe.ts | import {PipeTransform, Pipe} from "angular2/core";
@Pipe({
name: 'amTimeAgoPipe'
})
export class AmTimeAgoPipe implements PipeTransform {
constructor() {
}
transform(value:string, args:any[]) {
if (value) {
value = this.getDateDiff(value)
}
return value;
}
getDateDiff(pTime:string) {
... |
xiaohuidong99/Ionic2-IonicClub | app/pages/user/user.ts | import {Page, NavController, NavParams} from 'ionic-angular';
import {IonicService} from "../../services/IonicService";
import {ConfigService} from "../../services/ConfigService";
import {AmTimeAgoPipe} from '../../pipe/AmTimeAgoPipe';
import {AvatarPipe} from "../../pipe/avatarPipe";
import {DateFormatPipe} from "../.... |
andrewcaires/vue-fetch | src/vue-fetch.ts | import { EventEmitter, isDef } from '@andrewcaires/utils.js';
import Vue from 'vue';
export interface VueFetchOptions {
url?: string;
headers?: VueFetchHeaders;
logging?: VueFetchLog;
timeout?: number;
}
export interface VueFetchBody {
json: boolean;
parse: any;
}
export type VueFetchHeaders = { [key: st... |
c2d7fa/miscjs | src/spec.ts | <gh_stars>0
export type Rest<Xs extends any[]> = Xs extends [any, ...infer Ys] ? Ys : never;
type LiteralIn<Ks extends string[]> = Ks[number];
type BasicTypes = {
string: string;
number: number;
boolean: boolean;
null: null;
undefined: undefined;
date: Date;
};
const $_array = Symbol("arrayOf");
export c... |
c2d7fa/miscjs | src/index.ts | <reponame>c2d7fa/miscjs
export {default as choose} from "./choose";
export * as spec from "./spec";
export {get, set, update} from "./update";
// Returns `true` if the two arrays are equal, in the sense that they contain
// the same elements at the same positions. If `eq` is given, it is used to
// compare the element... |
c2d7fa/miscjs | src/index.test.ts | /// <reference types="jest" />
import {implies} from "./index";
describe("implies", () => {
it("false implies anything", () => {
expect(implies(false, true)).toBeTruthy();
expect(implies(false, false)).toBeTruthy();
});
it("true only implies true", () => {
expect(implies(true, true)).toBeTruthy();
... |
c2d7fa/miscjs | src/update.test.ts | /// <reference types="@types/jest" />
import {get, set, update} from "./update";
describe("getting a value", () => {
test("at an empty path is just the value itself", () => {
expect(get({a: 1}, "")).toEqual({a: 1});
});
test("at a path with one key is the value at that key", () => {
expect(get({a: 1}, ... |
c2d7fa/miscjs | src/choose.ts | <reponame>c2d7fa/miscjs
export default function choose<R>(
choice: string,
options: {[key: string]: () => R},
): {found: true; value: R} | {found: false; value: undefined} {
const found = choice in options;
if (found) {
return {found, value: options[choice]()};
} else {
return {found, value: undefine... |
c2d7fa/miscjs | src/spec.test.ts | /// <reference types="@types/jest" />
import {$array, $check, $literal, $nullable, $or, isValid} from "./spec";
describe("basic types", () => {
test("strings are strings", () => {
expect(isValid("string", "this is a string")).toBeTruthy();
});
test("numbers are numbers", () => {
expect(isValid("number"... |
c2d7fa/miscjs | src/update.ts | <filename>src/update.ts
type GetPath<O, P> = P extends ""
? O
: P extends `${infer Left}.${infer Right}`
?
| GetPath<NonNullable<GetPath<O, Left>>, Right>
| (null extends GetPath<O, Left> ? null : never)
| (undefined extends GetPath<O, Left> ? undefined : never)
: P extends keyof O
? O[P]
... |
c2d7fa/miscjs | src/choose.test.ts | <gh_stars>0
/// <reference types="jest" />
import choose from "./choose";
describe("choose", () => {
describe("a valid option", () => {
const result = choose("valid", {
valid() {
return 1;
},
});
it("is found", () => {
expect(result.found).toBe(true);
});
it("is evalu... |
gzigzigzeo/protobuf-as | src/walker_as/prettify.ts | <gh_stars>1-10
import { File } from '../walker/index.js';
import prettier from 'prettier';
// Options for prettier, TODO: move to WalkerAS
const prettierOptions: prettier.Options = {
parser: 'typescript',
tabWidth: 2,
};
export function prettify(files: File[]): File[] {
return files.map((file: File) => <F... |
gzigzigzeo/protobuf-as | tests/__fixtures__/build/nested.d.ts | <gh_stars>1-10
/**
* tests/__fixtures__/assembly/nested/encode
* @param obj `tests/__fixtures__/as_proto/nested/nested/Person`
* @returns `~lib/arraybuffer/ArrayBuffer`
*/
export declare function encode(obj: __Record3<undefined>): ArrayBuffer;
/**
* tests/__fixtures__/assembly/nested/decode
* @param buffer `~lib/... |
gzigzigzeo/protobuf-as | tests/__fixtures__/ts_proto/elementaries/main.ts | <reponame>gzigzigzeo/protobuf-as<gh_stars>1-10
/* eslint-disable */
import Long from 'long';
import _m0 from 'protobufjs/minimal.js';
export const protobufPackage = '';
export enum Enum {
Zero = 0,
One = 1,
Two = 2,
UNRECOGNIZED = -1,
}
export function enumFromJSON(object: any): Enum {
switch (ob... |
gzigzigzeo/protobuf-as | tests/__fixtures__/build/lists.d.ts | /**
* tests/__fixtures__/assembly/lists/encode
* @param obj `tests/__fixtures__/as_proto/lists/lists/Lists`
* @returns `~lib/arraybuffer/ArrayBuffer`
*/
export declare function encode(obj: __Record3<undefined>): ArrayBuffer;
/**
* tests/__fixtures__/assembly/lists/decode
* @param buffer `~lib/arraybuffer/ArrayBuf... |
gzigzigzeo/protobuf-as | tests/__fixtures__/assembly/nested.ts | import { Person } from '../as_proto/nested/nested';
export function encode(obj: Person): ArrayBuffer {
return obj.encode()
}
export function decode(buffer: ArrayBuffer): Person {
return Person.decode(buffer)
}
export function size(obj: Person): u32 {
return obj.size()
}
|
gzigzigzeo/protobuf-as | src/walker_as/namespace_single_file.ts | import { decorated } from "../proto/index.js";
import { Writer } from "./index.js";
/**
* Namespace code blocks
*/
export class NamespaceSingleFile {
constructor(private p:Writer) {}
start(ns:decorated.Namespace) {
if (ns.name == "") {
return
}
ns.name.split(".").forEach(... |
gzigzigzeo/protobuf-as | src/walker_as/size.ts | import { decorated } from '../proto/index.js';
import { Writer, GlobalsRegistry } from './index.js';
import { getTypeInfo, TypeInfo } from './type_info.js';
import { relativeName, embedNamespace } from './internal.js';
/**
* Generates message size() and __size helper methods
*/
export class Size {
private sizer ... |
gzigzigzeo/protobuf-as | tests/__fixtures__/build/complex_struct.d.ts | <reponame>gzigzigzeo/protobuf-as
/**
* tests/__fixtures__/assembly/complex_struct/encode
* @param obj `tests/__fixtures__/as_proto/complex_struct/complex_struct/Message`
* @returns `~lib/arraybuffer/ArrayBuffer`
*/
export declare function encode(obj: __Record3<undefined>): ArrayBuffer;
/**
* tests/__fixtures__/ass... |
gzigzigzeo/protobuf-as | assembly/ext/google.protobuf.Struct.ts | // Returns struct field by name. If field does not exists, it gets created and added to the fields collection.
get(name: string): Value {
if (this.fields.has(name)) {
return this.fields.get(name);
}
const v = new Value()
v.setNull()
this.fields.set(name, v)
return v
}
|
gzigzigzeo/protobuf-as | tests/__fixtures__/assembly/lists.ts | import { Lists } from '../as_proto/lists/lists';
export function encode(obj: Lists): ArrayBuffer {
return obj.encode()
}
export function decode(buffer: ArrayBuffer): Lists {
return Lists.decode(buffer)
}
export function size(obj: Lists): u32 {
return obj.size()
}
|
gzigzigzeo/protobuf-as | src/walker_as/namespace_multi_file.ts | <reponame>gzigzigzeo/protobuf-as<filename>src/walker_as/namespace_multi_file.ts
import { decorated } from "../proto/index.js";
import { Writer } from "./index.js";
import { namespaceToFileName, getRelPath } from './internal.js';
/**
* Namespace code blocks
*/
export class NamespaceMultiFile {
constructor(private... |
gzigzigzeo/protobuf-as | tests/__fixtures__/ts_proto/lists/main.ts | <reponame>gzigzigzeo/protobuf-as<gh_stars>1-10
/* eslint-disable */
import Long from 'long';
import _m0 from 'protobufjs/minimal.js';
export const protobufPackage = '';
export enum Enum {
Zero = 0,
One = 1,
Two = 2,
UNRECOGNIZED = -1,
}
export function enumFromJSON(object: any): Enum {
switch (ob... |
gzigzigzeo/protobuf-as | src/walker_as/walker_as_single_file.ts | <reponame>gzigzigzeo/protobuf-as<gh_stars>1-10
import { FlatWalker, File } from '../walker/index.js';
import { decorated } from '../proto/index.js';
import { BlocksSingleFile } from './blocks_single_file.js';
import { NamespaceSingleFile } from './namespace_single_file.js';
import { Enum } from './enum.js';
import { Me... |
gzigzigzeo/protobuf-as | tests/assembly/elementaries.test.ts | import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { Elementaries, Enum } from '../__fixtures__/ts_proto/elementaries/main.js';
import { encode, decode, size } from '../__fixtures__/build/elementaries.js';
import { TextEncoder, TextDecoder } from 'util';
const subject: Elementaries = {
Double... |
gzigzigzeo/protobuf-as | tests/assembly/lists.test.ts | <reponame>gzigzigzeo/protobuf-as
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { Lists, Message, Enum } from '../__fixtures__/ts_proto/lists/main.js';
import { encode, decode, size } from '../__fixtures__/build/lists.js';
import { TextEncoder, TextDecoder } from 'util';
const subject: Lists ... |
gzigzigzeo/protobuf-as | tests/__fixtures__/as_proto/lists/lists.ts | namespace __proto {
/**
* Decoder implements protobuf message decode interface.
*
* Useful references:
*
* Protocol Buffer encoding: https://developers.google.com/protocol-buffers/docs/encoding
* LEB128 encoding AKA varint 128 encoding: https://en.wikipedia.org/wiki/LEB128
* ZigZag encoding/decod... |
gzigzigzeo/protobuf-as | src/proto/named_descriptor_index_reducer.ts | import { WeightMap, ImmutableFlatTree } from '../structs/index.js';
import * as named from './named_descriptor.js';
/**
* Performs tree-shaking of the named descriptor index.
* Removes unused descriptors. Removes explicitly requested descriptors. Performs integritiy check.
*/
export class NamedDescriptorIndexReduc... |
gzigzigzeo/protobuf-as | tests/assembly/maps.test.ts | import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { Maps } from '../__fixtures__/ts_proto/maps/main.js';
import { encode, decode, size } from '../__fixtures__/build/maps.js';
const subject: Maps = {
StringStringMap: { key1: 'value1', key2: 'value2', key3: '', key4: 'value4', '': 'value5' },
... |
gzigzigzeo/protobuf-as | tests/__fixtures__/as_proto/complex_struct/complex_struct.ts | namespace __proto {
/**
* Decoder implements protobuf message decode interface.
*
* Useful references:
*
* Protocol Buffer encoding: https://developers.google.com/protocol-buffers/docs/encoding
* LEB128 encoding AKA varint 128 encoding: https://en.wikipedia.org/wiki/LEB128
* ZigZag encoding/decod... |
gzigzigzeo/protobuf-as | src/walker_as/index.ts | <filename>src/walker_as/index.ts
export * from './walker_as_single_file.js';
export * from './walker_as_multi_file.js';
// Writer implements generic function which prints a code piece
export type Writer = (value: string) => void;
// Global code blocks registry
export interface GlobalsRegistry {
registerGlobal(key... |
gzigzigzeo/protobuf-as | tests/__fixtures__/as_proto/maps/maps.ts | <gh_stars>1-10
namespace __proto {
/**
* Decoder implements protobuf message decode interface.
*
* Useful references:
*
* Protocol Buffer encoding: https://developers.google.com/protocol-buffers/docs/encoding
* LEB128 encoding AKA varint 128 encoding: https://en.wikipedia.org/wiki/LEB128
* ZigZag... |
gzigzigzeo/protobuf-as | tests/__fixtures__/assembly/maps.ts | import { Maps } from '../as_proto/maps/maps';
export function encode(obj: Maps): ArrayBuffer {
return obj.encode()
}
export function decode(buffer: ArrayBuffer): Maps {
return Maps.decode(buffer)
}
export function size(obj: Maps): u32 {
return obj.size()
}
|
gzigzigzeo/protobuf-as | src/walker_as/internal.ts | import { decorated, named } from '../proto/index.js';
import path from 'path';
import { fileURLToPath } from 'url';
import changeCase from 'change-case';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// embedNamespace represents Decode, Encode and Size namespace name
e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.