type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
(first, second) => {
return first.name.toLocaleLowerCase().localeCompare(second.name.toLocaleLowerCase());
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface User extends CommonEntities.PrivilegesArray {
id: string;
name: string;
info: string;
title: string;
signature: string;
hasLogo: boolean;
created: number;
lastSeen: number;
threadCount: number;
messageCount: number;
subscribedThreadCount: number;
receivedUpVotes: number;
receivedDownVotes: number;
attachmentCount: number;
attachmentTotalSize: number;
attachmentQuota: number;
privileges: string[];
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface CurrentUser {
authenticated: number;
user: User;
newReceivedVotesNr: number;
newReceivedQuotesNr: number;
newReceivedPrivateMessagesNr: number;
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface Vote {
at: number;
score: number;
message: ThreadMessageRepository.ThreadMessage;
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface VoteHistory {
lastRetrievedAt: number;
receivedVotes: Vote[];
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface QuoteHistory {
messages: ThreadMessageRepository.ThreadMessage[];
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface UserCollection extends CommonEntities.PaginationInfo {
users: User[];
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
interface SingleUser {
user: User;
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
interface OnlineUserCollection {
online_users: User[];
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
export interface GetUsersRequest {
page: number;
orderBy: string;
sort: string;
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
InterfaceDeclaration |
interface UserSearchResult {
index: number;
pageSize: number;
} | danij/Forum.WebClient | src/services/userRepository.ts | TypeScript |
ArrowFunction |
() => _.invoke(this, 'props.onConfirm', null, this.props) | biterest/biterest-key-collector | app/components/Confirm/ConfirmSuccess/ConfirmSuccess.tsx | TypeScript |
ClassDeclaration |
export class ConfirmSuccess extends Component<IConfirmSuccessProps> {
handleDismiss = () => _.invoke(this, 'props.onConfirm', null, this.props)
render() {
const { transaction: { hash } } = this.props
const link = (
<ExternalLink key='blockchain' href={`https://blockchain.info/tx/${hash}`} | biterest/biterest-key-collector | app/components/Confirm/ConfirmSuccess/ConfirmSuccess.tsx | TypeScript |
MethodDeclaration |
render() {
const { transaction: { hash } } = this.props
const link = (
<ExternalLink key='blockchain' href={`https://blockchain.info/tx/${hash}`} | biterest/biterest-key-collector | app/components/Confirm/ConfirmSuccess/ConfirmSuccess.tsx | TypeScript |
ArrowFunction |
subs => subs.forEach(s => s.unsubscribe()) | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
group => group.destroy() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(field: FormFieldInstance) => field.isDirty | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(nestedGroup: FormGroup) => nestedGroup.isDirty() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
nestedGroup => nestedGroup.setFormListener(this._formListener as Subject<FieldChange>) | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
({ fieldName }: FieldChange) => Boolean(this._fields[fieldName]) | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
fieldChange => this.handleFieldChange(fieldChange) | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
nestedGroup => [
nestedGroup._groupChanged.subscribe(() => this._groupChanged.next()),
nestedGroup._fieldsChanged.subscribe(() => this._fieldsChanged.next()),
// If a nested group's validity changes, check ourselves
nestedGroup._groupValidityChanged.subscribe(() => this.checkValidity())
] | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
() => this._groupChanged.next() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
() => this._fieldsChanged.next() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
() => this.checkValidity() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
g => g.onReset() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
() => this.handleChildrenReset() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
nestedGroup => nestedGroup.reset() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(acc: FieldMap, nestedGroup) => {
acc = { ...acc, ...nestedGroup.getValues() };
return acc;
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(acc: FieldMap, key) => {
acc[key] = this._fields[key];
return acc;
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
field => {
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || field.value !== '') {
formattedGroup[field.name] = field.value;
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(childGroup: FormGroup) => {
const grandchildrenFormatted = this.keyValueMap(childGroup, includeEmpty);
// remove empty containers/lists
if (includeEmpty === PropertyFilterLevel.EXCLUDE_EMPTY) {
Object.keys(grandchildrenFormatted).forEach(propertyKey => {
if (JSON.stringify(grandchildrenFormatted[propertyKey]) === '{}') {
delete grandchildrenFormatted[propertyKey];
}
});
}
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || Object.keys(grandchildrenFormatted).length > 0) {
formattedGroup[childGroup.name] = grandchildrenFormatted;
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
propertyKey => {
if (JSON.stringify(grandchildrenFormatted[propertyKey]) === '{}') {
delete grandchildrenFormatted[propertyKey];
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(acc: FieldMap, key) => {
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || this._fields[key].value !== '') {
acc[key] = this._fields[key].value;
}
return acc;
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(group: FormGroup) => {
const groupValuesFormatted = this.keyValueMap(group, includeEmpty);
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || Object.keys(groupValuesFormatted).length > 0) {
groupValues[group.name] = groupValuesFormatted;
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
(field: FormFieldInstance) => field.isValid | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ArrowFunction |
nestedGroup => nestedGroup.validate() | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
EnumDeclaration |
export enum PropertyFilterLevel {
EXCLUDE_EMPTY = 0,
INCLUDE_EMPTY = 1
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
TypeAliasDeclaration |
export type GroupValidator = (fields: FieldMap) => [boolean, string?]; | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
isValid(): Promise<boolean> {
return this._groupValidityChanged.pipe(take(1)).toPromise();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
async setFields(fields: FormField[]): Promise<void> {
super.setFields(fields);
this.checkValidity();
// Send as this is the init of the form
const isValid = await this.isValid();
this._groupValidityChanged.next(isValid);
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
destroy(): void {
if (this.formSubscription) {
this.formSubscription.unsubscribe();
}
this.nestedGroupSubscriptions.forEach(subs => subs.forEach(s => s.unsubscribe()));
this.nestedGroups.forEach(group => group.destroy());
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
isDirty(): boolean {
const thisGroupIsDirty = Object.values(this._fields).some((field: FormFieldInstance) => field.isDirty);
// If this group is dirty don't bother checking nested groups
if (thisGroupIsDirty) {
return true;
}
const areNestedGroupsDirty = this.nestedGroups.some((nestedGroup: FormGroup) => nestedGroup.isDirty());
return areNestedGroupsDirty;
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
setGroupValidator(validator: GroupValidator): void {
this.groupValidator = validator;
this.checkValidity();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
private handleFieldsChange(): void {
this._fieldsChanged.next();
this.checkValidity();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
addFields(fields: FormField[]): void {
super.addFields(fields);
this.handleFieldsChange();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
removeFields(fields: FormField[]): void {
super.removeFields(fields);
this.handleFieldsChange();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
setFormListener(formListener: Subject<FieldChange>): void {
this._formListener = formListener;
if (this.nestedGroups.length) {
this.nestedGroups.forEach(nestedGroup => nestedGroup.setFormListener(this._formListener as Subject<FieldChange>));
}
this.initializeFormListerner();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
private initializeFormListerner(): void {
// If we already have a subscription, unsubscribe before we resubscribe
if (this.formSubscription) {
this.formSubscription.unsubscribe();
}
if (this._formListener) {
this.formSubscription = this._formListener
// If changed field belongs to this group handle change
.pipe(filter(({ fieldName }: FieldChange) => Boolean(this._fields[fieldName])))
.subscribe(fieldChange => this.handleFieldChange(fieldChange));
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
handleFieldChange(fieldChange: FieldChange): void {
super.handleFieldChange(fieldChange);
this._groupChanged.next(fieldChange);
this.checkValidity();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
setNestedGroups(groups: FormGroup | FormGroup[]): void {
const nestedGroups = Array.isArray(groups) ? groups : [groups];
this.nestedGroups = nestedGroups;
// Initialize the form listener for nested groups if it is already defined
if (this._formListener) {
nestedGroups.forEach(nestedGroup => nestedGroup.setFormListener(this._formListener as Subject<FieldChange>));
}
// We want any nested group events to bubble up to the top level form
this.nestedGroupSubscriptions = nestedGroups.map(nestedGroup => [
nestedGroup._groupChanged.subscribe(() => this._groupChanged.next()),
nestedGroup._fieldsChanged.subscribe(() => this._fieldsChanged.next()),
// If a nested group's validity changes, check ourselves
nestedGroup._groupValidityChanged.subscribe(() => this.checkValidity())
]);
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
reset(): void {
super.reset();
if (this.nestedGroups.length) {
this.childrenResetSubscription = zip(...this.nestedGroups.map(g => g.onReset())).subscribe({
next: () => this.handleChildrenReset()
});
this.nestedGroups.map(nestedGroup => nestedGroup.reset());
} else {
this.checkValidity(true);
this._onReset.next();
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
handleChildrenReset(): void {
this.checkValidity(true);
this._onReset.next();
if (this.childrenResetSubscription) {
this.childrenResetSubscription.unsubscribe();
this.childrenResetSubscription = null;
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
onReset(): Observable<void> {
return this._onReset.asObservable();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
getValues(): FieldMap {
const nestedGroupValues = this.nestedGroups.reduce((acc: FieldMap, nestedGroup) => {
acc = { ...acc, ...nestedGroup.getValues() };
return acc;
}, {});
const values = Object.keys(this._fields).reduce((acc: FieldMap, key) => {
acc[key] = this._fields[key];
return acc;
}, {});
return { ...values, ...nestedGroupValues };
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
private keyValueMap(group: FormGroup, includeEmpty: PropertyFilterLevel): FieldMap {
const formattedGroup: {[key: string]: any} = {};
group.getFields().forEach(field => {
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || field.value !== '') {
formattedGroup[field.name] = field.value;
}
});
group.nestedGroups.forEach((childGroup: FormGroup) => {
const grandchildrenFormatted = this.keyValueMap(childGroup, includeEmpty);
// remove empty containers/lists
if (includeEmpty === PropertyFilterLevel.EXCLUDE_EMPTY) {
Object.keys(grandchildrenFormatted).forEach(propertyKey => {
if (JSON.stringify(grandchildrenFormatted[propertyKey]) === '{}') {
delete grandchildrenFormatted[propertyKey];
}
});
}
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || Object.keys(grandchildrenFormatted).length > 0) {
formattedGroup[childGroup.name] = grandchildrenFormatted;
}
});
return formattedGroup;
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
getGroupValues(includeEmpty: PropertyFilterLevel = PropertyFilterLevel.INCLUDE_EMPTY): FieldMap {
const fieldValues = Object.keys(this._fields).reduce((acc: FieldMap, key) => {
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || this._fields[key].value !== '') {
acc[key] = this._fields[key].value;
}
return acc;
}, {});
const groupValues: {[key: string]: any} = {};
this.nestedGroups.forEach((group: FormGroup) => {
const groupValuesFormatted = this.keyValueMap(group, includeEmpty);
if (includeEmpty === PropertyFilterLevel.INCLUDE_EMPTY || Object.keys(groupValuesFormatted).length > 0) {
groupValues[group.name] = groupValuesFormatted;
}
});
if (Object.keys(groupValues).length > 0) {
return {...fieldValues, ...groupValues};
}
return {...fieldValues};
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
validateSelf(): boolean {
if (this.groupValidator) {
return Boolean(this.groupValidator(this._fields));
}
// validate all fields are valid
return Object.values(this._fields).every((field: FormFieldInstance) => field.isValid);
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
determineFieldErrors(): void {
super.determineFieldErrors(this.validate());
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration |
private checkValidity(reset = false): void {
const { _valid } = this;
const newValidity = this.validate();
// set and emit the value of the validaity if it changes or we are resetting
if ((_valid !== newValidity) || reset) {
this._valid = newValidity;
this._groupValidityChanged.next(newValidity);
}
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
MethodDeclaration | // Tries to validate children if there are any. If there are no children or the children are valid, then
// will try to validate itself
validate(): boolean {
if (this.nestedGroups.length) {
const areChildrenValid = this.nestedGroups.every(nestedGroup => nestedGroup.validate());
if (!areChildrenValid) {
return false;
}
return this.validateSelf();
}
return this.validateSelf();
} | CiscoDevNet/msx-ui-forms | src/form-builder/form-group.ts | TypeScript |
ClassDeclaration |
@NgModule({
imports: [CommonModule, ErrorCollectModule],
declarations: [...COMPONENTS],
exports: [...COMPONENTS],
})
export class FooterToolbarModule {
static forRoot(): ModuleWithProviders {
return { ngModule: FooterToolbarModule, providers: [] };
}
} | ilvsx/delon | packages/abc/footer-toolbar/footer-toolbar.module.ts | TypeScript |
MethodDeclaration |
static forRoot(): ModuleWithProviders {
return { ngModule: FooterToolbarModule, providers: [] };
} | ilvsx/delon | packages/abc/footer-toolbar/footer-toolbar.module.ts | TypeScript |
FunctionDeclaration |
export default function ConnectedContent() {
return (
<Switch>
<Route path="/view/:tokenId">
<ViewToken />
</Route>
<Route path="/reconfigurator/:tokenId1/:tokenId2">
<Reconfigurator />
</Route>
<Route path="/reconfigurator/:tokenId1">
<Reconfigurator />
</Route>
<Route path="/collection/:address">
<Collection />
</Route>
<Route path="/collection">
<Collection />
</Route>
<Route path="/">
<Collection />
</Route>
</Switch>
);
} | rlee1121/blockheads-shelf | src/ConnectedContent.tsx | TypeScript |
ClassDeclaration |
@NgModule({
imports: [
FormsModule,
ProvidersRoutingModule,
ChartsModule,
BsDropdownModule,
CommonModule,
ButtonsModule.forRoot(),
ModalModule.forRoot()
],
declarations: [
ProvidersComponent
],
exports: [
],
})
export class ProvidersModule { } | parth8778/Handyman_Admin | src/app/views/providers/providers.module.ts | TypeScript |
ArrowFunction |
async () => {
//All User Ref
const UserRef = database.collection('Database').doc('Users');
const UserData: ListUser = (await UserRef.get()).data() as ListUser;
if (UserData['UID'] !== undefined) {
const UID: string = auth.currentUser?.uid as string;
//User Contacts Ref
const ContactsRef = database
.collection('Database')
.doc('Users')
.collection(UID)
.doc('Contacts')
.collection('Friends');
const ContactsData = await ContactsRef.get({
source: 'server',
});
ContactsData.docs.map(async (doc) => {
const Data: FriendInformations = doc.data() as FriendInformations;
if (Data['UID']) {
const UserID: string = Data['UID'];
if (Object.values(UserData['UID']).indexOf(UserID) == -1) {
await ContactsRef.doc(doc.id).delete();
}
}
});
}
} | krsbx/-Typescript-Loveless-Chat | Utility/ContactsCleaner.ts | TypeScript |
ArrowFunction |
async (doc) => {
const Data: FriendInformations = doc.data() as FriendInformations;
if (Data['UID']) {
const UserID: string = Data['UID'];
if (Object.values(UserData['UID']).indexOf(UserID) == -1) {
await ContactsRef.doc(doc.id).delete();
}
}
} | krsbx/-Typescript-Loveless-Chat | Utility/ContactsCleaner.ts | TypeScript |
ClassDeclaration |
class App extends ComponentBase
{
public render(): JSX.Element
{
return (
<div>
<Hello compiler="TypeScript" framework="React" />
<TodoManager />
</div>
);
}
} | nivinjoseph/ts-react-poc | src/app.tsx | TypeScript |
MethodDeclaration |
public render(): JSX.Element
{
return (
<div>
<Hello compiler="TypeScript" framework="React" />
<TodoManager />
</div>
);
} | nivinjoseph/ts-react-poc | src/app.tsx | TypeScript |
ArrowFunction |
() => {
it('correctly generates a string representation', () => {
const cache: LruCache<number, string> = new LruCache(Number.MAX_SAFE_INTEGER);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
expect(cache.toString()).toEqual('[[1, a], [2, b], [3, c]]');
});
it('correctly stores a single value', () => {
const cache: LruCache<number, string> = new LruCache(Number.MAX_SAFE_INTEGER);
cache.set(1, 'hi');
expect(cache.get(1)).toEqual('hi');
});
it('correctly eliminates tail value when over capacity', () => {
const cache: LruCache<number, string> = new LruCache(3);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
cache.set(4, 'd');
expect(cache.get(1)).toBeUndefined();
});
it('moves entry to most recently used position when accessed', () => {
const cache: LruCache<number, string> = new LruCache(3);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
cache.get(1);
cache.set(4, 'd');
expect(cache.toString()).toEqual('[[3, c], [1, a], [4, d]]');
});
} | andrewkolos/simple-online-game-syncrhonization-framework | test/util/lru-cache.test.ts | TypeScript |
ArrowFunction |
() => {
const cache: LruCache<number, string> = new LruCache(Number.MAX_SAFE_INTEGER);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
expect(cache.toString()).toEqual('[[1, a], [2, b], [3, c]]');
} | andrewkolos/simple-online-game-syncrhonization-framework | test/util/lru-cache.test.ts | TypeScript |
ArrowFunction |
() => {
const cache: LruCache<number, string> = new LruCache(Number.MAX_SAFE_INTEGER);
cache.set(1, 'hi');
expect(cache.get(1)).toEqual('hi');
} | andrewkolos/simple-online-game-syncrhonization-framework | test/util/lru-cache.test.ts | TypeScript |
ArrowFunction |
() => {
const cache: LruCache<number, string> = new LruCache(3);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
cache.set(4, 'd');
expect(cache.get(1)).toBeUndefined();
} | andrewkolos/simple-online-game-syncrhonization-framework | test/util/lru-cache.test.ts | TypeScript |
ArrowFunction |
() => {
const cache: LruCache<number, string> = new LruCache(3);
cache.set(1, 'a');
cache.set(2, 'b');
cache.set(3, 'c');
cache.get(1);
cache.set(4, 'd');
expect(cache.toString()).toEqual('[[3, c], [1, a], [4, d]]');
} | andrewkolos/simple-online-game-syncrhonization-framework | test/util/lru-cache.test.ts | TypeScript |
MethodDeclaration |
CHANGE_DRAWER_STATE(state, value) {
state.drawer = value;
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
MethodDeclaration |
SET_CSRF_TOKEN(state, token: string) {
state.csrfToken = token;
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
MethodDeclaration |
SET_USER(state, userObj: UserType) {
state.user = userObj;
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
MethodDeclaration |
changeDrawerState({ commit }, value) {
commit('CHANGE_DRAWER_STATE', value);
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
MethodDeclaration |
setUser({ commit }, user) {
commit('SET_USER', user);
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
MethodDeclaration |
noUser(state) {
return state.user === null;
} | FlickerSoul/Graphery | graphery/src/store/index.ts | TypeScript |
ArrowFunction |
async (context: Context, { customQuery, state }) => {
const { data, errors } = await context.$odoo.api.shippingGetDeliveryMethods(customQuery);
state.value = data.deliveryMethods;
throwErrors(errors);
return data.deliveryMethods;
} | vuestorefront-community/odoo | packages/composables/src/composables/useShippingProvider/index.ts | TypeScript |
ArrowFunction |
async (context: Context, { shippingMethod, customQuery, state }) => {
const { data, errors } = await context.$odoo.api.setShippingMethod({ shippingMethodId: shippingMethod.id}, customQuery);
context.useCart.cart.value.order.shippingMethod = data.setShippingMethod?.order?.shippingMethod;
throwErrors(errors);
return [data.setShippingMethod?.order?.shippingMethod];
} | vuestorefront-community/odoo | packages/composables/src/composables/useShippingProvider/index.ts | TypeScript |
InterfaceDeclaration |
interface ShippingProviderState {
response: ShippingInfo;
} | vuestorefront-community/odoo | packages/composables/src/composables/useShippingProvider/index.ts | TypeScript |
MethodDeclaration |
provide() {
return {
useCart: useCart()
};
} | vuestorefront-community/odoo | packages/composables/src/composables/useShippingProvider/index.ts | TypeScript |
ArrowFunction |
p => p.id === this.destNode.context.pipeline_id | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
n => n.name === this.destNode.name && n.ref !== this.destNode.ref | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
results => {
let app = results[0];
let pip = results[1];
let env = results[2];
let projIn = results[3];
if (app) {
clonedWorkflow.applications[app.id] = app;
}
if (pip) {
clonedWorkflow.pipelines[pip.id] = pip;
}
if (env) {
clonedWorkflow.environments[env.id] = env;
}
if (projIn) {
clonedWorkflow.project_integrations[projIn.id] = projIn;
}
this.triggerEvent.emit(clonedWorkflow);
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
(section) => {
if (section === 'done') {
this.saveTrigger();
} else {
this.currentSection = section;
}
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
a => a.id === this.destNode.context.application_id | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
e => e.id === this.destNode.context.environment_id | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
ArrowFunction |
i => i.id === this.destNode.context.project_integration_id | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
show(t: string, isP: boolean): void {
this.selectedType = t;
this.isParent = isP;
const config = new TemplateModalConfig<boolean, boolean, void>(this.triggerModal);
config.mustScroll = true;
this.modal = this._modalService.open(config);
this._cd.detectChanges();
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
hide(): void {
this.modal.approve(true);
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
destNodeChange(node: WNode): void {
this.destNode = node;
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
pipelineSectionChanged(pipSection: string) {
this.currentSection = pipSection;
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
addOutgoingHook(): void {
this.destNode = this.worklflowAddOutgoingHook.outgoingHook;
this.saveTrigger();
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
saveTrigger(): void {
this.destNode.context.conditions = new WorkflowNodeConditions();
this.destNode.context.conditions.plain = new Array<WorkflowNodeCondition>();
let c = new WorkflowNodeCondition();
c.variable = 'cds.status';
c.value = PipelineStatus.SUCCESS;
c.operator = 'eq';
let editMode = this._store.selectSnapshot(WorkflowState).editMode;
this.destNode.context.conditions.plain.push(c);
if (editMode) {
let allNodes = Workflow.getAllNodes(this.workflow);
this.destNode.ref = new Date().getTime().toString();
if (this.destNode.type === WNodeType.PIPELINE) {
this.destNode.name =
this.project.pipeline_names.find(p => p.id === this.destNode.context.pipeline_id)
.name;
}
let nodeBaseName = this.destNode.name;
let hasNodeToRename = true;
let nameIndex = 1;
do {
if (allNodes.findIndex(
n => n.name === this.destNode.name && n.ref !== this.destNode.ref) === -1) {
hasNodeToRename = false;
} else {
this.destNode.name = nodeBaseName + '_' + nameIndex;
nameIndex++;
}
} while (hasNodeToRename);
}
let clonedWorkflow = cloneDeep(this.workflow);
if (this.source && !this.isParent) {
let sourceNode: WNode;
if (!editMode) {
sourceNode = Workflow.getNodeByID(this.source.id, clonedWorkflow);
} else {
sourceNode = Workflow.getNodeByRef(this.source.ref, clonedWorkflow);
}
if (!sourceNode.triggers) {
sourceNode.triggers = new Array<WNodeTrigger>();
}
let newTrigger = new WNodeTrigger();
newTrigger.parent_node_name = sourceNode.ref;
newTrigger.child_node = this.destNode;
sourceNode.triggers.push(newTrigger);
} else if (this.isParent) {
this.destNode.triggers = new Array<WNodeTrigger>();
let newTrigger = new WNodeTrigger();
newTrigger.child_node = clonedWorkflow.workflow_data.node;
this.destNode.triggers.push(newTrigger);
this.destNode.context.default_payload = newTrigger.child_node.context.default_payload;
newTrigger.child_node.context.default_payload = null;
this.destNode.hooks = cloneDeep(clonedWorkflow.workflow_data.node.hooks);
clonedWorkflow.workflow_data.node.hooks = [];
clonedWorkflow.workflow_data.node = this.destNode;
} else {
return;
}
if (editMode) {
forkJoin([
this.getApplication(clonedWorkflow),
this.getPipeline(clonedWorkflow),
this.getEnvironment(clonedWorkflow),
this.getProjectIntegration(clonedWorkflow)
]).subscribe(results => {
let app = results[0];
let pip = results[1];
let env = results[2];
let projIn = results[3];
if (app) {
clonedWorkflow.applications[app.id] = app;
}
if (pip) {
clonedWorkflow.pipelines[pip.id] = pip;
}
if (env) {
clonedWorkflow.environments[env.id] = env;
}
if (projIn) {
clonedWorkflow.project_integrations[projIn.id] = projIn;
}
this.triggerEvent.emit(clonedWorkflow);
});
} else {
this.triggerEvent.emit(clonedWorkflow);
}
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
nextStep() {
this.nodeWizard.goToNextSection().subscribe((section) => {
if (section === 'done') {
this.saveTrigger();
} else {
this.currentSection = section;
}
});
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
getApplication(w: Workflow): Observable<Application> {
if (this.destNode.context.application_id) {
if (w.applications && w.applications[this.destNode.context.application_id]) {
return of(w.applications[this.destNode.context.application_id]);
}
return this._appService
.getApplication(this.project.key, this.project.application_names
.find(a => a.id === this.destNode.context.application_id).name);
}
return of(null);
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |
MethodDeclaration |
getPipeline(w: Workflow): Observable<Pipeline> {
if (this.destNode.context.pipeline_id) {
if (w.pipelines && w.pipelines[this.destNode.context.pipeline_id]) {
return of(w.pipelines[this.destNode.context.pipeline_id]);
}
return this._pipService.getPipeline(this.project.key, this.project.pipeline_names
.find(p => p.id === this.destNode.context.pipeline_id).name);
}
return of(null);
} | Kerguillec/cds | ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts | TypeScript |