type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
assert.isTrue(color.hasAlpha(), 'the color should be considered to have an alpha value');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.detectHEXFormat();
assert.strictEqual(result, 'hexa', 'format was not detected correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 1], 'testFormat', 'testColor');
const result = color.detectHEXFormat();
assert.strictEqual(result, 'hex', 'format was not detected correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.canonicalRGBA();
assert.deepEqual(result, [128, 128, 128, 0.5], 'canonical RGBA was not returned correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.nickname();
assert.strictEqual(result, 'red', 'nickname was not returned correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.nickname();
assert.isNull(result, 'nickname should be returned as Null');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.toProtocolRGBA();
assert.deepEqual(result, {r: 128, g: 128, b: 128, a: 0.5}, 'conversion to protocol RGBA was not correct');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.invert().rgba();
assert.deepEqual(result, [0, 1, 1, 1], 'inversion was not successful');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.setAlpha(0.5).rgba();
assert.deepEqual(result, [1, 0, 0, 0.5], 'alpha value was not set correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 0.5], 'testFormat', 'testColor');
const otherColor = new Color.Color([0, 0, 1, 0.5], 'testFormat', 'testColor');
const result = color.blendWith(otherColor).rgba();
assert.deepEqual(result, [0.5, 0, 0.5, 0.75], 'color was not blended correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'original', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'testColor', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'nickname', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'red', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'hex', 'testColor');
const result = color.asString();
assert.strictEqual(result, '#ff0000', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'shorthex', 'testColor');
const result = color.asString();
assert.strictEqual(result, '#f00', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'hexa', 'testColor');
const result = color.asString();
assert.strictEqual(result, '#ff0000ff', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'shorthexa', 'testColor');
const result = color.asString();
assert.strictEqual(result, '#f00f', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'rgb(255 0 0)', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'rgba', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'rgb(255 0 0 / 1)', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'hsl', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'hsl(0 100% 50%)', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'hsla', 'testColor');
const result = color.asString();
assert.strictEqual(result, 'hsl(0 100% 50% / 1)', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const color = new Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
const result = color.asString('nickname');
assert.strictEqual(result, 'red', 'color was not converted to a string correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
it('able to return the color for an ID if the ID was already set', () => {
const generator = new Color.Generator();
generator.setColorForID('r', 'Red');
assert.strictEqual(generator.colorForID('r'), 'Red', 'color was not retrieved correctly');
});
it('able to return the color for an ID that was not set', () => {
const generator = new Color.Generator();
assert.strictEqual(generator.colorForID('r'), 'hsl(133 67% 80% / 1)', 'color was not generated correctly');
});
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const generator = new Color.Generator();
generator.setColorForID('r', 'Red');
assert.strictEqual(generator.colorForID('r'), 'Red', 'color was not retrieved correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ArrowFunction |
() => {
const generator = new Color.Generator();
assert.strictEqual(generator.colorForID('r'), 'hsl(133 67% 80% / 1)', 'color was not generated correctly');
} | song940/devtools-frontend | test/unittests/front_end/common/Color_test.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'app-menu-panel',
templateUrl: './menu-panel.component.html',
styleUrls: ['./menu-panel.component.scss']
})
export class MenuPanelComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
public dados = [{ label: 'PO HTML Framework', link: '/MenuPanel', icon: 'po-icon-home' }];
} | delciney/angular-po-ui | front/src/app/components/menu-panel/menu-panel.component.ts | TypeScript |
ArrowFunction |
<K extends keyof WindowEventMap, T>(
event: K,
listener: (this: Window, ev: WindowEventMap[K]) => T
): void => useEffect(
(): () => void => {
window.addEventListener(event, listener);
return (): void => {
window.removeEventListener(event, listener);
};
},
[]
) | learnify-ca/learnify-hooks | src/useEventListener.ts | TypeScript |
ArrowFunction |
(): () => void => {
window.addEventListener(event, listener);
return (): void => {
window.removeEventListener(event, listener);
};
} | learnify-ca/learnify-hooks | src/useEventListener.ts | TypeScript |
ArrowFunction |
(): void => {
window.removeEventListener(event, listener);
} | learnify-ca/learnify-hooks | src/useEventListener.ts | TypeScript |
TypeAliasDeclaration |
export type DirectoryOptions = {
isDirectoryExplorer: true;
defaultPath?: string;
title?: string;
}; | WitoDelnat/monokle | src/components/atoms/FileExplorer/FileExplorerOptions.ts | TypeScript |
TypeAliasDeclaration |
export type FileOptions = {
isDirectoryExplorer?: false;
allowMultiple?: boolean;
acceptedFileExtensions?: string[];
defaultPath?: string;
title?: string;
action?: 'save' | 'open';
}; | WitoDelnat/monokle | src/components/atoms/FileExplorer/FileExplorerOptions.ts | TypeScript |
TypeAliasDeclaration |
export type FileExplorerOptions = DirectoryOptions | FileOptions; | WitoDelnat/monokle | src/components/atoms/FileExplorer/FileExplorerOptions.ts | TypeScript |
ClassDeclaration |
export class ButtonizeCustomResource extends CfnResource {
constructor(
scope: Construct,
id: string,
{ target, widget, apiKey }: ButtonizeCustomResourceProps
) {
super(scope, id, {
type: 'Custom::Buttonize',
properties: {
ServiceToken:
ButtonizeCustomResourceProvider.getOrCreateProvider(scope)
.serviceToken,
props: JSON.stringify({
target,
widget
}),
...(typeof apiKey === 'undefined' ? {} : { apiKey })
}
})
}
} | buttonize/buttonize-cdk | src/ButtonizeCustomResource.ts | TypeScript |
InterfaceDeclaration |
export interface ButtonizeCustomResourceProps {
readonly target: LambdaTarget | CustomTarget
readonly widget: Widget
readonly apiKey?: string
} | buttonize/buttonize-cdk | src/ButtonizeCustomResource.ts | TypeScript |
ArrowFunction |
(data:string) => {
this.connectedClientID = data
} | TJSTONE99/Single-spa-micro-front-end-tracer | Details_App/src/app/components/question/question.component.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'app-question',
templateUrl: './question.component.html',
styleUrls: ['./question.component.css']
})
export class QuestionComponent implements OnInit, OnDestroy {
constructor(private websocket: WebsocketService, private eventBus: EventbusService) { }
connectedClientID:string
subscription: Subscription
ngOnInit(): void {
this.connectedClientID = ""
this.subscription = this.eventBus.getConnectedClientValue().subscribe((data:string) => {
this.connectedClientID = data
})
}
submitSelection(value: string) :void{
this.websocket.sendMessage('_sendMessageToRecipent', {recipentClientID:this.connectedClientID, value:`Connected User Selected : ${value}`})
}
ngOnDestroy(): void{
this.subscription.unsubscribe()
}
} | TJSTONE99/Single-spa-micro-front-end-tracer | Details_App/src/app/components/question/question.component.ts | TypeScript |
MethodDeclaration |
ngOnInit(): void {
this.connectedClientID = ""
this.subscription = this.eventBus.getConnectedClientValue().subscribe((data:string) => {
this.connectedClientID = data
})
} | TJSTONE99/Single-spa-micro-front-end-tracer | Details_App/src/app/components/question/question.component.ts | TypeScript |
MethodDeclaration |
submitSelection(value: string) :void{
this.websocket.sendMessage('_sendMessageToRecipent', {recipentClientID:this.connectedClientID, value:`Connected User Selected : ${value}`})
} | TJSTONE99/Single-spa-micro-front-end-tracer | Details_App/src/app/components/question/question.component.ts | TypeScript |
MethodDeclaration |
ngOnDestroy(): void{
this.subscription.unsubscribe()
} | TJSTONE99/Single-spa-micro-front-end-tracer | Details_App/src/app/components/question/question.component.ts | TypeScript |
ClassDeclaration |
export class Book extends Publication
{
private _isbn: string;
private _titleBook: string;
private _editorial: string;
private _county: string;
private _city: string;
private _bookPDF: File;
private _certificateEditorial: File;
public getIsbn(): string {
return this._isbn;
}
public setIsbn(value: string) {
this._isbn = value;
}
public getTitleBook(): string {
return this._titleBook;
}
public setTitleBook(value: string) {
this._titleBook = value;
}
public getEditorial(): string {
return this._editorial;
}
public setEditorial(value: string) {
this._editorial = value;
}
public getCounty(): string {
return this._county;
}
public setCounty(value: string) {
this._county = value;
}
public getCity(): string {
return this._city;
}
public setCity(value: string) {
this._city = value;
}
public getBookPDF(): File {
return this._bookPDF;
}
public setBookPDF(value: File) {
this._bookPDF = value;
}
public getCertificateEditorial(): File {
return this._certificateEditorial;
}
public setCertificateEditorial(value: File) {
this._certificateEditorial = value;
}
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getIsbn(): string {
return this._isbn;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setIsbn(value: string) {
this._isbn = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getTitleBook(): string {
return this._titleBook;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setTitleBook(value: string) {
this._titleBook = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getEditorial(): string {
return this._editorial;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setEditorial(value: string) {
this._editorial = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getCounty(): string {
return this._county;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setCounty(value: string) {
this._county = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getCity(): string {
return this._city;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setCity(value: string) {
this._city = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getBookPDF(): File {
return this._bookPDF;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setBookPDF(value: File) {
this._bookPDF = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public getCertificateEditorial(): File {
return this._certificateEditorial;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
MethodDeclaration |
public setCertificateEditorial(value: File) {
this._certificateEditorial = value;
} | zjimenez110492/Proyecto-Maestria | src/app/models/publications/book.ts | TypeScript |
TypeAliasDeclaration |
type IStore = {
items: {
id: string
images: string[]
selectedImage: number
}[]
} | Soare-Robert-Daniel/NFT-Generator-PIS | src/store.ts | TypeScript |
ArrowFunction |
({ Component, pageProps }) => {
// Can be set to 'devnet', 'testnet', or 'mainnet-beta'
const network = WalletAdapterNetwork.Devnet;
// You can also provide a custom RPC endpoint
const endpoint = useMemo(() => clusterApiUrl(network), [network]);
// @solana/wallet-adapter-wallets includes all the adapters but supports tree shaking and lazy loading --
// Only the wallets you configure here will be compiled into your application, and only the dependencies
// of wallets that your users connect to will be loaded
const wallets = useMemo(
() => [
new PhantomWalletAdapter(),
new GlowWalletAdapter(),
new SlopeWalletAdapter(),
new SolflareWalletAdapter({ network }),
new TorusWalletAdapter(),
],
[network]
);
return (
<ConnectionProvider endpoint={endpoint}>
<WalletProvider wallets={wallets} autoConnect>
<WalletModalProvider>
<Component {...pageProps} />
</WalletModalProvider>
</WalletProvider>
</ConnectionProvider> | TP-Lab/wallet-adapter | packages/starter/nextjs-starter/pages/_app.tsx | TypeScript |
ArrowFunction |
() => clusterApiUrl(network) | TP-Lab/wallet-adapter | packages/starter/nextjs-starter/pages/_app.tsx | TypeScript |
ArrowFunction |
() => [
new PhantomWalletAdapter(),
new GlowWalletAdapter(),
new SlopeWalletAdapter(),
new SolflareWalletAdapter({ network }),
new TorusWalletAdapter(),
] | TP-Lab/wallet-adapter | packages/starter/nextjs-starter/pages/_app.tsx | TypeScript |
ArrowFunction |
(state: State) => state.subApp.financialPositions.financialPositions | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) => state.subApp.financialPositions.financialPositionsError | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.isFinancialPositionsPending | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) => state.subApp.financialPositions.selectedFinancialPosition | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.financialPositionUpdateAmount | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.isFinancialPositionUpdateSubmitPending | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.isFinancialPositionUpdateCancelEnabled | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.selectedFinancialPositionUpdateAction | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.isShowUpdateFinancialPositionConfirmModal | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
ArrowFunction |
(state: State) =>
state.subApp.financialPositions.isUpdateFinancialPositionNDCAfterConfirmModal | kleyow/finance-portal-v2-ui | src/App/FinancialPositions/selectors.ts | TypeScript |
FunctionDeclaration |
export default function semiOmitCssLoader(source: string) {
return source
.replace(/(import\s+['"][^'"]+\.css['"])/g, '// $1')
.replace(/(require\(['"][^'"]+\.css['"]\))/g, '// $1');
} | AhmedSayed77/semi-design | packages/semi-webpack/src/semi-omit-css-loader.ts | TypeScript |
ClassDeclaration |
export class UserOutputDTO{
readonly id: string;
readonly role: string;
readonly login: string;
readonly createdAt: string;
readonly updatedAt: string;
constructor(data) {
this.id = data.id;
this.role = data.role;
this.login = data.login;
this.createdAt = data.createdAt;
this.updatedAt = data.updatedAt;
}
} | MaksKryuk/practice-wiki | src/modules/output-dto/user.output.dto.ts | TypeScript |
ArrowFunction |
() => ({
root: {
overflow: 'initial',
maxWidth: 304,
backgroundColor: 'transparent',
},
title: {
marginBottom: 0,
},
rateValue: {
fontWeight: 'bold',
marginTop: 2,
},
content: {
position: 'relative',
padding: 24,
margin: '-24% 16px 0',
backgroundColor: '#fff',
borderRadius: 4,
},
favorite: {
position: 'absolute',
top: 12,
right: 12,
},
locationIcon: {
marginRight: 4,
fontSize: 18,
},
}) | Galaxyjia/mui-treasury | website/src/docs/components/card/review/ReviewCard.tsx | TypeScript |
ArrowFunction |
(props: ShowcaseProps) => (
<Showcase
{...props} | Galaxyjia/mui-treasury | website/src/docs/components/card/review/ReviewCard.tsx | TypeScript |
ArrowFunction |
(timestamps: number[]) =>
timestamps.map((timestamp) => {
return `t${timestamp}:blocks(first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${
timestamp + 600
} }) {
number
}`
}) | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
(timestamp) => {
return `t${timestamp}:blocks(first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${
timestamp + 600
} }) {
number
}`
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
(subqueries: string[]) => {
return gql`query blocks {
${subqueries}
}`
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
async (
timestamps: number[],
sortDirection: 'asc' | 'desc' = 'desc',
skipCount = 500,
): Promise<Block[]> => {
if (timestamps?.length === 0) {
return []
}
const fetchedData: any = await multiQuery(
blocksQueryConstructor,
getBlockSubqueries(timestamps),
BLOCKS_CLIENT,
skipCount,
)
const blocks: Block[] = []
if (fetchedData) {
// eslint-disable-next-line no-restricted-syntax
for (const key of Object.keys(fetchedData)) {
if (fetchedData[key].length > 0) {
blocks.push({
timestamp: key.split('t')[1],
number: parseInt(fetchedData[key][0].number, 10),
})
}
}
// graphql-request does not guarantee same ordering of batched requests subqueries, hence manual sorting
return orderBy(blocks, (block) => block.number, sortDirection)
}
return blocks
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
(block) => block.number | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
(
timestamps: number[],
sortDirection: 'asc' | 'desc' = 'desc',
skipCount = 1000,
): {
blocks?: Block[]
error: boolean
} => {
const [blocks, setBlocks] = useState<Block[]>()
const [error, setError] = useState(false)
const timestampsString = JSON.stringify(timestamps)
const blocksString = blocks ? JSON.stringify(blocks) : undefined
useEffect(() => {
const fetchData = async () => {
const timestampsArray = JSON.parse(timestampsString)
const result = await getBlocksFromTimestamps(timestampsArray, sortDirection, skipCount)
if (result.length === 0) {
setError(true)
} else {
setBlocks(result)
}
}
const blocksArray = blocksString ? JSON.parse(blocksString) : undefined
if (!blocksArray && !error) {
fetchData()
}
}, [blocksString, error, skipCount, sortDirection, timestampsString])
return {
blocks,
error,
}
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
() => {
const fetchData = async () => {
const timestampsArray = JSON.parse(timestampsString)
const result = await getBlocksFromTimestamps(timestampsArray, sortDirection, skipCount)
if (result.length === 0) {
setError(true)
} else {
setBlocks(result)
}
}
const blocksArray = blocksString ? JSON.parse(blocksString) : undefined
if (!blocksArray && !error) {
fetchData()
}
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
async () => {
const timestampsArray = JSON.parse(timestampsString)
const result = await getBlocksFromTimestamps(timestampsArray, sortDirection, skipCount)
if (result.length === 0) {
setError(true)
} else {
setBlocks(result)
}
} | CryptoR2022/CryptorDEX | src/views/Info/hooks/useBlocksFromTimestamps.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
resolve(true);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
resolve(new BusinessNetworkDefinition('[email protected]', 'Acme Business Network'));
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
mockClientService = sinon.createStubInstance(ClientService);
TestBed.configureTestingModule({
declarations: [
FileImporterComponent,
AddFileComponent,
FileDragDropDirective
],
imports: [
FormsModule
],
providers: [
{provide: AdminService, useClass: MockAdminService},
{provide: AlertService, useClass: MockAlertService},
{provide: ClientService, useValue: mockClientService},
NgbActiveModal
]
});
sandbox = sinon.sandbox.create();
fixture = TestBed.createComponent(AddFileComponent);
component = fixture.componentInstance;
mockScriptManager = sinon.createStubInstance(ScriptManager);
mockBusinessNetwork = sinon.createStubInstance(BusinessNetworkDefinition);
mockBusinessNetwork.getModelManager.returns(mockModelManager);
mockBusinessNetwork.getScriptManager.returns(mockScriptManager);
mockBusinessNetwork.getAclManager.returns(mockAclManager);
mockSystemModelFile = sinon.createStubInstance(ModelFile);
mockSystemModelFile.isLocalType.withArgs('Asset').returns(true);
mockSystemModelFile.getNamespace.returns('org.hyperledger.composer.system');
mockModelManager = sinon.createStubInstance(ModelManager);
mockModelManager.getModelFile.withArgs('org.hyperledger.composer.system').returns(mockSystemModelFile);
mockSystemAsset = sinon.createStubInstance(AssetDeclaration);
mockSystemAsset.getFullyQualifiedName.returns('org.hyperledger.composer.system.Asset');
mockModelManager.getSystemTypes.returns([mockSystemAsset]);
mockAclFile = sinon.createStubInstance(AclFile);
mockAclManager = sinon.createStubInstance(AclManager);
mockAclManager.getAclFile.returns(mockAclFile);
mockQueryFile = sinon.createStubInstance(QueryFile);
mockQueryManager = sinon.createStubInstance(QueryManager);
mockQueryManager.getQueryFile.returns(mockQueryFile);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
it('should change this.expandInput to true', () => {
component.fileDetected();
component.expandInput.should.equal(true);
});
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
component.fileDetected();
component.expandInput.should.equal(true);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
it('should change this.expectedInput to false', () => {
component.fileLeft();
component.expandInput.should.equal(false);
});
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
component.fileLeft();
component.expandInput.should.equal(false);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
it('should call this.createModel if model file detected', fakeAsync(() => {
let b = new Blob(['/**CTO File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.cto');
let createMock = sandbox.stub(component, 'createModel');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
}));
it('should call this.createScript if script file detected', fakeAsync(() => {
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.js');
let createMock = sandbox.stub(component, 'createScript');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
}));
it('should call this.createRules if ACL file detected', fakeAsync(() => {
let b = new Blob(['/**ACL File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.acl');
let createMock = sandbox.stub(component, 'createRules');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
}));
it('should call this.createReadme if readme file detected', fakeAsync(() => {
let b = new Blob(['/**README File*/'], {type: 'text/plain'});
let file = new File([b], 'README.md');
let createMock = sandbox.stub(component, 'createReadme');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
}));
it('should call this.createQuery if query file detected', fakeAsync(() => {
let b = new Blob(['/**QUERY File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.qry');
let createMock = sandbox.stub(component, 'createQuery');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
}));
it('should call this.fileRejected when there is an error reading the file', fakeAsync(() => {
let b = new Blob(['/**CTO File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.cto');
let createMock = sandbox.stub(component, 'fileRejected');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.reject('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.called;
}));
it('should throw when given incorrect file type', fakeAsync(() => {
let b = new Blob(['/**PNG File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.png');
let createMock = sandbox.stub(component, 'fileRejected');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.calledWith('Unexpected File Type: png');
}));
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**CTO File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.cto');
let createMock = sandbox.stub(component, 'createModel');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.js');
let createMock = sandbox.stub(component, 'createScript');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**ACL File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.acl');
let createMock = sandbox.stub(component, 'createRules');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**README File*/'], {type: 'text/plain'});
let file = new File([b], 'README.md');
let createMock = sandbox.stub(component, 'createReadme');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**QUERY File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.qry');
let createMock = sandbox.stub(component, 'createQuery');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.should.have.been.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**CTO File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.cto');
let createMock = sandbox.stub(component, 'fileRejected');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.reject('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.called;
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let b = new Blob(['/**PNG File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.png');
let createMock = sandbox.stub(component, 'fileRejected');
let dataBufferMock = sandbox.stub(component, 'getDataBuffer')
.returns(Promise.resolve('some data'));
// Run method
component.fileAccepted(file);
tick();
// Assertions
createMock.calledWith('Unexpected File Type: png');
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
it('should return an error status', async(() => {
component.fileRejected('long reason to reject file');
component['alertService'].errorStatus$.subscribe(
(message) => {
expect(message).to.be.equal('long reason to reject file');
}
);
}));
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
component.fileRejected('long reason to reject file');
component['alertService'].errorStatus$.subscribe(
(message) => {
expect(message).to.be.equal('long reason to reject file');
}
);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
(message) => {
expect(message).to.be.equal('long reason to reject file');
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
it('should create a new script file', async(() => {
let mockScript = sinon.createStubInstance(Script);
mockScript.getIdentifier.returns('newfile.js');
mockClientService.createScriptFile.returns(mockScript);
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.js');
// Run method
component.createScript(file, file);
// Assertions
component.fileType.should.equal('js');
mockClientService.createScriptFile.calledWith(file.name, 'JS', file.toString());
component.currentFile.should.deep.equal(mockScript);
component.currentFileName.should.equal(mockScript.getIdentifier());
}));
it('should use the addScriptFileName variable as the file name if none passed in', () => {
let fileName = 'testFileName.js';
component.addScriptFileName = fileName;
let mockScript = sinon.createStubInstance(Script);
mockScript.getIdentifier.returns(fileName);
mockClientService.createScriptFile.returns(mockScript);
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], '');
// Run method
component.createScript(null, file);
// Assertions
component.fileType.should.equal('js');
mockClientService.createScriptFile.calledWith(fileName, 'JS', file.toString());
component.currentFile.should.deep.equal(mockScript);
component.currentFileName.should.equal(mockScript.getIdentifier());
component.currentFileName.should.equal(fileName);
});
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let mockScript = sinon.createStubInstance(Script);
mockScript.getIdentifier.returns('newfile.js');
mockClientService.createScriptFile.returns(mockScript);
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], 'newfile.js');
// Run method
component.createScript(file, file);
// Assertions
component.fileType.should.equal('js');
mockClientService.createScriptFile.calledWith(file.name, 'JS', file.toString());
component.currentFile.should.deep.equal(mockScript);
component.currentFileName.should.equal(mockScript.getIdentifier());
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
ArrowFunction |
() => {
let fileName = 'testFileName.js';
component.addScriptFileName = fileName;
let mockScript = sinon.createStubInstance(Script);
mockScript.getIdentifier.returns(fileName);
mockClientService.createScriptFile.returns(mockScript);
let b = new Blob(['/**JS File*/'], {type: 'text/plain'});
let file = new File([b], '');
// Run method
component.createScript(null, file);
// Assertions
component.fileType.should.equal('js');
mockClientService.createScriptFile.calledWith(fileName, 'JS', file.toString());
component.currentFile.should.deep.equal(mockScript);
component.currentFileName.should.equal(mockScript.getIdentifier());
component.currentFileName.should.equal(fileName);
} | NunoEdgarGFlowHub/composer | packages/composer-playground/src/app/editor/add-file/add-file.component.spec.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.