本文整理汇总了TypeScript中UUID.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: switch
export const pizzaReducer: ActionReducer<Object> = (state = defaultState, action: Action) => {
switch (action.type) {
case PizzaActions.CREATE_NEW_PIZZA: {
return Object.assign({}, defaultState, { id: uuid() })
}
case PizzaActions.UPDATE_PIZZA: {
let updatedIngredient = {}
const currentSelection = state.ingredients[state.step]
if (currentSelection instanceof Array && action.payload.checked) {
updatedIngredient[state.step] = [ ...currentSelection, action.payload.value ]
} else if (currentSelection instanceof Array && !action.payload.checked) {
updatedIngredient[state.step] = currentSelection.filter(i => i !== action.payload.value)
} else {
updatedIngredient[state.step] = action.payload.value
}
const ingredients = Object.assign({}, state.ingredients, updatedIngredient)
let price = 7.99 + ingredients.meat.length * 1.99 + ingredients.veggies.length * 0.99
switch (ingredients.cheese) {
case 'None': price -= 1.70; break
case 'Light': price -= 0.85; break
case 'Extra': price += 1.30; break
}
if (ingredients.crust === 'Gluten Free') {
price += 2.50
}
return Object.assign({}, state, { ingredients, price })
}
case PizzaActions.NEXT_STEP: {
const index = steps.indexOf(state.step) + 1
const step = steps[Math.min(index, steps.length - 1)]
return Object.assign({}, state, { step })
}
case PizzaActions.PREVIOUS_STEP: {
const index = steps.indexOf(state.step) - 1
const step = steps[Math.max(index, 0)]
return Object.assign({}, state, { step })
}
default: return state
}
}
开发者ID:carlospaelinck,项目名称:Angular2-Demo,代码行数:49,代码来源:pizza.ts
示例2: expect
test('getDeviceInvalidQueryInvalidDeviceId', async () => {
const getDeviceVariablesInvalidDeviceId = {
deviceId: uuidv4(),
}
await expect(gqlRequest(getDeviceInvalidQuery, getDeviceVariablesInvalidDeviceId)).rejects.toThrow()
});
开发者ID:adamjq,项目名称:typescript-appsync-graphql,代码行数:7,代码来源:testAppsync.ts
示例3: test
test('a delivery confirmation is built', async function(assert) {
assert.expect(5);
const me = getService<CurrentUserService>('currentUser');
await me.exists();
const store = getService<StoreService>('store');
const service = getService<AutoResponder>('messages/auto-responder');
const sender = await createContact('some user');
const receivedMessage = store.createRecord('message', {
id: uuid(),
sender,
body: 'test message',
});
stubService('messages/dispatcher', {
sendToUser: {
perform(response: Message, to: Identity) {
assert.equal(response.target, TARGET.MESSAGE);
assert.equal(response.type, TYPE.DELIVERY_CONFIRMATION);
assert.equal(response.to, receivedMessage.id);
assert.equal(response.sender, me.record);
assert.equal(to.publicKey, sender.publicKey);
},
},
});
service.messageReceived(receivedMessage);
});
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:31,代码来源:unit-test.ts
示例4: uuid
.get('/fetchInfo', ctx => {
const { user } = ctx.session
let sessionID
if (!user) {
sessionID = uuid()
ctx.session.uuid = sessionID
}
ctx.body = {
user: user || {
uuid: sessionID,
},
envs: ENV_KEYS.reduce((envs, key) => {
let value: string | string[] = process.env[key]
if (STR_ARR_ENV_KEYS.includes(key)) {
value = value ? value.split(',') : []
}
return Object.assign(envs, {
[key]: process.env[key],
})
}, {}),
}
})
开发者ID:JounQin,项目名称:blog,代码行数:26,代码来源:index.ts
示例5: build
private build(attributes = {}) {
return this.store.createRecord('message', {
id: uuid(),
sentAt: new Date(),
from: this.currentUser.uid,
sender: this.currentUser.record,
...attributes,
});
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:9,代码来源:factory.ts
示例6: ngOnInit
ngOnInit() {
this.userToken = this.cookieService.get('userToken');
if (!this.userToken) {
this.userToken = uuid();
const date = new Date();
date.setTime(date.getTime() + (5000 * 24 * 60 * 60 * 1000));
this.cookieService.set('userToken', this.userToken, date);
}
}
开发者ID:gsuveti,项目名称:primeng-material,代码行数:9,代码来源:dev-playground.component.ts
示例7: Error
fieldResolver: ((source, _args, _context, info) => {
const pathAsArray = responsePathAsArray(info.path)
if (pathAsArray.length === 1) {
// source is null for root fields
source = source || (info.operation.operation === "mutation" ? mockMutationResults : mockData)
}
// fail early if source is not an object type
// this happens because graphql only checks for null when deciding
// whether to resolve fields in a given value
if (typeof source !== "object") {
const parentPath = pathAsArray.slice(0, -1).join("/")
throw new Error(`The value at path '${parentPath}' should be an object but is a ${typeof source}.`)
}
// handle aliased fields first
const alias = info.fieldNodes[0].alias
if (alias && alias.value in source) {
return inferUnionOrInterfaceType(checkLeafType(source[alias.value], info), info)
}
// the common case, the field has a fixture and is not aliased
if (info.fieldName in source) {
return inferUnionOrInterfaceType(checkLeafType(source[info.fieldName], info), info)
}
if (info.fieldName === "__id" || info.fieldName === "id") {
// if relay is looking for `__id` but we only supplied `id`
if ("id" in source) {
return source.id
}
// relay is looking for an id to denormalize the fixture in the store
// but we don't want to have to specify ids for all fixtures
// so generate one and store it in a weak map so we don't mutate
// the object itself
if (idMap.has(source)) {
return idMap.get(source)
}
const id = uuid()
idMap.set(source, id)
return id
}
throw error(
info,
({ type, path }) => `A mock for field at path '${path}' of type '${type}' was expected but not found.`
)
}) as GraphQLFieldResolver<any, any>,
开发者ID:artsy,项目名称:emission,代码行数:50,代码来源:index.ts
示例8: gqlRequest
test('getDeviceAndMessagesValidQueryDoesNotExist', async () => {
const getDeviceVariablesInvalidDeviceId = {
deviceId: uuidv4(),
}
const expectedNullResponse = {
"getDevice": null
}
return gqlRequest(getDeviceAndMessagesQuery, getDeviceVariablesInvalidDeviceId)
.then(result => {
expect(result).toEqual(expectedNullResponse)
})
});
开发者ID:adamjq,项目名称:typescript-appsync-graphql,代码行数:15,代码来源:testAppsync.ts
示例9: showNotification
function* showNotification(title, uuids) {
//Show a toastr notification. Return its notifyId
//Select vm names from store by uuids
const selector = (state) => state.get('app').get('vm_data');
const vm_data_map = yield select(selector);
const names = uuids.map(uuid => vm_data_map.get(uuid).name_label);
//Set up notification options
const options = {
id: uuid(),
type: 'info',
timeOut: 0,
title,
message: names.join('\n'),
options: {
showCloseButton: true,
}
};
yield put(actions.add(options));
return options.id;
}
开发者ID:,项目名称:,代码行数:20,代码来源:
注:本文中的UUID.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论