Skip to content

Instantly share code, notes, and snippets.

View jmaicaaan's full-sized avatar

JM Santos jmaicaaan

  • Philippines
View GitHub Profile
export type Camelize<GenericObject> = {
[ObjectProperty in keyof GenericObject as CamelizeString<ObjectProperty & string>]:
GenericObject[ObjectProperty] extends Array<infer ArrayItem>
? ArrayItem extends Record<string, unknown>
? Array<Camelize<ArrayItem>>
: GenericObject[ObjectProperty]
: GenericObject[ObjectProperty] extends Record<string, unknown>
? Camelize<GenericObject[ObjectProperty]>
: GenericObject[ObjectProperty];
};
export type CamelizeString<ObjectProperty extends string> =
ObjectProperty extends `${infer F}_${infer R}`
? `${F}${Capitalize<CamelizeString<R>>}`
: ObjectProperty;
export type CamelizeString<ObjectProperty extends string> =
ObjectProperty extends `${infer F}_${infer R}`
? `${F}${Capitalize<CamelizeString<R>>}`
: ObjectProperty;
export type Camelize<GenericObject> = {
[ObjectProperty in keyof GenericObject as CamelizeString<ObjectProperty & string>]:
GenericObject[ObjectProperty] extends Array<infer ArrayItem>
? ArrayItem extends Record<string, unknown>
? Array<Camelize<ArrayItem>>
@jmaicaaan
jmaicaaan / style.css
Created February 28, 2022 15:04
Base CSS for Image Gallery Tutorial
.image-gallery {
display: grid;
grid-gap: 5px;
}
.image-gallery img {
height: 250px;
width: 250px;
}
describe('fb social login', () => {
it('should be able to login with fb', () => {
cy.visit('http://localhost:3000');
return cy.loginByFacebook().then(() => {
cy.get('[data-testid="fb-login-button"]')
.should('be.enabled')
.click();
cy.location('pathname').should('eq', '/home');
});
Cypress.Commands.add('loginByFacebook', (
status: 'connected' | 'not_authorized' | 'unknown' = 'connected'
) => {
return cy.window().then((win) => {
const callbackResult = {
...status === 'connected' && {
status: 'connected',
authResponse: {
accessToken: 'test_fbAccessToken',
},
const person01 = {
name: 'JM'
};
/**
* Clone/copy all the values in `person01`
*/
const person02 = { ...person01 };
/**
let person01 = 'JM';
let person02 = person01;
person02 = 'JM Santos';
console.log('person01', person01); // JM
console.log('person02', person02); // JM Santos
const person01 = {
name: 'JM'
};
const person02 = person01;
/**
* Mutating `person02` will cause effect also on `person01` because
* `person01` was assigned by reference not by value
*/
let y = 3;
/**
* The `sum` function is accessing the global variable `y` to compute for the sum
*/
const sum = (x) => x + y;
/**
* Here we are mutating the state of the variable `y` to `6`
* which means that the computation of `sum` will now be different