npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

qwerasd

v1.1.1

Published

A TypeScript library for detecting consecutive keyboard characters (qwerty patterns, numbers, letters). Perfect for password strength validation.

Readme

qwerasd

🎯 檢測鍵盤連續字的 TypeScript 工具包

不僅可以檢測 qwe123abc 等基本連續字,更能智慧識別 abc124qwe789password123 等複雜混合字串中的連續字片段,適用於密碼強度驗證、表單驗證等場景。

✨ 功能特色

  • 檢測 QWERTY 鍵盤連續字:qweasdzxc
  • 檢測垂直連續字:qazwsxedc
  • 檢測反向連續字:ewqtsrcba
  • 檢測數字連續字:123456789
  • 檢測字母連續字:abcXYZ
  • 🆕 智慧混合字串檢測abc124qwe789hello123 等複雜組合

📦 安裝

npm install qwerasd

🚀 快速開始

useQwerty 檢測器

useQwerty 是本套件的核心功能,提供完整的鍵盤連續字檢測能力:

import { useQwerty } from "qwerasd";

const detector = useQwerty(3); // 設定最小長度為 3

// 檢測各種連續字
detector.detect("qwe").isQwerty(); // true - QWERTY 鍵盤連續字
detector.detect("123").isNumber(); // true - 數字連續字
detector.detect("abc").isLowercase(); // true - 小寫字母連續字
detector.detect("XYZ").isUppercase(); // true - 大寫字母連續字

// 檢測任何類型的連續字
detector.detect("qwe").isConsecutive(); // true
detector.detect("hello").isConsecutive(); // false

// 獲取詳細結果
const result = detector.detect("qwer").getResults();
// { isQwerty: true, isUppercase: false, isLowercase: false,
//   isNumber: false, isConsecutive: true }

🆕 智慧混合字串檢測

新版本支援檢測複雜字串中的連續字片段,大幅提升實用性:

const detector = useQwerty(3);

// ✨ 混合字串檢測 - 核心新功能
detector.detect("abc124").isConsecutive(); // true - 檢測到 "abc"
detector.detect("qwe789").isConsecutive(); // true - 檢測到 "qwe" 和 "789"
detector.detect("hello123").isConsecutive(); // true - 檢測到 "123"
detector.detect("password456").isConsecutive(); // true - 檢測到 "456"

// 詳細分析混合字串
const mixedResult = detector.detect("abc124").getResults();
// { isQwerty: false, isLowercase: true, isNumber: false, isConsecutive: true }

// 複合連續字檢測
detector.detect("qwe123").getResults();
// { isQwerty: true, isNumber: true, isConsecutive: true }
// 同時檢測到 QWERTY 和數字連續字!

工作原理:檢測器會智慧地將長字串分割成指定長度的片段,然後檢查每個片段是否為連續字,讓您能輕鬆發現隱藏在複雜字串中的弱點模式。

進階檢測選項

// 檢測反向連續字
detector.detect("ewq", true); // true - qwe 的反向
detector.detect("321", true); // true - 123 的反向

// 檢測垂直連續字(僅適用於 QWERTY)
detector.detect("qaz", false, true); // true - q→a→z 垂直排列
detector.detect("wsx", false, true); // true - w→s→x 垂直排列

單次檢測場景

如果只需要簡單的單次檢測,可以從 qwerasd/utils 導入這些便利函數:

import { isQwerty, isNumber, isUppercase, isLowercase } from "qwerasd/utils";

// 快速檢測 QWERTY 鍵盤連續字
isQwerty("qwe"); // true
isQwerty("asd"); // true
isQwerty("hello"); // false

// 快速檢測數字連續字
isNumber("123"); // true
isNumber("456"); // true
isNumber("135"); // false

// 快速檢測字母連續字
isUppercase("ABC"); // true
isLowercase("xyz"); // true

// 支援反向和垂直檢測
isQwerty("ewq", true); // true - 反向檢測
isQwerty("qaz", false, true); // true - 垂直檢測

💡 提示:您也可以從主模組導入這些函數 import { isQwerty } from "qwerasd",兩種方式都可以使用。

