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

packhouse

v2.0.3

Published

Packhouse is a function wrapper based on the concept of functional programming

Downloads

23

Readme

Summary

完整教學文件

Packhouse是一個基於函數式程式設計(Functional Programming)的程式設計模型,其擁有以下特性:

  • 追蹤呼叫上下文
  • 真正的型態檢查
  • 管理與分類函式
  • 美麗的寫作規範
  • 建構後端服務的能力

開始前可以閱讀函數式編程指南了解基本觀念。


為何採用Packhouse?

  1. Packhouse開發可以建構統一的Input/Output接口。

  2. Packhouse的精神是建構微服務中的微服務,建立細微可控的函式能夠快速反應需求變更,且如果保持函數式編程的核心理念,便可以在專案破碎化的情況下複製模式到各個專案中。

  3. 並不是所有的專案都能運行TypeScript,而Packhouse是原生的JavaScript,不需要經由任何編譯就能執行。

  4. 編寫Cloud Function時將所有的邏輯編寫在一個檔案中難以應付頻繁的需求變更,物件導向開發在minify或編譯後難以除錯,雖然我們可以藉由單元測試來避免錯誤,但上線後會發生的事永遠比開發時離奇。


無伺服器架構 - Serverless

你不需要逐步建立服務,可以直接參考API Service章節。

無伺服器架構是Packhouse絕佳的運作平台:

Serverless Framework

AWS Serverless Application


安裝

npm i packhouse --save

運行環境

Node 8.x以上。

Packhouse並沒有強制必須於哪個環境下運作,它甚至允許於瀏覽器執行,但我們不會在乎瀏覽器兼容性。


First Function

以下是最低限度地執行程式:

const Packhouse = require('packhouse')
const packhouse = new Packhouse()
const group = {
    tools: {
        sum: {
            handler: (self, v1, v2) => self.success(v1 + v2)
        }
    }
}

packhouse.addGroup('math', () => {
    return {
        data: group
    }
})

packhouse
    .tool('math/sum')
    .action(10, 20, (error, result) => {
        console.log(result) // 30
    })

使用案例

Mess是為通勤族精心設計的閱讀網站,你可以在任何等待時間使用任何裝置隨時閱讀國外媒體或文章,並享受精心設計的使用者介面與翻譯、語音服務。


Versions

1.x與2.x的版本差異非常大,如果使用1.x請參照下列文件:

Guide

API Document