• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Option.some函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fp-ts/lib/Option.some函数的典型用法代码示例。如果您正苦于以下问题:TypeScript some函数的具体用法?TypeScript some怎么用?TypeScript some使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了some函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createDecoration

 private async createDecoration(currentDecoration: Decoration, item: DecorationUpdateActionQuickPickItem): Promise<Option<Decoration>> {
     this.telemetryReporter.logHighlightUpdated(item.actionId);
     switch (item.actionId) {
         case DecorationAction.TOGGLE_CASE_SENSITIVITY:
             return some(currentDecoration.withCaseSensitivityToggled());
         case DecorationAction.TOGGLE_WHOLE_MATCH:
             return some(currentDecoration.withWholeMatchToggled());
         case DecorationAction.UPDATE_PHRASE: {
             const options = {
                 value: currentDecoration.pattern.phrase,
                 prompt: 'Enter a new pattern.'
             };
             const newPhraseOpt = await this.windowComponent.showInputBox(options);
             return newPhraseOpt.map(newPhrase => currentDecoration.withPhrase(newPhrase));
         }
         case DecorationAction.UPDATE_COLOUR: {
             const options = {
                 value: currentDecoration.colour,
                 prompt: 'Enter a new color.'
             };
             const newPhraseOpt = await this.windowComponent.showInputBox(options);
             return newPhraseOpt.map(newColour => currentDecoration.withColour(newColour));
         }
     }
 }
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:25,代码来源:decoration-variation-reader.ts


示例2: test

 test('it deregisters a decoration id and their positions', () => {
     const decorationId = registry.queryDecorationId('EDITOR_ID', range(1, 1));
     assert.deepEqual(decorationId, some('DECORATION_ID'));
     registry.deregister('DECORATION_ID');
     const decorationId2 = registry.queryDecorationId('EDITOR_ID', range(1, 1));
     assert.deepEqual(decorationId2, none);
 });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:7,代码来源:text-location-registry.test.ts


示例3: test

    test('it lets user to select which level they want to save a config', async () => {
        const windowComponent = mock(WindowComponent);
        when(windowComponent.showQuickPick(
            [{
                label: 'Global',
                value: true
            }, {
                label: 'Workspace',
                value: false
            }],
            {placeHolder: 'Select which scope of settings to save highlights to'}
        )).thenResolve(some({label: 'Global', value: true}));

        const picker = new ConfigTargetPicker(windowComponent);

        assert.deepEqual(await picker.pick(), some(true));
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:17,代码来源:config-target-picker.test.ts


示例4: test

    test('it registers a pattern and returns registry information', () => {
        const registry = createDecorationRegistry();

        const pattern = createPattern('PATTERN');
        assert.deepEqual(registry.issue(pattern), some({
            id: 'UUID_1',
            colour: pink,
            pattern
        }));
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:10,代码来源:decoration-registry.test.ts


示例5: test

    test('it lets user to pick a highlight pattern', async () => {
        const windowComponent = mock(WindowComponent);
        when(windowComponent.showQuickPick(
            [
                {label: 'TEXT_1', detail: 'String', decoration: decoration1},
                {label: '/TEXT_2/i', detail: 'RegExp', decoration: decoration2}
            ],
            {placeHolder: 'PLACEHOLDER_MESSAGE'}
        )).thenResolve(some({
            label: 'TEXT_1', detail: 'String', decoration: decoration1
        }));
        const decorationRegistry = mock(DecorationRegistry);
        when(decorationRegistry.retrieveAll()).thenReturn([decoration1, decoration2]);

        const picker = new DecorationPicker(decorationRegistry, windowComponent);
        const decoration = await picker.pick('PLACEHOLDER_MESSAGE');

        assert.deepEqual(decoration, some(decoration1));
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:19,代码来源:decoration-picker.test.ts


示例6: test

        test('it removes a decoration', () => {
            const decorationRegistry = mock(DecorationRegistry);
            when(decorationRegistry.inquireById('DECORATION_ID')).thenReturn(some(decoration));
            const textDecorator = mock(TextDecorator);
            const operator = new DecorationOperator(editors, decorationRegistry, textDecorator);

            operator.removeDecoration('DECORATION_ID');

            verify(decorationRegistry.revoke('DECORATION_ID'));
            verify(textDecorator.undecorate(editors, ['DECORATION_ID']));
        });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:11,代码来源:decoration-operator.test.ts


示例7: setup

    setup(() => {
        extensionConfig = mockMethods<vscode.WorkspaceConfiguration>(['get', 'update']);
        when(extensionConfig.get('CONFIG_NAME')).thenReturn('CONFIG_VALUE');

        const workspace = mockMethods<typeof vscode.workspace>(['getConfiguration']);
        when(workspace.getConfiguration('textmarker')).thenReturn(extensionConfig);

        const configTargetPicker = mock(ConfigurationTargetPicker);
        when(configTargetPicker.pick()).thenResolve(some('CONFIG_TARGET'));

        configStore = new ConfigStore(workspace, configTargetPicker);
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:12,代码来源:config-store.test.ts


示例8: suite

    suite('When the cursor is on highlight', () => {

        const editor = mockType<TextEditor>({id: 'EDITOR_ID', selectedText: 'SELECTED', selection: registeredRange});

        const pattern = mock(StringPattern);
        const oldDecoration = new Decoration('DECORATION_ID', pattern, 'pink');
        const newDecoration = new Decoration('DECORATION_ID', pattern, 'yellow');

        const decorationRegistry = mock(DecorationRegistry);
        when(decorationRegistry.inquireById('DECORATION_ID')).thenReturn(some(oldDecoration));

        let decorationOperator: DecorationOperator;
        let decorationOperatorFactory: DecorationOperatorFactory;

        setup(() => {
            const deps = createDecorationOperator();
            decorationOperator = deps.decorationOperator;
            decorationOperatorFactory = deps.decorationOperatorFactory;
        });

        test('it updates decoration', async () => {
            const patternVariationReader = mock(DecorationVariationReader);
            when(patternVariationReader.read(oldDecoration)).thenResolve(some(newDecoration));

            const command = new UpdateHighlightCommand(
                decorationOperatorFactory,
                decorationRegistry,
                patternVariationReader,
                textLocationRegistry
            );

            await command.execute(editor);

            verify(decorationOperator.updateDecoration(oldDecoration, newDecoration));
        });

        test('it does nothing if a new pattern is not given by user', async () => {
            const patternVariationReader = mock(DecorationVariationReader);
            when(patternVariationReader.read(any())).thenResolve(none);

            const command = new UpdateHighlightCommand(
                decorationOperatorFactory,
                decorationRegistry,
                patternVariationReader,
                textLocationRegistry
            );

            await command.execute(editor);

            verify(decorationOperator.updateDecoration(any(), any()), {times: 0});
        });
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:52,代码来源:update-highlight.test.ts



注:本文中的fp-ts/lib/Option.some函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript framer.animate类代码示例发布时间:2022-05-25
下一篇:
TypeScript Array.findFirst函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap