0.1.0 • Published 1 year ago

tokenizing v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

tokenizing - 从文本中匹配字符索引范围

应用

从js文件来匹配token

// 导入方法
import parseJsForI18n from 'tokenizing/matchingJs'

// 简单示例
const jsContent = '(a,b) => i++ // xxx'
matchingJs(jsContent, {
  onToken: console.log,
  onBlockStart: console.log,
  onBlockEnd: console.log,
})

从js文件来处理国际化的中文字符串字面量

// 导入方法
import parseJsForI18n from 'tokenizing/parseJsForI18n'

// 简单示例
const jsContent = 'const name = "小明"; const hi = `你好,${name}`;'
const newJsContent = parseJsForI18n(jsContent)
// -> 'const name = $t("小明"); const hi = $t("你好,{p0}", [name]);'
0.1.0

1 year ago