当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Option.some函数代码示例

本文整理汇总了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;未经允许,请勿转载。