Hefty

Results 107 issues of Hefty

本文为读 lodash 源码的第三百三十五篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 源码分析 `startsWith` 用来检测字符串 `string` 是否以 `target` 字符串开始,也可以指定开始检测的位置 `position` 。 源码如下: ```javascript function startsWith(string, target, position) { const { length } = string position =...

系列文章
api

本文为读 lodash 源码的第三百三十三篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import castSlice from './.internal/castSlice.js' import hasUnicode from './.internal/hasUnicode.js' import isRegExp from './isRegExp.js' import stringToArray from './.internal/stringToArray.js' ``` [《lodash源码分析之castSlice》](https://github.com/yeyuqiudeng/pocket-lodash/issues/310) [《lodash源码分析之hasUnicode》](https://github.com/yeyuqiudeng/pocket-lodash/issues/168) [《lodash源码分析之isRegExp》](https://github.com/yeyuqiudeng/pocket-lodash/issues/235) [《lodash源码分析之stringToArray》](https://github.com/yeyuqiudeng/pocket-lodash/issues/245) ##...

系列文章
api

本文为读 lodash 源码的第三百三十二篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import words from './words.js' import toString from './toString.js' ``` [《lodash源码分析之words》](https://github.com/yeyuqiudeng/pocket-lodash/issues/314) [《lodash源码分析之toString》](https://github.com/yeyuqiudeng/pocket-lodash/issues/252) ## 源码分析 `kebabCase` 用来将字符串转换成用 `_` 号连词的形式。 如将 `fooBar` 转换成 `foo_bar` 。...

系列文章
api

本文为读 lodash 源码的第三百三十一篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 源码分析 `replace` 和字符串的 `replace` 方法作用一样,没有其它特别的地方。 源码如下: ```javascript function replace(...args) { const string = `${args[0]}` return args.length < 3 ? string : string.replace(args[1], args[2]) }...

系列文章
api

本文为读 lodash 源码的第三百三十篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import root from './.internal/root.js' ``` [lodash源码分析之root](https://github.com/yeyuqiudeng/pocket-lodash/issues/126) ## 源码分析 `parseInt` 的作用和原生的 `parseInt` 是类似的,但是会对字符串开头部分的空格移除才会进行转换。 ```javascript const reTrimStart = /^\s+/ const nativeParseInt = root.parseInt function...

系列文章
api

本文为读 lodash 源码的第三百二十九篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import createPadding from './.internal/createPadding.js' import stringSize from './.internal/stringSize.js' ``` [lodash源码分析之createPadding](https://github.com/yeyuqiudeng/pocket-lodash/issues/327) [lodash源码分析之stringSize](https://github.com/yeyuqiudeng/pocket-lodash/issues/170) ## 源码分析 `padStart` 是在 `string` 的长度不足 `length` 的时候,在前面补全指定的字符串 `chars` ,得到一个长度为 `length`...

系列文章
api

本文为读 lodash 源码的第三百二十八篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import createPadding from './.internal/createPadding.js' import stringSize from './.internal/stringSize.js' ``` [lodash源码分析之createPadding](https://github.com/yeyuqiudeng/pocket-lodash/issues/327) [lodash源码分析之stringSize](https://github.com/yeyuqiudeng/pocket-lodash/issues/170) ## 源码分析 `padEnd` 是在 `string` 的长度不足 `length` 的时候,在后面补全指定的字符串 `chars` ,得到一个长度为 `length`...

系列文章
api

本文为读 lodash 源码的第三百二十七篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import createPadding from './.internal/createPadding.js' import stringSize from './.internal/stringSize.js' ``` [lodash源码分析之createPadding](https://github.com/yeyuqiudeng/pocket-lodash/issues/327) [lodash源码分析之stringSize](https://github.com/yeyuqiudeng/pocket-lodash/issues/170) ## 源码分析 `pad` 的作用是在 `string` 的长度不足 `length` 的时候,使用 `chars` 在 `pad`...

系列文章
api

本文为读 lodash 源码的第三百二十六篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 依赖 ```javascript import repeat from '../repeat.js' import baseToString from './baseToString.js' import castSlice from './castSlice.js' import hasUnicode from './hasUnicode.js' import stringSize from './stringSize.js' import stringToArray...

系列文章
internal

本文为读 lodash 源码的第三百二十五篇,后续文章会更新到这个仓库中,欢迎 star:[pocket-lodash](https://github.com/yeyuqiudeng/pocket-lodash) gitbook也会同步仓库的更新,gitbook地址:[pocket-lodash](https://www.gitbook.com/book/yeyuqiudeng/pocket-lodash/details) ## 源码分析 `repeat` 的作用是将指定的字符串重复 `n` 次生成一个新的字符串。 其实可以很简单地就完成这个功能: ```javascript function repeat (string, n) { let result = '' for (let i = 0; i < n;...

系列文章
api