當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript edit.setProperty函數代碼示例

本文整理匯總了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)
                })
            )
        }
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:28,代碼來源:settings.ts

示例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 }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:7,代碼來源:configHelpers.ts

示例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)],
    }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:9,代碼來源:configHelpers.ts

示例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 }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:9,代碼來源:configHelpers.ts

示例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 }
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:9,代碼來源:configHelpers.ts


注:本文中的@sqs/jsonc-parser/lib/edit.setProperty函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。