项目作者: Swizz

项目描述 :
A 400 bytes console.{log,info,warn,error,...} that return its last argument
高级语言: TypeScript
项目地址: git://github.com/Swizz/identity-log.git
创建时间: 2017-06-16T08:20:45Z
项目社区:https://github.com/Swizz/identity-log

开源协议:

下载


Identity-log


A 400 bytes console.{log,info,warn,…} that return its last argument



Table of Contents


Table of Contents

- Getting started
- Usage
- Misc

Getting started

  • 1. To use identity-log you need to download it thanks to your favorite JavaScript Package Manager.

    1. yarn add identity-log
    1. npm install --save identity-log
  • 2. Then you are free to import all the exported logging functions.

    1. import { error, log, warn } from 'identity-log'
  • 3. You can use them directly by surrounding the returned value without worrying.

    1. const add = (a, b) => log(a + b)
    2. add(1, 2) // => 3

Usage

Identity-log aim to be less impacting as possible on the function, less bytes and better perf ; and handle all the console api.

  • assert
  • dir
  • error
  • info
  • log
  • trace
  • warn

tap

Identity-log also provide a tap function that allow you to create your own transformation from a function that return void to a function that return its last argument.

The tap function can be used for function composition too.

  1. tap(console.log, 1, 2, 3) // => 3
  2. const log = tap(console.log)
  3. log(1, 2, 3) // => 3

Misc