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

TypeScript task.node函数代码示例

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

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



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

示例1: destroyAllOfAuthIdImpl

/**
 * Destroy / delete all sessions of the given auth Id
 */
function destroyAllOfAuthIdImpl(storage: RedisStorage, authId: AuthId): T.Task<void> {
  const redis = storage.redis;
  return T.node(redis, storage.authKey(authId), redis.smembers)
    .map((refs: string[]) => {
      redis.del([authId].concat(refs) as any);
    });
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:10,代码来源:index.ts


示例2: it

 it('200 and etag when no etag query parameters', async () => {
   const stat = await T.toPromise(T.node(null, path.join(__dirname, 'fixture', 'attic', 'a'), fs.stat));
   const extag = await T.toPromise(defaultEtag(stat, true));
   const req = new IncomingMessageMock({ url: '/attic/a' });
   await T.toPromise(request(staticTest, req).map(resp => {
     assert.equal(resp.status, 200);
     assert.equal(resp.headers['ETag'], (extag as any).value);
   }));
 });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:static.test.ts


示例3: it

  it('can move file upload to target dir', async function () {
    const middleware = mutter({ getStorage });
    const form = new FormData();

    form.append('name', 'thatiq');
    form.append('tiny0', file('tiny0.json'));

    const { state } = await T.toPromise(submitForm(middleware, form));
    const dest = await T.toPromise(T.node(null, temp.mkdir));
    const files: Files = state.files;
    const target = path.join(dest, 'tiny-uploaded.json');
    await T.toPromise(files['tiny0'][0].move(target));
    const [targetStat, sourceStat] = await T.toPromise(T.bothPar(
      T.node(null, target, fs.stat),
      T.node(null, path.join(__dirname, 'fixtures', 'tiny0.json'), fs.stat)
    ));
    assert.equal(targetStat.size, sourceStat.size);
    await T.toPromise(T.node(null, dest, rimraf));
  });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:19,代码来源:disk-storage.ts


示例4: getFileInfo

export function getFileInfo(path: string): T.Task<FileInfo> {
  return T.node(null, path, FS.stat)
    .chain(stat => {
      if (stat.isFile()) {
        let time = H.fromDate(stat.mtime);
        let date = H.formatHttpDate(time);
        return T.pure(new FileInfo(path, stat.size, time, date));
      }
      return T.raise(new Error(`getInfo: ${path}  isn't a file`));
    });
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:11,代码来源:file-info.ts


示例5: listenConnection

function listenConnection(
  state: ServerState,
  sett: Z.Settings
): T.Task<void> {
  const listenOpts = sett.listenOpts;
  const server = state.server as Server | HServer;
  if (listenOpts.path) {
    return bindConnectionUnix(listenOpts.path, listenOpts.permission || '660', listenOpts, server);
  }
  return T.node(server, listenOpts, server.listen);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:11,代码来源:run.ts


示例6: withFdCache

 T.supervise(T.co(function* () {
   let fdRef: R.Ref<number> = yield R.newRef(-1);
   yield withFdCache(3000, getFd =>
     getFd(0)(path.join(__dirname, '..', 'package.json')).chain(fd =>
       R.writeRef(fdRef, (fd[0] as any).value))
   );
   let fd: number = yield R.readRef(fdRef);
   return T.attempt(T.node(null, fd, fs.readFile)).chain(mcont => {
     assert.ok(isLeft(mcont));
     return T.pure(void 0);
   });
 }))
开发者ID:syaiful6,项目名称:jonggrang,代码行数:12,代码来源:fd-cache.test.ts


示例7: bindConnectionUnix

function bindConnectionUnix(
  path: string,
  permission: number | string,
  listenOpts: Z.ListenOpts,
  server: Server | HServer
): T.Task<void> {
  return T.apathize(T.node(null, path, FS.unlink))
    .chain(() =>
      T.node(server, listenOpts, server.listen)
    ).chain(() =>
      T.forkTask(T.node(null, path, permission, FS.chmod))
    ) as T.Task<any>;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:13,代码来源:run.ts


示例8: fileSystemLookup

export function fileSystemLookup(
  etagFn: EtagLookup,
  prefix: string,
  pieces: Piece[],
  weakEtags: boolean
): T.Task<LookupResult> {
  const fp = pathFromPieces(prefix, pieces);
  return T.attempt(T.node(null, fp, fs.stat))
    .chain(estat => {
      if (isLeft(estat))
        return T.pure({ tag: LookupResultType.LRNOTFOUND } as LookupResult);

      const { value: stat } = estat;
      if (stat.isFile()) {
        return T.pure(mkLookupResult(LookupResultType.LRFILE, mkFile(
          stat.size,
          (s, h) => W.responseFile(s, h, fp),
          pieces.length === 0 ? '' : pieces[pieces.length - 1],
          etagFn(stat, weakEtags),
          just(stat.mtime)
        )));
      }

      return T.node(null, fp, fs.readdir)
        .chain(entries_ => {
          const entries = entries_.filter(isVisible);
          return T.forIn(entries, frel => {
            const fpAbs = path.join(fp, frel);
            return T.attempt(T.node(null, fpAbs, fs.stat))
              .map(estate => {
                if (isLeft(estate)) {
                  return nothing as Maybe<Either<string, File>>;
                }
                const stat = estate.value;
                if (stat.isDirectory()) {
                  return just(left(frel)) as Maybe<Either<string, File>>;
                }

                // file
                return just(right(mkFile(
                  stat.size,
                  (s, h) => W.responseFile(s, h, fpAbs),
                  frel,
                  etagFn(stat, weakEtags),
                  just(stat.mtime)
                ))) as Maybe<Either<string, File>>;
              });
          }).map(xs => mkLookupResult(LookupResultType.LRFOLDER, catMaybes(xs)));
        });
    });
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:51,代码来源:fs.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript task.pure函数代码示例发布时间:2022-05-28
下一篇:
TypeScript task.makeTask_函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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