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

labor-standards-tw

v0.1.0

Published

Utility for Taiwan labor standards acts

Downloads

1

Readme

labor-standards-tw

台灣勞動基準法的函式庫,可用於計算加班費、特休假、確認班表是否違法等。

開發環境

本專案使用 node.js v6 LTS,如果你有許多專案使用不同版本的 node.js,推薦你使用 nvm

如何使用

首先可以使用 npm 安裝本函式庫:

npm install g0v/labor-standards-tw --save

安裝後,在 node.js 環境底下可以用 require() 引入函示庫,如在瀏覽器環境,可以用 webpack 後使用 import 語法引入:

// for Node.js
const {Labor, WorkTime} = require('labor-standards-tw')

// for Webpack
import {Labor, WorkTime} from 'labor-standards-tw'

Labor class

Labor 類別是本函式庫的基礎,所有功能都圍繞著這個類別。它可以用來設定一個勞工的就職日、月薪、年齡等條件。

import { Labor, Gender } from 'labor-standards-tw'

// 一個 20 歲的女性勞工於 2017/3/20 就職,月薪為 24000 元
const labor = new Labor()
labor.setGender(Gender.FEMALE)
     .setAge(20)
     .onBoard(new Date(2017, 4, 20))
     .setMonthlySalary(24000)

Labor 類別有兩種類型的 methods,第一種是如上述的一些 setter / getter 可以設定基本資訊,另外一種是依據這些基本資訊計算出更進一步的資訊,第二種類型的 methods 都會回傳 Result 類別

import { Labor, ChildLaborType } from 'labor-standards-tw'

const labor = new Labor().setAge(15)

// 驗證勞工是否為童工身分
let result = labor.validateChildLabor()

// 根據勞動基準法 44 條,此勞工為合法的童工身分
expect(result.value.legal).eq(true)
expect(result.value.type).eq(ChildLaborType.CHILD_LABOR)
let article = result.according[0]
expect(article.lawTitle).eq('勞動基準法')
expect(article.id).eq('44')

// 如果勞工年齡為 14 歲
result = labor.setAge(14).validateChildLabor()

// 非法
expect(result.value.legal).eq(false)

// 身分為非法勞工
expect(result.value.type).eq(ChildLaborType.ILLEGAL)

// 違反勞基法 44 條
article = result.violations[0]
expect(article.lawTitle).eq('勞動基準法')
expect(article.id).eq('44')

// 有三種可能性的罰則
// 1. 罰款 300,000 以下
// 2. 拘役 6 個月以下
// 3. 前面兩者加起來
const penalty = article.penalize()
expect(penalty.article.id).eq('77')
expect(penalty.possibilities.length).eq(3)

更詳細的用法,請參考程式內的 jsdoc 註解,或是 cucumber 的 測試案例

如何貢獻

如果你發現程式碼有錯誤,或任何需要改進的地方,請到 issues 頁面開一個新的 issue。

若要提交你的修改,請送 pull request 到本專案,travis-ci 上面會有基本的語法與 coding style 檢查後,接著經由團隊成員審核後就會將您的變更合併入專案當中。

關於 cucumber 的測試方式,請參考 test.md

相關資訊

授權

本專案依照 MIT 授權 釋出,若需使用請確保您的使用方式符合 MIT 授權。