# 2019.11.14 今天是每日时报陪你的第 277 天

[文章] 带你手写微前端框架:https://juejin.im/post/5db4253451882556a035ae5d?utm_source=tuicool&utm_medium=referral (opens new window)

[文章] 图文讲解,TCP 为啥要 3 次握手和 4 次挥手?握两次手不行吗?:https://mp.weixin.qq.com/s?__biz=MzU2Njg3OTU1Mg==&mid=2247484969&idx=1&sn=dbe8ef6e6e711ddce55699a392a018b2 (opens new window)

[类库] dedent 可以从多行字符串模板中去除缩进的类库;在开发命令行工具时,需要有参数的 help 提示,这时就可以用到这个库解决缩进不一致的问题:https://github.com/dmnd/dedent (opens new window)

[类库] dashify 可以将驼峰风格的字符串转换成横线分割的字符串,很实用的功能:https://github.com/jonschlinkert/dashify (opens new window)

[工具] Postwoman 介绍,它是一个在线版的请求构建器,类似于 Postman:https://dev.to/liyasthomas/i-created-postwoman-an-online-open-source-api-request-builder-41md (opens new window)

# 配图 - 手写微前端

# 配图 - TCP

# 配图 - Postwoman

# 示例 - dedent

import dedent from "dedent";

function usageExample() {
  const first = dedent`A string that gets so long you need to break it over
                       multiple lines. Luckily dedent is here to keep it
                       readable without lots of spaces ending up in the string
                       itself.`;

  const second = dedent`
    Leading and trailing lines will be trimmed, so you can write something like
    this and have it work as you expect:

      * how convenient it is
      * that I can use an indented list
         - and still have it do the right thing

    That's all.
  `;

  const third = dedent(`
    Wait! I lied. Dedent can also be used as a function.
  `);

  return first + "\n\n" + second + "\n\n" + third;
}

# 示例 - dashify

var dashify = require('dashify');

console.log(dashify('fooBar'));
//=> 'foo-bar'

console.log(dashify('fooBarBaz'));
//=> 'foo-bar-baz'

console.log(dashify('foo bar'));
//=> 'foo-bar'

console.log(dashify('foo barBaz'));
//=> 'foo-bar-baz'

console.log(dashify('foo barBaz quux'));
//=> 'foo-bar-baz-quux'

console.log(dashify('São Tomé and Príncipe'));
//=> 'são-tomé-and-príncipe'
Last Updated: 11/14/2019, 2:45:23 PM