From bf5e3debaaa91e9d6f5c873cbe1e0ddeb27d0a1d Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 26 Jan 2021 19:12:34 +0800 Subject: [PATCH] Migrate to @napi-rs/pinyin, drop Windows x86 (#38) --- README.md | 2 +- appveyor.yml | 15 --------------- lib/limax.js | 4 ++-- package.json | 4 ++-- 4 files changed, 5 insertions(+), 20 deletions(-) delete mode 100644 appveyor.yml diff --git a/README.md b/README.md index 9ed6125..6099ac8 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Provided to support backwards-compatibility with the `slug` module. const underscore = slug('i ♥ unicode', '_'); // i_love_unicode ``` -## Test [![Build Status](https://travis-ci.org/lovell/limax.png?branch=master)](https://travis-ci.org/lovell/limax) +## Test ![.github/workflows/ci.yml](https://github.com/lovell/limax/workflows/.github/workflows/ci.yml/badge.svg) Run the unit tests with: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 543fbd6..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,15 +0,0 @@ -os: Visual Studio 2019 -version: "{build}" -build: off -platform: x86 -environment: - matrix: - - nodejs_version: "10" - - nodejs_version: "12" - - nodejs_version: "14" - - nodejs_version: "15" -install: - - ps: Install-Product node $env:nodejs_version - - npm install -test_script: - - npm test diff --git a/lib/limax.js b/lib/limax.js index fdeceff..576ed92 100644 --- a/lib/limax.js +++ b/lib/limax.js @@ -1,7 +1,7 @@ 'use strict'; const speakingurl = require('speakingurl'); -const pinyin = require('pinyin'); +const { pinyin, PINYIN_STYLE } = require('@napi-rs/pinyin'); const hepburn = require('hepburn'); function customCharsAsArray (custom) { @@ -39,7 +39,7 @@ module.exports = function (text, opt) { const tone = (typeof options.tone === 'boolean') ? options.tone : true; mergeDigitSuffixes = tone; text = pinyin(text, { - style: tone ? pinyin.STYLE_TONE2 : pinyin.STYLE_NORMAL + style: tone ? PINYIN_STYLE.WithToneNumEnd : PINYIN_STYLE.Plain }).join(' '); // Remove punctuation symbols const customNonPunctuation = customCharsAsArray(options.custom).map(function (c) { return `\\${c}`; }).join(''); diff --git a/package.json b/package.json index 046b233..cb86488 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ ], "license": "Apache-2.0", "dependencies": { + "@napi-rs/pinyin": "^1.5.0", "hepburn": "^1.2.0", - "pinyin": "^2.9.1", "speakingurl": "^14.0.1" }, "devDependencies": { @@ -49,4 +49,4 @@ "nyc": "^15.1.0", "semistandard": "^16.0.0" } -} +} \ No newline at end of file