本文整理匯總了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 }
}