type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
data => console.log(data) | JosephmBassey/fast-csv | examples/formatting-ts/examples/write_to_string.example.ts | TypeScript |
ArrowFunction |
async (req: NextApiRequest, res: NextApiResponse, ctx: IRequestContext) => {
const { param: dateOrMagic, format } = extractFormat(req, 'date', extractDateOrMagic);
const date = dateOrMagic instanceof Date ? dateOrMagic : await resolveMetaDate(dateOrMagic, ctx);
const region = extractRegion(req);
const data = () => fetchRegion(ctx, region, date);
return sendFormat(req, res, ctx, format, data, {
title: `${region.name}-${formatAPIDate(date)}`,
cache: estimateCacheDuration(date),
constantFields: {
date,
region: region.id,
},
});
} | sgratzl/yacobo | src/pages/api/region/[region]/date/[date].ts | TypeScript |
ArrowFunction |
() => fetchRegion(ctx, region, date) | sgratzl/yacobo | src/pages/api/region/[region]/date/[date].ts | TypeScript |
ArrowFunction |
(_) => Formula | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(_) => SPEC | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.startsWith(`icon_chara_all_${this.DF.toString().padStart(4, '0')}`) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => `img/icon_chara/Texture2D/${p}` | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(df) => Object.values(dataManager.files.img.icon_chara.Texture2D)
.filter((p) => p.startsWith(`icon_chara_all_${df.toString().padStart(4, '0')}`))
.map((p) => `img/icon_chara/Texture2D/${p}`)
.filter((p) => !images.includes(p)) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.startsWith(`icon_chara_all_${df.toString().padStart(4, '0')}`) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => !images.includes(p) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => [p, dataManager.questById[p.QUEST_DF]] | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
([, quest]) => quest | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.LV | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.key() | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => ({
level: p.key(),
skills: p.select((i) => dataManager.skillById[i.DF])
.where((p) => !!p)
.toArray(),
}) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(i) => dataManager.skillById[i.DF] | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => !!p | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.LV <= level | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => dataManager.skillById[p.DF] | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(skill) => skill.withComboSkills | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.id | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.NO >= startLevel && p.NO <= endLevel | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.FD | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.DF | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => ({
item: dataManager.itemById[p.key()],
qualities: p.groupBy((o) => o.QTY).select((o) => ({
quality: o.key(),
count: o.count(),
})).orderBy((o) => o.quality).toArray(),
}) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(o) => o.QTY | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(o) => ({
quality: o.key(),
count: o.count(),
}) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(o) => o.quality | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => !!p.item | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.item.DF | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => dataManager.lookup.elementMapSkillEffectTarget[element].includes(p.effectTarget) && p.effect === EBattleEffectKind.eSTATUS_FIX | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(sum, p) => sum + p.effectValue | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(element) => this.getElement(element, level) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.effectTarget === dataManager.lookup.stateMapSkillEffectTarget[state] | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(p) => p.effectTarget === dataManager.lookup.stateMapSkillEffectTarget[state] && p.effect === EBattleEffectKind.eSTATUS_FIX | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(state) => this.getState(state, level, foodLevel) | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ArrowFunction |
(_) => MVList | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ClassDeclaration |
export class SPEC {
@Type((_) => Formula)
HP: Formula;
@Type((_) => Formula)
SATK: Formula;
@Type((_) => Formula)
SDEF: Formula;
@Type((_) => Formula)
MATK: Formula;
@Type((_) => Formula)
MDEF: Formula;
@Type((_) => Formula)
SPD: Formula;
@Type((_) => Formula)
SDA: Formula;
@Type((_) => Formula)
LDA: Formula;
@Type((_) => Formula)
QTH: Formula;
@Type((_) => Formula)
DDG: Formula;
@Type((_) => Formula)
SADD: Formula;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ClassDeclaration |
export class Chara {
m_GameObject: MGameObject;
m_Enabled: number;
m_Script: MScript;
m_Name: string;
@Type((_) => MVList)
m_vList: MVList[];
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration | // custom types
export interface IElementResult {
element: string;
label: string;
skills: SkillList[],
value: number;
total: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface IStateResult {
state: string;
label: string;
skills: SkillList[],
value: number;
foodValue: number;
skillValue: number;
total: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration | // generated types
export interface MGameObject {
m_FileID: number;
m_PathID: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface MScript {
m_FileID: number;
m_PathID: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface SKILL {
DF: number;
LV: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface FD {
DF: number;
QTY: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface FDM {
NO: number;
GRD: number;
FD: FD[];
HP: number;
SATK: number;
SDEF: number;
MATK: number;
MDEF: number;
SPD: number;
SDA: number;
LDA: number;
QTH: number;
DDG: number;
SADD: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface QST {
NO: number;
QUEST_DF: number;
FLAG_DF: number;
LV: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface WEAPON {
GEN: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface GROW {
STAR: number;
STONE: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface AvHelmOffset {
id: number;
offsetY: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface MDL {
fScale: number;
eAnimKind: number;
avHelmOffset: AvHelmOffset[];
bMacho: number;
hairId: number;
eyeId: number;
headId: number;
voice: number;
weaponId: number;
bodyId: number;
shieldId: number;
helmId: number;
accId1: number;
accId2: number;
accId3: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
InterfaceDeclaration |
export interface BA {
LV: number;
DF: number;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration | // skills
public getRawSkills(level = MVList.maxLevel) {
return this.SKILL
.filter((p) => p.LV <= level)
.map((p) => dataManager.skillById[p.DF])
.filter((p) => p);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getSkills(level = MVList.maxLevel) {
const key = JSON.stringify({ level });
if (!this.#skillCache.has(key)) {
this.#skillCache.set(key, SkillList.removeOverrideSkills(this.getRawSkills(level)));
}
return this.#skillCache.get(key);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getSkillWithComboSkills(level = MVList.maxLevel) {
const key = JSON.stringify({ level });
if (!this.#skillWithComboSkillCache.has(key)) {
const skills = SkillList.removeOverrideSkills(this.getRawSkills(level))
.map((skill) => skill.withComboSkills)
.flat();
this.#skillWithComboSkillCache.set(key, Enumerable.from(skills).distinct((p) => p.id).toArray());
}
return this.#skillWithComboSkillCache.get(key);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getBlazeArt(level = MVList.maxLevel, blazeArtLevel = 5) {
const blazeArts = this.BA.filter((p) => p.LV <= level);
if (!blazeArts.length) {
return null;
}
const blazeArtLv = dataManager.blazeArtById[blazeArts[0].DF].LV;
const blazeArt = blazeArtLv[blazeArtLevel - 1];
return dataManager.skillById[blazeArt?.SKILL_DF];
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public totalFoods(startLevel = 1, endLevel = MVList.maxLevel) {
return Enumerable.from(this.FDM)
.where((p) => p.NO >= startLevel && p.NO <= endLevel)
.selectMany((p) => p.FD)
.groupBy((p) => p.DF)
.select((p) => ({
item: dataManager.itemById[p.key()],
qualities: p.groupBy((o) => o.QTY).select((o) => ({
quality: o.key(),
count: o.count(),
})).orderBy((o) => o.quality).toArray(),
}))
.where((p) => !!p.item)
.orderBy((p) => p.item.DF)
.toArray();
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration | //
public getElement(element: string, level = MVList.maxLevel) {
const key = JSON.stringify({ element, level });
if (!this.#elementCache.has(key)) {
const skills = this.getSkillWithComboSkills(level)
.filter((p) => dataManager.lookup.elementMapSkillEffectTarget[element].includes(p.effectTarget) && p.effect === EBattleEffectKind.eSTATUS_FIX);
const result = {
element,
label: dataManager.lookup.element[element],
value: skills.reduce((sum, p) => sum + p.effectValue, 0),
skills,
total: 0,
};
result.total = result.value;
this.#elementCache.set(key, result);
}
return this.#elementCache.get(key);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getElements(level = MVList.maxLevel) {
return Object.keys(dataManager.lookup.element).map((element) => this.getElement(element, level));
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration | //
public getFoodSpec(level = MVList.maxLevel) {
return this.FDM[level - 1];
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getFoodState(state: string, foodLevel = MVList.maxLevel) {
return this.getFoodSpec(foodLevel)?.[state] ?? 0;
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getBaseState(state: string, level = MVList.maxLevel) {
return this.SPEC[state].getValue(level);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getState(state: string, level = MVList.maxLevel, foodLevel = MVList.maxLevel) {
const key = JSON.stringify({ state, level, foodLevel });
if (!this.#stateCache.has(key)) {
const baseSkills = this.getSkillWithComboSkills(level);
const skills = ['QTH', 'DDG'].includes(state)
? baseSkills.filter((p) => p.effectTarget === dataManager.lookup.stateMapSkillEffectTarget[state])
: baseSkills.filter((p) => p.effectTarget === dataManager.lookup.stateMapSkillEffectTarget[state] && p.effect === EBattleEffectKind.eSTATUS_FIX);
const result = {
state,
label: dataManager.lookup.state[state],
value: this.getBaseState(state, level),
foodValue: this.getFoodState(state, foodLevel),
skillValue: skills.reduce((sum, p) => sum + p.effectValue, 0),
total: 0,
skills,
};
result.total = result.value + result.foodValue + result.skillValue;
this.#stateCache.set(key, result);
}
return this.#stateCache.get(key);
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
MethodDeclaration |
public getStates(level = MVList.maxLevel, foodLevel = MVList.maxLevel) {
return Object.keys(this.SPEC).map((state) => this.getState(state, level, foodLevel));
} | hoshiyuki-tamako/atelier_online_data_unpack | src/master/chara.ts | TypeScript |
ClassDeclaration |
export class GroupDTO {
@IsString()
@IsNotEmpty()
readonly name: string;
@IsString()
readonly description: string;
@IsArray()
readonly permissions: Array<Permission>
} | renanmoraes/base-api-nestjs | src/group/dto/group.dto.ts | TypeScript |
FunctionDeclaration |
function Modal({
imgURL,
isModalVisible,
setIsModalVisible,
roomId,
questionId,
type,
}: IModalProps) {
const history = useHistory();
async function handleDeleteQuestion() {
await database.ref(`rooms/${roomId}/questions/${questionId}`).remove().then(() => {
ShowToast({ type: 'success', message: 'Question deleted' });
});
setIsModalVisible(false);
}
async function handleEndRoom() {
await database.ref(`rooms/${roomId}`).update({
endedAt: new Date(),
}).then(() => {
ShowToast({ type: 'success', message: 'Room deleted' });
});
history.push('/');
}
return (
<div className="overlay">
<div>
<img src={imgURL} alt="Remover" />
<h1>{(type === 'delete') ? 'Remover pergunta' : 'Encerrar Sala'} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
FunctionDeclaration |
async function handleDeleteQuestion() {
await database.ref(`rooms/${roomId}/questions/${questionId}`).remove().then(() => {
ShowToast({ type: 'success', message: 'Question deleted' });
});
setIsModalVisible(false);
} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
FunctionDeclaration |
async function handleEndRoom() {
await database.ref(`rooms/${roomId}`).update({
endedAt: new Date(),
}).then(() => {
ShowToast({ type: 'success', message: 'Room deleted' });
});
history.push('/');
} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
ArrowFunction |
() => {
ShowToast({ type: 'success', message: 'Question deleted' });
} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
ArrowFunction |
() => {
ShowToast({ type: 'success', message: 'Room deleted' });
} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
ArrowFunction |
() => setIsModalVisible(false) | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
TypeAliasDeclaration |
type IModalProps = {
imgURL: string;
isModalVisible: boolean;
setIsModalVisible: (isModalVisible: boolean) => void;
roomId: string | undefined;
questionId: string | undefined;
type: string;
} | Olliveer/letmeask | src/components/Modal/index.tsx | TypeScript |
FunctionDeclaration |
export default function JSDebuggerStatement(): Token {
return concat(["debugger", ";"]);
} | Bradinz/tools | internal/formatter/builders/js/statements/JSDebuggerStatement.ts | TypeScript |
ClassDeclaration |
export default class VisitorContext {
output = {
types: {},
interfaces: {}
};
sg: sg.SchemaGenerator;
typeChecker: ts.TypeChecker;
constructor(private program: ts.Program,
public name: string,
public nssPrefix: string,
public vendor: string,
public version: string,
private schemaGeneratorConfig: sg.Config = {}) {
this.typeChecker = program.getTypeChecker();
}
getSchemaGenerator() {
if (!this.sg) {
const config: sg.Config = {
topRef: true,
expose: 'export',
jsDoc: 'extended',
extraTags: [],
...this.schemaGeneratorConfig
};
log('Creating schema generator with config', config);
const parser = sg.createParser(this.program, config);
this.sg = new sg.SchemaGenerator(this.program, parser, sg.createFormatter(config));
}
return this.sg;
}
} | aleksandrenko/vcd-ext-sdk | packages/compiler/src/VisitorContext.ts | TypeScript |
MethodDeclaration |
getSchemaGenerator() {
if (!this.sg) {
const config: sg.Config = {
topRef: true,
expose: 'export',
jsDoc: 'extended',
extraTags: [],
...this.schemaGeneratorConfig
};
log('Creating schema generator with config', config);
const parser = sg.createParser(this.program, config);
this.sg = new sg.SchemaGenerator(this.program, parser, sg.createFormatter(config));
}
return this.sg;
} | aleksandrenko/vcd-ext-sdk | packages/compiler/src/VisitorContext.ts | TypeScript |
FunctionDeclaration |
export function inc(params: Array<number> /*, hash*/) {
return params[0] + 1;
} | Gavant/ember-changeset-steps | addon/helpers/inc.ts | TypeScript |
ArrowFunction |
(draft: Draft<XkcdState>, action: XkcdActionsUnion): void => {
switch (action.type) {
case XkcdActionType.SET_ERROR:
draft.error = action.payload
break
case XkcdActionType.SET_INFO:
draft.info = action.payload
break
case XkcdActionType.SET_LOADING_STATE:
draft.loadingState = action.payload
break
}
} | vitalybaev/redux-eggs | examples/example-next-gip/eggs/xkcd/reducer.ts | TypeScript |
ArrowFunction |
props => (
<div className="web-content">
<PageTitle title | BLOCKCHAINS-FULL-STACK/sourcegraph | client/web/src/enterprise/batches/settings/BatchChangesSiteConfigSettingsArea.tsx | TypeScript |
InterfaceDeclaration |
export interface BatchChangesSiteConfigSettingsAreaProps extends Pick<RouteComponentProps, 'history' | 'location'> {
queryGlobalBatchChangesCodeHosts?: typeof queryGlobalBatchChangesCodeHosts
} | BLOCKCHAINS-FULL-STACK/sourcegraph | client/web/src/enterprise/batches/settings/BatchChangesSiteConfigSettingsArea.tsx | TypeScript |
ArrowFunction |
() => {
let component: JobboardsComponent;
let fixture: ComponentFixture<JobboardsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ JobboardsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JobboardsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
} | Onaopemipo/hrhead | src/app/modules/applicants/jobboards/jobboards.component.spec.ts | TypeScript |
ArrowFunction |
() => {
TestBed.configureTestingModule({
declarations: [ JobboardsComponent ]
})
.compileComponents();
} | Onaopemipo/hrhead | src/app/modules/applicants/jobboards/jobboards.component.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(JobboardsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
} | Onaopemipo/hrhead | src/app/modules/applicants/jobboards/jobboards.component.spec.ts | TypeScript |
FunctionDeclaration |
function splitBoxes(pq: PQueue<VBox>, target: number): void {
let lastSize = pq.size;
while (pq.size < target) {
const vbox = pq.pop();
if (!vbox || vbox.count < 1) {
break;
}
const [vbox1, vbox2] = vbox.split();
pq.push(vbox1);
if (vbox2 && vbox2.count > 0) pq.push(vbox2);
// No more new boxes, converged
if (pq.size === lastSize) {
break;
} else {
lastSize = pq.size;
}
}
} | LiveChart/-livechart-sharp-vibrant | src/quantizer/mmcq.ts | TypeScript |
FunctionDeclaration |
function generateSwatches(pq: PQueue<VBox>) {
const swatches: Swatch[] = [];
while (pq.size) {
const v = pq.pop();
const color = v.avg;
swatches.push(new Swatch(color, v.count));
}
return swatches;
} | LiveChart/-livechart-sharp-vibrant | src/quantizer/mmcq.ts | TypeScript |
ArrowFunction |
(pixels: Pixels, opts: ComputedOptions): Array<Swatch> => {
if (pixels.length === 0 || opts.colorCount < 2 || opts.colorCount > 256) {
throw new Error('Wrong MMCQ parameters');
}
const vbox = VBox.build(pixels);
const pq = new PQueue<VBox>((a, b) => a.count - b.count);
pq.push(vbox);
// first set of colors, sorted by population
splitBoxes(pq, fractByPopulations * opts.colorCount);
// Re-order
const pq2 = new PQueue<VBox>((a, b) => a.count * a.volume - b.count * b.volume);
pq2.contents = pq.contents;
// next set - generate the median cuts using the (npix * vol) sorting.
splitBoxes(pq2, opts.colorCount - pq2.size);
// calculate the actual colors
return generateSwatches(pq2);
} | LiveChart/-livechart-sharp-vibrant | src/quantizer/mmcq.ts | TypeScript |
ArrowFunction |
(a, b) => a.count - b.count | LiveChart/-livechart-sharp-vibrant | src/quantizer/mmcq.ts | TypeScript |
ArrowFunction |
(a, b) => a.count * a.volume - b.count * b.volume | LiveChart/-livechart-sharp-vibrant | src/quantizer/mmcq.ts | TypeScript |
ArrowFunction |
(name?: string): CharacterSkill => ({
name: name || '',
info: '',
rotations: '',
tips: '',
}) | RaenonX-DL/dragalia-posts-site-front | src/utils/services/api/utils.ts | TypeScript |
ArrowFunction |
(): PositionalInfo => ({
position: '',
builds: '',
rotations: '',
tips: '',
}) | RaenonX-DL/dragalia-posts-site-front | src/utils/services/api/utils.ts | TypeScript |
ArrowFunction |
(endpoint: string): string => {
return urlJoin(API_ROOT, endpoint);
} | RaenonX-DL/dragalia-posts-site-front | src/utils/services/api/utils.ts | TypeScript |
MethodDeclaration |
beforeEach() {
emitter = new Evented();
source = new EventedStreamSource(emitter, 'testEvent');
stream = new ReadableStream<Event>(source);
reader = stream.getReader();
return stream.started;
} | maier49/streams | tests/unit/adapters/EventedStreamSource.ts | TypeScript |
MethodDeclaration |
start() {
emitter.emit(testEvent);
return reader.read().then(function (result: ReadResult<Event>) {
assert.strictEqual(result.value, testEvent as any,
'Event read from stream should be the same as the event emitted by emitter');
});
} | maier49/streams | tests/unit/adapters/EventedStreamSource.ts | TypeScript |
MethodDeclaration |
'event array'() {
let appleEvent = {
type: 'apple',
test: 'value'
};
let orangeEvent = {
type: 'orange',
test: 'value'
};
source = new EventedStreamSource(emitter, [ 'apple', 'orange' ]);
stream = new ReadableStream<Event>(source);
reader = stream.getReader();
emitter.emit(appleEvent);
emitter.emit(orangeEvent);
return reader.read().then(function (result: ReadResult<Event>) {
assert.strictEqual(result.value, appleEvent as any);
return reader.read().then(function (result: ReadResult<Event>) {
assert.strictEqual(result.value, orangeEvent as any);
});
});
} | maier49/streams | tests/unit/adapters/EventedStreamSource.ts | TypeScript |
MethodDeclaration |
cancel() {
let enqueueCallCount = 0;
stream.controller.enqueue = function (chunk: Event) {
enqueueCallCount += 1;
};
source.cancel();
emitter.emit(testEvent);
assert.strictEqual(enqueueCallCount, 0, 'Canceled source should not call controller.enqueue');
} | maier49/streams | tests/unit/adapters/EventedStreamSource.ts | TypeScript |
ArrowFunction |
(props: Props) => {
const {
section,
search,
count,
onlyOnSale,
isMap,
wearableRarities,
wearableGenders,
contracts,
onBrowse
} = props
const [showFiltersMenu, setShowFiltersMenu] = useState(false)
const [showFiltersModal, setShowFiltersModal] = useState(false)
const category = section ? getSearchCategory(section) : undefined
const dropdownOptions = [
{ value: SortBy.NEWEST, text: t('filters.newest') },
{ value: SortBy.NAME, text: t('filters.name') }
]
if (onlyOnSale) {
dropdownOptions.unshift({
value: SortBy.RECENTLY_LISTED,
text: t('filters.recently_listed')
})
dropdownOptions.unshift({
value: SortBy.CHEAPEST,
text: t('filters.cheapest')
})
}
const sortBy = dropdownOptions.find(option => option.value === props.sortBy)
? props.sortBy
: dropdownOptions[0].value
const appliedFilters = []
if (wearableRarities.length > 0) {
appliedFilters.push(t('nft_filters.rarity'))
}
// if (wearableGenders.length > 0) {
// appliedFilters.push(t('nft_filters.gender'))
// }
// if (contracts.length > 0) {
// appliedFilters.push(t('nft_filters.collection'))
// }
const handleOnlyOnSaleChange = useCallback(
(_, props: CheckboxProps) => {
onBrowse({ sortBy: SortBy.NEWEST, onlyOnSale: !!props.checked })
},
[onBrowse]
)
const handleIsMapChange = useCallback(
(isMap: boolean) => {
onBrowse({ isMap, isFullscreen: false, search: '' })
},
[onBrowse]
)
const handleDropdownChange = useCallback(
(_, props: DropdownProps) => {
onBrowse({ sortBy: props.value as SortBy })
},
[onBrowse]
)
const handleRaritiesChange = useCallback(
(options: string[]) => {
const newOptions = options.map((option) => t(`wearable.rarity.${option}`).toLowerCase())
onBrowse({ wearableRarities: newOptions as WearableRarity[] })
},
[onBrowse]
)
const handleGendersChange = useCallback(
(options: string[]) => {
onBrowse({ wearableGenders: options as WearableGender[] })
},
[onBrowse]
)
const handleCollectionsChange = useCallback(
(contract: string) => {
onBrowse({ contracts: [contract as ContractName] })
},
[onBrowse]
)
const handleSearch = useCallback(
(newSearch: string) => {
if (search !== newSearch) {
onBrowse({ search: newSearch, isMap: false, isFullscreen: false })
}
},
[search, onBrowse]
)
// const handleToggleFilterMenu = useCallback(
// () => setShowFiltersMenu(!showFiltersMenu),
// [showFiltersMenu, setShowFiltersMenu]
// )
useEffect(() => setShowFiltersMenu(false), [category, setShowFiltersMenu])
const searchPlaceholder = isMap
? t('nft_filters.search_land')
: count === undefined
? t('global.loading') + '...'
: t('nft_filters.search', {
suffix:
count < MAX_QUERY_SIZE
? t('nft_filters.results', {
count: count.toLocaleString()
})
: t('nft_filters.more_than_results', {
count: count.toLocaleString()
})
})
return (
<div className="NFTFilters">
<div className="topbar">
{isMap ? (
<>
<TextFilter
value={search}
placeholder={searchPlaceholder}
onChange={handleSearch}
/>
<Responsive
minWidth={Responsive.onlyTablet.minWidth}
className="topbar-filter"
>
<Radio
toggle
checked={onlyOnSale}
onChange={handleOnlyOnSaleChange}
label={t('nft_filters.on_sale')}
/>
</Responsive>
</> | blockfishio/spacey-marketplace | webapp/src/components/Vendor/decentraland/NFTFilters/NFTFilters.tsx | TypeScript |
ArrowFunction |
option => option.value === props.sortBy | blockfishio/spacey-marketplace | webapp/src/components/Vendor/decentraland/NFTFilters/NFTFilters.tsx | TypeScript |
ArrowFunction |
(_, props: CheckboxProps) => {
onBrowse({ sortBy: SortBy.NEWEST, onlyOnSale: !!props.checked })
} | blockfishio/spacey-marketplace | webapp/src/components/Vendor/decentraland/NFTFilters/NFTFilters.tsx | TypeScript |
ArrowFunction |
(isMap: boolean) => {
onBrowse({ isMap, isFullscreen: false, search: '' })
} | blockfishio/spacey-marketplace | webapp/src/components/Vendor/decentraland/NFTFilters/NFTFilters.tsx | TypeScript |
ArrowFunction |
(_, props: DropdownProps) => {
onBrowse({ sortBy: props.value as SortBy })
} | blockfishio/spacey-marketplace | webapp/src/components/Vendor/decentraland/NFTFilters/NFTFilters.tsx | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.