本文整理汇总了TypeScript中@sqs/jsonc-parser/lib/edit.setProperty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setProperty函数的具体用法?TypeScript setProperty怎么用?TypeScript setProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setProperty函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: applyEdits
storageItems => {
let clientSettings = storageItems.clientSettings
const format = { tabSize: 2, insertSpaces: true, eol: '\n' }
if ('edit' in args && args.edit) {
clientSettings = applyEdits(
clientSettings,
// TODO(chris): remove `.slice()` (which guards against
// mutation) once
// https://github.com/Microsoft/node-jsonc-parser/pull/12
// is merged in.
setProperty(clientSettings, args.edit.path.slice(), args.edit.value, format)
)
} else if ('extensionID' in args) {
clientSettings = applyEdits(
clientSettings,
typeof args.enabled === 'boolean'
? setProperty(clientSettings, ['extensions', args.extensionID], args.enabled, format)
: removeProperty(clientSettings, ['extensions', args.extensionID], format)
)
}
return new Promise<undefined>(resolve =>
storage.setSync({ clientSettings }, () => {
resolve(undefined)
})
)
}
示例2: setProperty
const addSlackWebhook: ConfigInsertionFunction = config => {
const value: SlackNotificationsConfig = {
webhookURL: 'get webhook URL at https://YOUR-WORKSPACE-NAME.slack.com/apps/new/A0F7XDUAZ-incoming-webhooks',
}
const edits = setProperty(config, ['notifications.slack'], value, defaultFormattingOptions)
return { edits, selectText: '""', cursorOffset: 1 }
}
示例3:
const addSAMLAuthProvider: ConfigInsertionFunction = config => {
const value: SAMLAuthProvider = {
type: 'saml',
identityProviderMetadataURL: '<see https://docs.sourcegraph.com/admin/auth/#saml>',
}
return {
edits: [...setProperty(config, ['auth.providers'], [value], defaultFormattingOptions)],
}
}
示例4: Sourcegraph
const addOtherRepository: ConfigInsertionFunction = config => {
const urlPlaceholder = '<git clone URL>'
const value: Repository = {
url: urlPlaceholder,
path: '<desired name of repository on Sourcegraph (example: my/repo)>',
}
const edits = setProperty(config, ['repos.list', -1], value, defaultFormattingOptions)
return { edits, selectText: urlPlaceholder }
}
示例5: scope
const addGitHubDotCom: ConfigInsertionFunction = config => {
const tokenPlaceholder = '<personal access token with repo scope (https://github.com/settings/tokens/new)>'
const value: GitHubConnection = {
token: tokenPlaceholder,
url: 'https://github.com',
}
const edits = setProperty(config, ['github', -1], value, defaultFormattingOptions)
return { edits, selectText: tokenPlaceholder }
}