lodash#times TypeScript Examples
The following examples show how to use
lodash#times.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: search-factories.ts From linkedin-private-api with MIT License | 6 votes |
createBaseCompany = (count: number) =>
times(count, () => ({
$type: 'com.linkedin.voyager.organization.Company',
entityUrn: faker.datatype.uuid(),
logo: {
$type: 'com.linkedin.voyager.organization.CompanyLogoImage',
image: {},
type: 'SQUARE_LOGO',
},
name: faker.datatype.uuid(),
}))
Example #2
Source File: invitation-factories.ts From linkedin-private-api with MIT License | 6 votes |
createInvitation = (count: number) =>
times(count, () => ({
$type: 'com.linkedin.voyager.relationships.invitation.Invitation',
'*fromMember': createMiniProfileId(),
'*toMember': createMiniProfileId(),
customMessage: faker.datatype.boolean(),
entityUrn: faker.datatype.uuid(),
invitationType: Object.values(INVITATION_TYPE)[random(0, 1)],
invitee: {
$type: 'com.linkedin.voyager.relationships.invitation.ProfileInvitee',
'*miniProfile': createMiniProfileId(),
},
mailboxItemId: faker.datatype.uuid(),
sentTime: faker.datatype.number(),
sharedSecret: faker.random.word(),
toMemberId: faker.datatype.uuid(),
unseen: faker.datatype.boolean(),
}))
Example #3
Source File: message-factories.ts From linkedin-private-api with MIT License | 6 votes |
createMessage = (count: number): LinkedInMessage[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.messaging.event.MessageEvent',
attributedBody: {
$type: 'com.linkedin.pemberly.text.AttributedText',
text: faker.lorem.sentence(),
},
body: faker.random.word(),
messageBodyRenderFormat: faker.random.word(),
}))
Example #4
Source File: message-factories.ts From linkedin-private-api with MIT License | 6 votes |
createEventCreate = (count: number): LinkedEventCreateResponse[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.messaging.create.EventCreateResponse',
backendConversationUrn: faker.datatype.uuid(),
backendEventUrn: faker.datatype.uuid(),
conversationUrn: faker.datatype.uuid(),
createdAt: faker.datatype.number(),
eventUrn: faker.datatype.uuid(),
}))
Example #5
Source File: profile-factories.ts From linkedin-private-api with MIT License | 6 votes |
createCompany = (count: number): LinkedInCompany[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.dash.organization.Company',
$anti_abuse_annotations: [{ attributeId: faker.datatype.number(), entityId: faker.datatype.number() }],
$recipeTypes: [faker.random.word()],
entityUrn: faker.datatype.uuid(),
industry: { [faker.datatype.uuid()]: faker.random.word() },
industryUrns: [faker.datatype.uuid()],
logo: {
vetorImage: createVectorImage(1)[0],
},
name: faker.name.firstName(),
universalName: faker.name.firstName(),
url: faker.internet.url(),
}))
Example #6
Source File: profile-factories.ts From linkedin-private-api with MIT License | 6 votes |
createProfilePicture = (count: number): LinkedInPhotoFilterPicture[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.dash.identity.profile.PhotoFilterPicture',
$recipeTypes: [faker.datatype.uuid()],
displayImageReference: {
vectorImage: createVectorImage(1)[0],
},
displayImageUrn: faker.datatype.uuid(),
photoFilterEditInfo: {},
}))
Example #7
Source File: profile-factories.ts From linkedin-private-api with MIT License | 6 votes |
createProfile = (count: number): Partial<LinkedInProfile>[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.dash.identity.profile.Profile',
'*industry': faker.datatype.uuid(),
'*profileCertifications': faker.datatype.uuid(),
'*profileCourses': faker.datatype.uuid(),
'*profileEducations': faker.datatype.uuid(),
'*profileHonors': faker.datatype.uuid(),
'*profileLanguages': faker.datatype.uuid(),
'*profileOrganizations': faker.datatype.uuid(),
'*profilePatents': faker.datatype.uuid(),
'*profilePositionGroups': faker.datatype.uuid(),
'*profileProjects': faker.datatype.uuid(),
'*profilePublications': faker.datatype.uuid(),
'*profileSkills': faker.datatype.uuid(),
'*profileTestScores': faker.datatype.uuid(),
'*profileTreasuryMediaProfile': faker.datatype.uuid(),
'*profileVolunteerExperiences': faker.datatype.uuid(),
$recipeTypes: times(3, faker.datatype.uuid),
defaultToActivityTab: faker.datatype.boolean(),
educationOnProfileTopCardShown: faker.datatype.boolean(),
entityUrn: createMiniProfileId(),
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
geoLocationBackfilled: faker.datatype.boolean(),
headline: faker.random.word(),
industryUrn: faker.datatype.uuid(),
locationName: faker.random.word(),
objectUrn: faker.datatype.uuid(),
profilePicture: createProfilePicture(1)[0],
publicIdentifier: faker.datatype.uuid(),
trackingId: faker.datatype.uuid(),
versionTag: faker.datatype.uuid(),
}))
Example #8
Source File: profile-factories.ts From linkedin-private-api with MIT License | 6 votes |
createMiniProfile = (count: number): LinkedInMiniProfile[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.identity.shared.MiniProfile',
trackingId: faker.datatype.uuid(),
firstName: faker.random.words(),
lastName: faker.random.words(),
publicIdentifier: faker.datatype.uuid(),
objectUrn: faker.datatype.uuid(),
entityUrn: createMiniProfileId(),
occupation: faker.random.words(),
picture: createVectorImage(1)[0],
backgroundImage: createVectorImage(1)[0],
}))
Example #9
Source File: search-factories.ts From linkedin-private-api with MIT License | 6 votes |
createMiniCompany = (count: number) =>
times(count, () => ({
$type: 'com.linkedin.voyager.entities.shared.MiniCompany',
active: faker.datatype.boolean(),
entityUrn: `urn:li:fs_miniCompany:${faker.datatype.uuid()}`,
name: faker.datatype.uuid(),
objectUrn: faker.datatype.uuid(),
showcase: faker.datatype.boolean(),
trackingId: faker.datatype.uuid(),
universalName: faker.random.word(),
}))
Example #10
Source File: message-factories.ts From linkedin-private-api with MIT License | 6 votes |
createMessageEvent = (count: number): Partial<LinkedInMessageEvent>[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.messaging.Event',
'*from': faker.datatype.uuid(),
backendUrn: faker.datatype.uuid(),
createdAt: faker.datatype.number(),
dashEntityUrn: faker.datatype.uuid(),
entityUrn: faker.datatype.uuid(),
originToken: faker.datatype.uuid(),
subtype: faker.datatype.uuid(),
previousEventInConversation: faker.datatype.uuid(),
eventContent: createMessage(1)[0],
}))
Example #11
Source File: search-factories.ts From linkedin-private-api with MIT License | 6 votes |
createJobPosting = (count: number) =>
times(count, () => ({
$type: 'com.linkedin.voyager.jobs.JobPosting',
entityUrn: faker.datatype.uuid(),
dashEntityUrn: faker.datatype.uuid(),
formattedLocation: faker.datatype.string(),
listedAt: faker.datatype.number(),
title: faker.datatype.string(),
workRemoteAllowed: faker.datatype.boolean(),
companyDetails: {
'*companyResolutionResult': faker.datatype.string(),
$type: 'com.linkedin.voyager.jobs.JobPostingCompany',
company: faker.datatype.string(),
},
}))
Example #12
Source File: search-factories.ts From linkedin-private-api with MIT License | 6 votes |
createJobSearchHit = (count: number) =>
times(count, () => ({
$type: 'com.linkedin.voyager.search.SearchHit',
hitInfo: {
'*jobPostingResolutionResult': faker.datatype.string(),
$type: 'com.linkedin.voyager.search.SearchJobJserp',
jobPosting: faker.datatype.string(),
sponsored: faker.datatype.boolean(),
},
targetPageInstance: faker.datatype.string(),
trackingId: faker.datatype.string(),
}))
Example #13
Source File: generateManifest.ts From nft-maker-js with Do What The F*ck You Want To Public License | 6 votes |
export default async function (task: null | Task): Promise<void> {
const { maxAttempts, uniques, editionSize } = resolveConfiguration()
maxNumberOfAttempts = maxAttempts
prepareOutputFolder()
uniques.forEach((u: Image) => {
if (validUnique(u)) {
imageData.push(u)
}
})
times(editionSize - uniques.length, () => {
attempts++
if (attempts == maxNumberOfAttempts) {
fail(`Could not find a unique image after ${attempts} attempts.`)
}
imageData.push(createNewUniqueImage())
attempts = 0
})
imageData = shuffle(imageData)
imageData = assignTokenIds(imageData)
fs.writeFileSync('./manifest.json', JSON.stringify(imageData, null, 2), {
flag: 'w',
})
}
Example #14
Source File: index.stories.tsx From pancake-toolkit with GNU General Public License v3.0 | 6 votes |
LazyImages: React.FC = () => {
return (
<Flex flexWrap="wrap">
{times(40, (index) => (
<Img
key={index}
src={`https://via.placeholder.com/${150 + index}`}
width={150}
height={150}
mb="16px"
mr="16px"
/>
))}
</Flex>
);
}
Example #15
Source File: index.stories.tsx From pancake-toolkit with GNU General Public License v3.0 | 6 votes |
LazyBackgrounds: React.FC = () => {
return (
<Flex flexWrap="wrap">
{times(40, (index) => (
<BackgroundImage
key={index}
src={`https://via.placeholder.com/${150 + index}`}
width={150}
height={150}
mb="16px"
mr="16px"
/>
))}
</Flex>
);
}
Example #16
Source File: unique-id.spec.ts From s-libs with MIT License | 6 votes |
describe('uniqueId()', () => {
it('uses the given prefix', () => {
expect(uniqueId('one').startsWith('one')).toBeTruthy();
expect(uniqueId('two').startsWith('two')).toBeTruthy();
expect(uniqueId('repeat').startsWith('repeat')).toBeTruthy();
expect(uniqueId('repeat').startsWith('repeat')).toBeTruthy();
});
//
// stolen from https://github.com/lodash/lodash
//
it('should generate unique ids', () => {
const actual = times(1000, () => uniqueId());
expect(uniq(actual).length).toBe(actual.length);
});
it('should return a string value when not providing a `prefix`', () => {
expect(typeof uniqueId()).toBe('string');
});
});
Example #17
Source File: index.stories.tsx From vvs-ui with GNU General Public License v3.0 | 6 votes |
LazyImages: React.FC = () => {
return (
<Flex flexWrap="wrap">
{times(40, (index) => (
<Img
key={index}
src={`https://via.placeholder.com/${150 + index}`}
width={150}
height={150}
mb="16px"
mr="16px"
/>
))}
</Flex>
);
}
Example #18
Source File: index.stories.tsx From vvs-ui with GNU General Public License v3.0 | 6 votes |
LazyBackgrounds: React.FC = () => {
return (
<Flex flexWrap="wrap">
{times(40, (index) => (
<BackgroundImage
key={index}
src={`https://via.placeholder.com/${150 + index}`}
width={150}
height={150}
mb="16px"
mr="16px"
/>
))}
</Flex>
);
}
Example #19
Source File: conversation-factories.ts From linkedin-private-api with MIT License | 6 votes |
createReceipt = (count: number): LinkedInParticipantReceipts[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.messaging.ParticipantReceipts',
fromEntity: faker.datatype.uuid(),
fromParticipant: faker.datatype.uuid(),
seenReceipt: {
$type: 'com.linkedin.voyager.messaging.SeenReceipt',
eventUrn: faker.datatype.uuid(),
seenAt: faker.datatype.number(),
},
}))
Example #20
Source File: conversation-factories.ts From linkedin-private-api with MIT License | 6 votes |
createConversation = (count: number): Partial<LinkedinConversation>[] =>
times(count, () => ({
$type: 'com.linkedin.voyager.messaging.Conversation',
'*events': [faker.datatype.uuid()],
'*participants': [faker.datatype.uuid(), faker.datatype.uuid()],
'*type': [faker.datatype.uuid()],
archived: faker.datatype.boolean(),
backendUrn: faker.datatype.uuid(),
blocked: faker.datatype.boolean(),
entityUrn: `urn:li:fs_conversation:${faker.datatype.uuid()}`,
featureTypes: Object.values(FeaturedType.CREATE_NEW_GROUP_CHAT),
firstMessageUrn: faker.datatype.uuid(),
lastActivityAt: faker.datatype.number(),
muted: faker.datatype.boolean(),
notificationStatus: faker.random.word(),
read: faker.datatype.boolean(),
receipts: createReceipt(2),
totalEventCount: faker.datatype.number(),
unreadCount: faker.datatype.number(),
viewerCurrentParticipant: faker.datatype.boolean(),
withNonConnection: faker.datatype.boolean(),
}))
Example #21
Source File: file.decorator.ts From aqualink-app with MIT License | 6 votes |
getRandomName = (
folder: string,
prefix: string,
file: string,
type: string | undefined,
) => {
const extension = path.extname(file);
const randomString = times(16, () => random(15).toString(16)).join('');
const fullname = `${prefix}-${type}-${randomString}${extension}`;
return path.join(folder, fullname);
}
Example #22
Source File: users.seeder.ts From nestjs-rest-microservices with MIT License | 6 votes |
async seedDatabase(): Promise<number> {
const recordCount: number = await this.service.count()
if (recordCount > 0) {
this.logger.info('UsersSeeder#seedDatabase', 'Aborting...')
return recordCount
}
const numOfRecords: number = random.number({ min: 10, max: 30 })
this.logger.info('UsersSeeder#seedDatabase.numOfRecords', numOfRecords)
times(numOfRecords, async () => {
const user: User = await this.service.create({
organization: random.arrayElement(this.ORGS),
loginId: internet.userName(),
avatar: image.avatar(),
followers: random.number({ min: 1, max: 500 }),
following: random.number({ min: 1, max: 500 })
})
this.logger.info('UsersSeeder#seedDatabase.newRecord', user)
})
return numOfRecords
}
Example #23
Source File: comments.seeder.ts From nestjs-rest-microservices with MIT License | 6 votes |
async seedDatabase(): Promise<number> {
const recordCount: number = await this.service.count()
if (recordCount > 0) {
this.logger.info('CommentsSeeder#seedDatabase', 'Aborting...')
return recordCount
}
const numOfRecords: number = random.number({ min: 10, max: 30 })
this.logger.info('CommentsSeeder#seedDatabase.numOfRecords', numOfRecords)
times(numOfRecords, async () => {
const comment: Comment = await this.service.create({
organization: random.arrayElement(this.ORGS),
comment: lorem.sentence()
})
this.logger.info('CommentsSeeder#seedDatabase.newRecord', comment)
})
return numOfRecords
}
Example #24
Source File: time-series.mock.ts From aqualink-app with MIT License | 6 votes |
createTimeSeriesData = (
source: DeepPartial<Sources>,
): DeepPartial<TimeSeries>[] => {
const metrics = getMetrics(source.type);
return metrics
.map((metric) =>
times(10, (i) => {
const date = moment()
.subtract(i, 'days')
.set('hour', random(23))
.set('minute', random(59))
.toDate();
return {
timestamp: date,
value: getFakerValue(metric),
metric,
source,
};
}),
)
.flat();
}
Example #25
Source File: index.tsx From aqualink-app with MIT License | 6 votes |
MOBILE_SELECT_MENU_ITEMS = Object.values(OrderKeys)
.filter((key) => DEFAULT_ITEMS.includes(key))
.reduce<ReactNode[]>(
(elements, val) => [
...elements,
...times(2, (i) => {
const itemOrder: Order = i % 2 === 0 ? "asc" : "desc";
return (
<MenuItem value={`${val}-${itemOrder}`} key={val + i}>
<Typography color="primary" variant="h4">
{getOrderKeysFriendlyString(val)}
{" "}
{itemOrder === "asc" ? (
<ArrowDownward fontSize="small" />
) : (
<ArrowUpward fontSize="small" />
)}
</Typography>
</MenuItem>
);
}),
],
[]
)
Example #26
Source File: create-sites.seeds.ts From aqualink-app with MIT License | 5 votes |
public async run(factory: Factory) {
const site = await factory(Site)().create();
const startDate = new Date(2020, 1, 1);
const dates = times(10, (i) => {
const date = new Date();
date.setDate(startDate.getDate() + i);
return date;
});
await Promise.all(
dates.map((date) => {
return factory(DailyData)()
.map(async (dailyData) => {
dailyData.date = date;
dailyData.site = site;
return dailyData;
})
.create();
}),
);
const surveyPoints = await Promise.all(
times(4, () => {
return factory(SiteSurveyPoint)()
.map(async (surveyPoint) => {
surveyPoint.site = site;
return surveyPoint;
})
.create();
}),
);
const metrics = [
Metric.ALERT,
Metric.DHW,
Metric.SATELLITE_TEMPERATURE,
Metric.TOP_TEMPERATURE,
Metric.BOTTOM_TEMPERATURE,
Metric.SST_ANOMALY,
];
const sources = await Promise.all(
surveyPoints.map((surveyPoint) => {
return factory(Sources)()
.map(async (data) => {
data.site = site;
data.surveyPoint = surveyPoint;
data.type = SourceType.HOBO;
return data;
})
.create();
}),
);
const sourcesMap: { [k: number]: Sources } = Object.fromEntries(
sources.map((source) => [source.surveyPoint!.id, source]),
);
await Promise.all(
times(1000, () => {
return factory(TimeSeries)()
.map(async (data) => {
const metricId = Math.floor(Math.random() * 5);
const surveyPointId = Math.floor(Math.random() * 4);
data.source = sourcesMap[surveyPoints[surveyPointId].id];
data.metric = metrics[metricId];
return data;
})
.create();
}),
);
}
Example #27
Source File: index.ts From MyAPI with MIT License | 5 votes |
getParamValues = (paramLength: number): string => {
return times(paramLength, i => `$${ i + 1 }`).join(',')
}
Example #28
Source File: daily-data.mock.ts From aqualink-app with MIT License | 5 votes |
getMockSpotterData = (
startDate: Date,
endDate: Date,
): SpotterData => {
const start = moment(startDate);
const end = moment(endDate);
const diffDays = end.diff(start, 'days');
return {
bottomTemperature: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(15, 35, true),
})),
topTemperature: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(15, 35, true),
})),
significantWaveHeight: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(15, 35, true),
})),
waveMeanPeriod: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(15, 35, true),
})),
waveMeanDirection: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(359),
})),
windSpeed: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(10, true),
})),
windDirection: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(359),
})),
latitude: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(-90, 90, true),
})),
longitude: times(diffDays, (i) => ({
timestamp: start.clone().add(i, 'days').toISOString(),
value: random(-180, 180, true),
})),
};
}
Example #29
Source File: daily-data.mock.ts From aqualink-app with MIT License | 5 votes |
californiaDailyData: DeepPartial<DailyData>[] = times(10, (i) => {
const dataDate = moment().subtract(i, 'd').endOf('day').toISOString();
return getMockDailyData(dataDate, californiaSite);
})