View getChangesOnList.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getChangesOnList } from './getChangesOnList'; | |
describe('getChangesOnList', () => { | |
type TestItem = { id: number; value: string }; | |
const testItemA: TestItem = { id: 1, value: 'A' }; | |
const testItemB: TestItem = { id: 2, value: 'B' }; | |
const testItemC: TestItem = { id: 3, value: 'C' }; | |
const testItems: TestItem[] = [testItemA, testItemB, testItemC]; |
View Copilot.getChangesOnList.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getChangesOnList } from './getChangesOnList'; | |
describe('getChangesOnList', () => { | |
it('should return the correct changes', () => { | |
const prev = [ | |
{ id: 1, name: 'foo' }, | |
{ id: 2, name: 'bar' }, | |
]; | |
const curr = [ | |
{ id: 1, name: 'foo' }, |
View ChatGPTgetChangesOnList.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getChangesOnList } from './getChangesOnList'; | |
describe('getChangesOnList', () => { | |
const prevList = [ | |
{ id: 1, name: 'John' }, | |
{ id: 2, name: 'Mary' }, | |
{ id: 3, name: 'Bob' }, | |
]; | |
const currList = [ | |
{ id: 1, name: 'John' }, |
View getChangesOnList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import isEqualFn from 'lodash/fp/isEqual'; | |
type Item = { id: string | number }; | |
/** | |
* Computes the changes between two lists of items. | |
* @param prev The previous list of items. | |
* @param curr The current list of items. | |
* @param isEqual The comparison function to use to determine if two items are deep equal. | |
* @returns An object containing three properties: |
View axiosInstance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
import {history} from "../helpers/history"; | |
import { | |
makeAuthorizationHeader, | |
isTokenValid, | |
getToken, | |
setToken, | |
tokenIsExpired, | |
} from "../helpers/token"; |
View article.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const article = { | |
"id": "a2f693f1-e63c-4190-81b3-7a0b459a2517", | |
"author": { | |
"id": "6e9418c3-8658-466f-81d6-58ac5548d3dd", | |
"displayName": "Gene Price", | |
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/iamsteffen/128.jpg", | |
"color": "#486071", | |
"url": "author/Gene-Price_6e9418c3-8658-466f-81d6-58ac5548d3dd" | |
}, | |
"title": "at odit nulla", |
View propTypes-isRequired.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Component.propTypes = { | |
requiredArray: PropTypes.array.isRequired, | |
requiredBool: PropTypes.bool.isRequired, | |
requiredFunc: PropTypes.func.isRequired, | |
requiredNumber: PropTypes.number.isRequired, | |
requiredObject: PropTypes.object.isRequired, | |
requiredString: PropTypes.string.isRequired, | |
requiredSymbol: PropTypes.symbol.isRequired, | |
// ... | |
}; |
View propTypes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Component.propTypes = { | |
optionalArray: PropTypes.array, | |
optionalBool: PropTypes.bool, | |
optionalFunc: PropTypes.func, | |
optionalNumber: PropTypes.number, | |
optionalObject: PropTypes.object, | |
optionalString: PropTypes.string, | |
optionalSymbol: PropTypes.symbol, | |
// ... | |
}; |
View typed-object-argument-function.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fullName = ( | |
{firstName = "", lastName = ""} // we are providing default values | |
: {firstName: string, lastName: string} // type, can be inferenced | |
= {} // default value object for object argument | |
) => `${firstName} ${lastName}`; |
View functions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(a: number, b: number): number { return a + b }; | |
const add = (a: number, b: number): number => a + b; | |
type Arithmetics = (a: number, b: number) => number; | |
// or | |
/* | |
interface Arithmetics { | |
(a: number, b: number): number; | |
} |
NewerOlder