npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

skewertest

v0.0.1

Published

node-ttucsc 大同大學資訊創意研究社 node.js 課程

Downloads

2

Readme

Skewer

node-ttucsc 大同大學資訊創意研究社 node.js 第二堂課課程:npm + flow control - 自幹簡易 flow control module

  • npm 安裝/移除 module
  • package.josn
  • npm 發布 module
  • 常見 flow control 方法
  • 自幹簡易 flow control module

範例安裝

npm install skewer

用法

skewer()

正宗串燒阿...

用幾個 object 串起數個 function

skewer(function (err, obj) {
  console.log(obj);
})
  .add(function (obj, next) {
    obj.idiot = '馬囧';
    next();
  })
  .add(function (obj, next) {
    obj.idiot2 = '馬囧囧';
    next();
  })
  .run({});

skewer.chain()

鍊子!當前函式的參數由上一步的函式決定

skewer.chain(function (err, text) {
  console.log(b);
})
  .add(function (n, next) {
    next(null, 'xdd');
  })
  .add(function (a, b) {
    next(b);
  });

skewer.customs()

去你的海關,扣我 Geeksphone 這麼多的稅...

按照一開始函數傳入的變數名稱把結果排序並傳入函式

var emit = skewer.customs(function (error, text1, text2) {
  console.log(text1);
  console.log(text2);
});

setTimeout(function () {
  emit('text2', '馬囧');
}, 100);

setTimeout(function () {
  emit('text1', '123');
}, 200);

skewer.map()

把多個相似的異步處理寫在一起,最後把值按順序放入陣列

var square = {
  exponent: 2,
  calc: function (n, cb) {
    var val = Math.pow(n, this.exponent);
    setTimeout(function () {
      cb(null, val);
    }, 100);
  }
};
skewer.map([1, 2, 3], skewer.methodWrapper(square, square.calc), function (err, results) {
  results.toString().should.equal('1,4,9');
  done();
});

也可以傳入一些選項,像是 fs.readFile 可能會需要給 'utf8',如果有多個選項要設定,就按順序放在 'utf8' 後面

skewer.map(['./file1', './file2', './file3'], fs.readFile, 'utf8', function (err, results) {
  //...
});

skewer.filter()

把陣列值一個一個丟進 function 內執行,回傳結果再去跟設定的的值去作比對,最後只留下比對成功的值

選項設定方式跟 map 一樣

skewer.filter(['./file1', './file2', './file3'], fs.exists, true, function (results) {
  //...
});

License

(The MIT License)

Copyright (c) 2013 Po-Ying Chen