📚 API 參考

useQwerty

const detector = useQwerty(最小長度);

detector.detect(str, 反向檢測?, 垂直檢測?)
  .isQwerty()       // 是否為 QWERTY 鍵盤連續字
  .isNumber()       // 是否為數字連續字
  .isUppercase()    // 是否為大寫字母連續字
  .isLowercase()    // 是否為小寫字母連續字
  .isConsecutive()  // 是否為任何類型的連續字
  .getResults()     // 取得詳細結果對象

參數說明:

  • 最小長度:檢測的最小字符長度,小於此長度的字串會返回 false
  • str:要檢測的字串
  • 反向檢測:是否包含反向字串檢測(可選,預設 false)
  • 垂直檢測:是否包含垂直排列檢測(可選,預設 false,僅適用於 QWERTY)

額外功能:直接檢測函數 (qwerasd/utils)

這些函數提供快速的單次檢測,適合簡單使用場景:

// 從 utils 模組導入
import { isQwerty, isUppercase, isLowercase, isNumber } from "qwerasd/utils";

// QWERTY 鍵盤連續字檢測
isQwerty(str, 反向檢測?, 垂直檢測?)

// 字母數字連續字檢測
isUppercase(str, 反向檢測?)   // 大寫字母 ABC, DEF...
isLowercase(str, 反向檢測?)   // 小寫字母 abc, xyz...
isNumber(str, 反向檢測?)      // 數字 123, 456...

實用範例

🔐 智慧密碼強度檢測

利用新的混合字串檢測功能,更精確地識別密碼中的弱點:

import { useQwerty } from "qwerasd";

// 創建檢測器,設定最小連續長度為 3
const detector = useQwerty(3);

function advancedPasswordCheck(password: string) {
  const result = detector.detect(password, true, true);

  return {
    password,
    hasWeakPattern: result.isConsecutive(),
    weakTypes: {
      qwerty: result.isQwerty(), // 鍵盤連續字
      numbers: result.isNumber(), // 數字連續字
      letters: result.isLowercase() || result.isUppercase(),
    },
    details: result.getResults(),
  };
}

// ✨ 測試各種複雜密碼場景
advancedPasswordCheck("mypassword123");
// { hasWeakPattern: true, weakTypes: { numbers: true, letters: false, qwerty: false } }

advancedPasswordCheck("secure_abc_2024");
// { hasWeakPattern: true, weakTypes: { letters: true, numbers: false, qwerty: false } }

advancedPasswordCheck("loginqwe456");
// { hasWeakPattern: true, weakTypes: { qwerty: true, numbers: true, letters: false } }

advancedPasswordCheck("K7#mX!9$pL");
// { hasWeakPattern: false, weakTypes: { qwerty: false, numbers: false, letters: false } }

實際應用場景

  • ✅ 檢測 abc123 類型的常見弱密碼組合
  • ✅ 識別 qwerty456 等鍵盤+數字的懶惰模式
  • ✅ 發現隱藏在長密碼中的連續字片段
  • ✅ 提供具體的改進建議(避免哪種類型的連續字)

快速檢測(使用 utils 模組)

import { isQwerty, isNumber } from "qwerasd/utils";

// 簡單的弱密碼模式檢測
function hasSimpleWeakPattern(password: string) {
  const commonPatterns = ["qwe", "asd", "zxc", "123", "456", "abc"];
  return commonPatterns.some(
    (pattern) =>
      password.includes(pattern) ||
      isQwerty(pattern, true) ||
      isNumber(pattern, true)
  );
}

hasSimpleWeakPattern("password123"); // true
hasSimpleWeakPattern("x9mK#2p"); // false

🔧 開發

npm test           # 運行測試
npm run build      # 構建發布版本

📄 授權

ISC


💡 提示:這個工具特別適合用於密碼強度檢測,不僅能識別明顯的連續字符(如 123qwe),更能發現隱藏在複雜密碼中的弱點模式(如 MyPassword123login_qwe_2024),幫助建立更安全的密碼策略。