本文整理汇总了TypeScript中lodash.uniqueId函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniqueId函数的具体用法?TypeScript uniqueId怎么用?TypeScript uniqueId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniqueId函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should work', done => {
const user = {
id: parseInt(_.uniqueId(), 10),
accountName: 'test-oauth-tokens-accountName'
};
const testClient = {
clientId: 'test-oauth-tokens-save-and-get-token',
clientSecret: 'secret',
name: 'test-oauth-tokens-save-and-get-token name',
description: null,
redirectUri: 'http://example.com'
};
const accessTokenValue = _.uniqueId('testAccessToken');
ClientStorage
.deleteAllClientsExtremelyUnsafePrepareToSuffer()
.then(() => ClientStorage.createClient(testClient))
.then(() => TokenStorage.saveAccessToken(accessTokenValue, testClient.clientId, null, user))
.then(() => TokenStorage.getAccessToken(accessTokenValue))
.then((retrievedAccessToken: TokenInfo) => {
expect(retrievedAccessToken).to.be.not.null;
expect(retrievedAccessToken.token).to.be.equal(accessTokenValue);
expect(retrievedAccessToken.user).to.be.eql(user);
expect(retrievedAccessToken.expires).to.be.null;
})
.then(done);
});
示例2: PathLayer
const nodeToLayerDataFn = (node: Node): Layer => {
if (!isElement(node)) {
return undefined;
}
if (node.tagName === 'path') {
return new PathLayer({
id: _.uniqueId(),
name: makeFinalNodeIdFn(node.getAttribute('android:name'), 'path'),
children: [],
pathData: getPath(node),
fillColor: getColor(node, 'fillColor', ''),
fillAlpha: getNumber(node, 'fillAlpha', '1'),
strokeColor: getColor(node, 'strokeColor', ''),
strokeAlpha: getNumber(node, 'strokeAlpha', '1'),
strokeWidth: getNumber(node, 'strokeWidth', '0'),
strokeLinecap: get(node, 'strokeLineCap', 'butt') as StrokeLineCap,
strokeLinejoin: get(node, 'strokeLineJoin', 'miter') as StrokeLineJoin,
strokeMiterLimit: getNumber(node, 'strokeMiterLimit', '4'),
trimPathStart: getNumber(node, 'trimPathStart', '0'),
trimPathEnd: getNumber(node, 'trimPathEnd', '1'),
trimPathOffset: getNumber(node, 'trimPathOffset', '0'),
fillType: get(node, 'fillType', 'nonZero') as FillType,
});
}
if (node.tagName === 'clip-path') {
return new ClipPathLayer({
id: _.uniqueId(),
name: makeFinalNodeIdFn(get(node, 'name', ''), 'clip-path'),
children: [],
pathData: getPath(node),
});
}
if (node.childNodes.length) {
const children = Array.from(node.childNodes)
.map(child => nodeToLayerDataFn(child))
.filter(child => !!child);
if (children && children.length) {
return new GroupLayer({
id: _.uniqueId(),
name: makeFinalNodeIdFn(get(node, 'name', ''), 'group'),
children,
pivotX: getNumber(node, 'pivotX', '0'),
pivotY: getNumber(node, 'pivotY', '0'),
rotation: getNumber(node, 'rotation', '0'),
scaleX: getNumber(node, 'scaleX', '1'),
scaleY: getNumber(node, 'scaleY', '1'),
translateX: getNumber(node, 'translateX', '0'),
translateY: getNumber(node, 'translateY', '0'),
});
}
}
return undefined;
};
示例3: function
export default function(state: State = [], action: Action): State {
switch (action.type) {
case 'ADD_GLOBAL_MESSAGE':
return [{ id: action.id, message: action.message, level: action.level }];
case 'REQUIRE_AUTHORIZATION':
// FIXME l10n
return [
{
id: uniqueId('global-message-'),
message:
'You are not authorized to access this page. ' +
'Please log in with more privileges and try again.',
level: MessageLevel.Error
}
];
case 'CLOSE_GLOBAL_MESSAGE':
return state.filter(message => message.id !== action.id);
case 'CLOSE_ALL_GLOBAL_MESSAGES':
return [];
default:
return state;
}
}
示例4: parseInt
const addUsers = (count, knex, date) => {
count = parseInt(count)
const rows = []
for (let i = 0; i < count; i++) {
const channel = _.sample(channels)
const id = _.uniqueId()
const first_name = { key: 'first_name', value: generateName(), type: 'string' }
const last_name = { key: 'last_name', value: generateName(), type: 'string' }
const gender = { key: 'gender', value: Math.random() < vary(0.65, 0.35) ? 'male' : 'female', type: 'string' }
const locale = { key: 'locale', value: _.sample(['en_US', 'fr_CA', 'en_CA']), type: 'string' }
const timezone = { key: 'timezone', value: _.random(-6, 12, false), type: 'string' }
const user = {
user_id: id,
channel: channel,
attributes: JSON.stringify([first_name, last_name, gender, locale, timezone]),
created_at: date
}
users.push(user)
rows.push(user)
}
return knex.batchInsert('srv_channel_users', rows, 20).then(() => console.log('Added', count, 'users'))
}
示例5: if
_.forEach(object, (value, key) => {
if (_.isFunction(value)) {
const id = _.uniqueId('CARTE_BLANCHE_FUNCTION_');
functionStore[id] = value.toString();
object[key] = id; // eslint-disable-line no-param-reassign
} else if (_.isObject(value)) {
extractAndReplaceFunctions(value);
}
});
示例6: constructor
constructor(panel: Object) {
this.datasource = panel['datasource'];
this.id = panel['id'];
this.scopedVars = panel['scopedVars'];
this.targets = panel['targets'];
this.title = panel['title'];
this.uid = _.uniqueId();
this.thresholds = this.getThresholds(panel);
};
示例7: createTestServer
export default function createTestServer() {
logger.level = 'warn';
const server = ServerFactory.createServer({
configFileName: path.resolve(__dirname, '../config/config.tests.json')
});
nconf.set('devModeFakeUserIdToSkipAuthentication', _.uniqueId());
return server;
}
示例8: it
it('should build for proxied configuration', () => {
const configuration = {
resolver: AccountInfo.AccountResolver.TpOndemandCom,
targetprocessAuthorizationProxyPath: '/oauth/authorize',
useRequestHostNameForTpLoginReturnUrl: false
};
const testAccountName = _.uniqueId('testAccountName-');
const currentRequestUrl = 'http://unused:1234/unusedAsWell?foo=1&bar=2';
const returnUrl = AccountInfo.buildTargetprocessAuthReturnUrl(configuration, testAccountName, currentRequestUrl);
expect(returnUrl).to.be.equal(`http://${testAccountName}.tpondemand.com/oauth/authorize?foo=1&bar=2`);
});
示例9: startTimer
startTimer(): number {
if (!this.proccessing) {
console.log('Start Timer');
this.proccessing = true;
this.startTime = lodash.now();
this.filterId = '' + this.startTime + lodash.uniqueId();
this.endTime = null;
this.textFinished = null;
}
return this.startTime;
}