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


TypeScript bluebird.reject函数代码示例

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


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

示例1: Error

        return this.tokenRepository.findBy({token: token.token}).then((fulfilled) => {
            if (isNullOrUndefined(fulfilled)) {
                return Promise.reject(new Error(errorMessages.userIsNotLogged));
            }

            if (token.expiredDate.getTime() > new Date().getTime()) {
                return Promise.resolve(this.userRepository.findBy({_id: fulfilled!.user}));
            }

            return Promise.reject(new Error(errorMessages.tokenExpired));
        }).then((fulfilled) => {
开发者ID:dominikus1993,项目名称:twitterClone,代码行数:11,代码来源:service.ts

示例2: Error

 return Promise.resolve(this.repository.findBy({_id: travel._id})).then((fullfiled: Travel[]) => {
     if (!R.isEmpty(fullfiled)) {
         const travelToRm = R.head(fullfiled);
         if ((travelToRm.owner as any)._id === (user._id as any)) {
             return Promise.resolve(travelToRm);
         } else {
             return Promise.reject(getError(new Error("Unathorized access")));
         }
     } else {
         return Promise.reject(getError(new Error("Can't find travel")));
     }
 }).then((fullfiled: Travel) => {
开发者ID:dominikus1993,项目名称:TravelAssistantNode,代码行数:12,代码来源:service.ts

示例3:

        .then(clientInfo => {
            if (!clientInfo) {
                return Promise.reject<number>('Client with specified clientId does not exist');
            }

            return clientInfo.id;
        });
开发者ID:itsuryev,项目名称:tp-oauth-server,代码行数:7,代码来源:tokenStorage.ts

示例4: it

            it('shows error on failure', function (done) {
                const statusCode = 404;
                const url = '/api/tribes';
                const expectedData = 'nonsense';

                const getSpy = spyOn(axios, 'get')
                    .and.returnValue(Bluebird.reject(
                        {
                            response: {status: statusCode, data: expectedData}
                        }
                    ));

                let callCount = 0;

                Coupling.getTribes()
                    .then(function () {
                        callCount++;
                    })
                    .catch(function (error) {
                        expect(getSpy).toHaveBeenCalledWith(url);
                        expect(error).toBeDefined();
                        expect(error.response.status).toBe(statusCode);
                        expect(error.response.data).toBe(expectedData);
                        done();
                    });
            });
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:26,代码来源:services.spec.ts

示例5: return

 return () => {
     if (numFailuresRemaining > 0) {
         --numFailuresRemaining;
         return Promise.reject(rejectValue);
     }
     return Promise.resolve(resolveValue);
 };
开发者ID:kwpeters,项目名称:node-sandbox,代码行数:7,代码来源:retry.spec.ts

示例6: writeSingleCoil

    writeSingleCoil(slave: number, address: number, value: boolean):Promise<Buffer>  {
        if (this.state != State.Opened) {
            return Promise.reject("Invalid state", {state: this.state} );
        } 

        var buffer = Buffer.alloc(8, 0);
        buffer[0] = slave;
        buffer[1] = 0x05; //function code
         
        buffer[2] = (address & 0xff00) >> 8;
        buffer[3] = address & 0x00ff;

        //Write 0xFF00 to enable, 0x0000 to disable
        //value to write
        if (value) {
            buffer[4] = 0xff;
        }

        //FIXME: Not needed, as we already set o by default
        //buffer[5] = 0x00;

        var crc = crc16_modbus(buffer, buffer.length - 2);

        buffer[buffer.length - 2] = crc & 0x00ff;
        buffer[buffer.length - 1] = (crc & 0xff00) >> 8;
        
        var __this = this;
        //slave (1), FC (1), Address (2), value writen (2) crc (2)
        var expectedDataCount = 8;
        
        return this.addToTaskQueue(buffer, expectedDataCount);
    }
开发者ID:nodesense,项目名称:nodesense-modbus-serial,代码行数:32,代码来源:modbus-serial.ts

示例7: writeSingleRegister

    writeSingleRegister(slave: number, address: number, value: number):Promise<Buffer>  {
        if (this.state != State.Opened) {
            return Promise.reject("Invalid state", {state: this.state} );
        }
        
        var buffer = Buffer.alloc(8, 0);
        buffer[0] = slave;
        buffer[1] = 0x06; //function code
         
        buffer[2] = (address & 0xff00) >> 8;
        buffer[3] = address & 0x00ff;

        //value to write
        buffer[4] = (value & 0xff00) >> 8;
        buffer[5] = value & 0x00ff;
  
        var crc = crc16_modbus(buffer, buffer.length - 2);

        buffer[buffer.length - 2] = crc & 0x00ff;
        buffer[buffer.length - 1] = (crc & 0xff00) >> 8;
       
         //slave (1), FC (1), Address (2), value writen (2) crc (2)
        var expectedDataCount = 8;
        
        return this.addToTaskQueue(buffer, expectedDataCount);

    }
开发者ID:nodesense,项目名称:nodesense-modbus-serial,代码行数:27,代码来源:modbus-serial.ts

示例8: readCoilsInternal

    readCoilsInternal(slave: number, functionCode :number, address: number, count: number):Promise<Buffer>  {
        if (this.state != State.Opened) {
            return Promise.reject("Invalid state", {state: this.state} );
        }
         

        var buffer = Buffer.alloc(8, 0);
        buffer[0] = slave;
        buffer[1] = functionCode; //function code
         
        buffer[2] = (address & 0xff00) >> 8;
        buffer[3] = address & 0x00ff;

        buffer[4] = (count & 0xff00) >> 8;
        buffer[5] = count & 0x00ff;
          
        var crc = crc16_modbus(buffer, 6);

        buffer[6] = crc & 0x00ff;
        buffer[7] = (crc & 0xff00) >> 8;


         //slave (1), function code (1), data bytes count (1), crc (2) + Math.ceil(count  / 8)
        var expectedDataCount = 5 + Math.ceil(count  / 8);
         
        return this.addToTaskQueue(buffer, expectedDataCount);
    }
开发者ID:nodesense,项目名称:nodesense-modbus-serial,代码行数:27,代码来源:modbus-serial.ts

示例9: writeMultipleRegisters

    writeMultipleRegisters(slave: number, address: number, dataBuffer: Buffer):Promise<Buffer>  {
        if (this.state != State.Opened) {
            return Promise.reject("Invalid state", {state: this.state} );
        }
        
        var buffer = Buffer.alloc(9 + dataBuffer.length, 0);
        buffer[0] = slave;
        buffer[1] = 16; //function code
         
        buffer[2] = (address & 0xff00) >> 8;
        buffer[3] = address & 0x00ff;

        //registers to write
        buffer[4] = ((dataBuffer.length / 2) & 0xff00) >> 8;
        buffer[5] = (dataBuffer.length / 2) & 0x00ff;

        //number of data bytes to follow
        buffer[6] = dataBuffer.length & 0x00ff;

 
        dataBuffer.copy(buffer, 7, 0);
   
        var crc = crc16_modbus(buffer, buffer.length - 2);

        buffer[buffer.length - 2] = crc & 0x00ff;
        buffer[buffer.length - 1] = (crc & 0xff00) >> 8;
        
         //slave (1), FC (1), Address (2), Registers Count (2) crc (2)
        var expectedDataCount = 8;
        
        return this.addToTaskQueue(buffer, expectedDataCount);
    }
开发者ID:nodesense,项目名称:nodesense-modbus-serial,代码行数:32,代码来源:modbus-serial.ts

示例10:

                server.register(plugin.module, plugin.options, (err) => {
                    if (err) {
                        return Promise.reject(err);
                    }

                    return Promise.resolve();
                });
开发者ID:richie5um,项目名称:hapiTemplate,代码行数:7,代码来源:index.ts


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