aurix-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +329 -0
- package/bin/aurix +172 -0
- package/bin/aurix.cmd +23 -0
- package/dist/agent/AgentLoop.d.ts +52 -0
- package/dist/agent/AgentLoop.d.ts.map +1 -0
- package/dist/agent/AgentLoop.js +543 -0
- package/dist/agent/AgentLoop.js.map +1 -0
- package/dist/agent/AgentsMD.d.ts +8 -0
- package/dist/agent/AgentsMD.d.ts.map +1 -0
- package/dist/agent/AgentsMD.js +53 -0
- package/dist/agent/AgentsMD.js.map +1 -0
- package/dist/agent/CodeReview.d.ts +13 -0
- package/dist/agent/CodeReview.d.ts.map +1 -0
- package/dist/agent/CodeReview.js +134 -0
- package/dist/agent/CodeReview.js.map +1 -0
- package/dist/agent/Config.d.ts +63 -0
- package/dist/agent/Config.d.ts.map +1 -0
- package/dist/agent/Config.js +55 -0
- package/dist/agent/Config.js.map +1 -0
- package/dist/agent/Context.d.ts +4 -0
- package/dist/agent/Context.d.ts.map +1 -0
- package/dist/agent/Context.js +390 -0
- package/dist/agent/Context.js.map +1 -0
- package/dist/agent/ContextManager.d.ts +23 -0
- package/dist/agent/ContextManager.d.ts.map +1 -0
- package/dist/agent/ContextManager.js +163 -0
- package/dist/agent/ContextManager.js.map +1 -0
- package/dist/agent/MemoryEngine.d.ts +24 -0
- package/dist/agent/MemoryEngine.d.ts.map +1 -0
- package/dist/agent/MemoryEngine.js +347 -0
- package/dist/agent/MemoryEngine.js.map +1 -0
- package/dist/agent/MultiAgent.d.ts +22 -0
- package/dist/agent/MultiAgent.d.ts.map +1 -0
- package/dist/agent/MultiAgent.js +466 -0
- package/dist/agent/MultiAgent.js.map +1 -0
- package/dist/agent/ResearchPipeline.d.ts +22 -0
- package/dist/agent/ResearchPipeline.d.ts.map +1 -0
- package/dist/agent/ResearchPipeline.js +195 -0
- package/dist/agent/ResearchPipeline.js.map +1 -0
- package/dist/agent/Setup.d.ts +3 -0
- package/dist/agent/Setup.d.ts.map +1 -0
- package/dist/agent/Setup.js +503 -0
- package/dist/agent/Setup.js.map +1 -0
- package/dist/agent/TokenCounter.d.ts +6 -0
- package/dist/agent/TokenCounter.d.ts.map +1 -0
- package/dist/agent/TokenCounter.js +73 -0
- package/dist/agent/TokenCounter.js.map +1 -0
- package/dist/agent/research/CitationGuardian.d.ts +10 -0
- package/dist/agent/research/CitationGuardian.d.ts.map +1 -0
- package/dist/agent/research/CitationGuardian.js +43 -0
- package/dist/agent/research/CitationGuardian.js.map +1 -0
- package/dist/agent/research/ClaimExtractor.d.ts +7 -0
- package/dist/agent/research/ClaimExtractor.d.ts.map +1 -0
- package/dist/agent/research/ClaimExtractor.js +49 -0
- package/dist/agent/research/ClaimExtractor.js.map +1 -0
- package/dist/agent/research/DebateSystem.d.ts +6 -0
- package/dist/agent/research/DebateSystem.d.ts.map +1 -0
- package/dist/agent/research/DebateSystem.js +33 -0
- package/dist/agent/research/DebateSystem.js.map +1 -0
- package/dist/agent/research/FinalReviewer.d.ts +10 -0
- package/dist/agent/research/FinalReviewer.d.ts.map +1 -0
- package/dist/agent/research/FinalReviewer.js +35 -0
- package/dist/agent/research/FinalReviewer.js.map +1 -0
- package/dist/agent/research/JudgeAgent.d.ts +7 -0
- package/dist/agent/research/JudgeAgent.d.ts.map +1 -0
- package/dist/agent/research/JudgeAgent.js +40 -0
- package/dist/agent/research/JudgeAgent.js.map +1 -0
- package/dist/agent/research/LogicCritic.d.ts +10 -0
- package/dist/agent/research/LogicCritic.d.ts.map +1 -0
- package/dist/agent/research/LogicCritic.js +39 -0
- package/dist/agent/research/LogicCritic.js.map +1 -0
- package/dist/agent/research/PlanningAgent.d.ts +10 -0
- package/dist/agent/research/PlanningAgent.d.ts.map +1 -0
- package/dist/agent/research/PlanningAgent.js +39 -0
- package/dist/agent/research/PlanningAgent.js.map +1 -0
- package/dist/agent/research/RequestAnalyzer.d.ts +14 -0
- package/dist/agent/research/RequestAnalyzer.d.ts.map +1 -0
- package/dist/agent/research/RequestAnalyzer.js +38 -0
- package/dist/agent/research/RequestAnalyzer.js.map +1 -0
- package/dist/agent/research/ResearchAgent.d.ts +12 -0
- package/dist/agent/research/ResearchAgent.d.ts.map +1 -0
- package/dist/agent/research/ResearchAgent.js +64 -0
- package/dist/agent/research/ResearchAgent.js.map +1 -0
- package/dist/agent/research/SkepticAgent.d.ts +9 -0
- package/dist/agent/research/SkepticAgent.d.ts.map +1 -0
- package/dist/agent/research/SkepticAgent.js +38 -0
- package/dist/agent/research/SkepticAgent.js.map +1 -0
- package/dist/agent/research/SupporterAgent.d.ts +9 -0
- package/dist/agent/research/SupporterAgent.d.ts.map +1 -0
- package/dist/agent/research/SupporterAgent.js +31 -0
- package/dist/agent/research/SupporterAgent.js.map +1 -0
- package/dist/agent/research/VideoAgent.d.ts +10 -0
- package/dist/agent/research/VideoAgent.d.ts.map +1 -0
- package/dist/agent/research/VideoAgent.js +49 -0
- package/dist/agent/research/VideoAgent.js.map +1 -0
- package/dist/agent/research/WriterAgent.d.ts +6 -0
- package/dist/agent/research/WriterAgent.d.ts.map +1 -0
- package/dist/agent/research/WriterAgent.js +30 -0
- package/dist/agent/research/WriterAgent.js.map +1 -0
- package/dist/agent/research/index.d.ts +15 -0
- package/dist/agent/research/index.d.ts.map +1 -0
- package/dist/agent/research/index.js +14 -0
- package/dist/agent/research/index.js.map +1 -0
- package/dist/agent/research/types.d.ts +49 -0
- package/dist/agent/research/types.d.ts.map +1 -0
- package/dist/agent/research/types.js +17 -0
- package/dist/agent/research/types.js.map +1 -0
- package/dist/cli/AltScreen.d.ts +3 -0
- package/dist/cli/AltScreen.d.ts.map +1 -0
- package/dist/cli/AltScreen.js +72 -0
- package/dist/cli/AltScreen.js.map +1 -0
- package/dist/cli/App.d.ts +11 -0
- package/dist/cli/App.d.ts.map +1 -0
- package/dist/cli/App.js +1319 -0
- package/dist/cli/App.js.map +1 -0
- package/dist/cli/Banner.d.ts +13 -0
- package/dist/cli/Banner.d.ts.map +1 -0
- package/dist/cli/Banner.js +12 -0
- package/dist/cli/Banner.js.map +1 -0
- package/dist/cli/BlackFill.d.ts +3 -0
- package/dist/cli/BlackFill.d.ts.map +1 -0
- package/dist/cli/BlackFill.js +9 -0
- package/dist/cli/BlackFill.js.map +1 -0
- package/dist/cli/ChatArea.d.ts +20 -0
- package/dist/cli/ChatArea.d.ts.map +1 -0
- package/dist/cli/ChatArea.js +300 -0
- package/dist/cli/ChatArea.js.map +1 -0
- package/dist/cli/ConnectModal.d.ts +9 -0
- package/dist/cli/ConnectModal.d.ts.map +1 -0
- package/dist/cli/ConnectModal.js +101 -0
- package/dist/cli/ConnectModal.js.map +1 -0
- package/dist/cli/FileDiff.d.ts +16 -0
- package/dist/cli/FileDiff.d.ts.map +1 -0
- package/dist/cli/FileDiff.js +45 -0
- package/dist/cli/FileDiff.js.map +1 -0
- package/dist/cli/InputBox.d.ts +18 -0
- package/dist/cli/InputBox.d.ts.map +1 -0
- package/dist/cli/InputBox.js +573 -0
- package/dist/cli/InputBox.js.map +1 -0
- package/dist/cli/LoginModal.d.ts +10 -0
- package/dist/cli/LoginModal.d.ts.map +1 -0
- package/dist/cli/LoginModal.js +129 -0
- package/dist/cli/LoginModal.js.map +1 -0
- package/dist/cli/Menu.d.ts +26 -0
- package/dist/cli/Menu.d.ts.map +1 -0
- package/dist/cli/Menu.js +115 -0
- package/dist/cli/Menu.js.map +1 -0
- package/dist/cli/MouseFilter.d.ts +2 -0
- package/dist/cli/MouseFilter.d.ts.map +1 -0
- package/dist/cli/MouseFilter.js +47 -0
- package/dist/cli/MouseFilter.js.map +1 -0
- package/dist/cli/Panel.d.ts.map +1 -0
- package/dist/cli/Panel.js.map +1 -0
- package/dist/cli/PermissionPrompt.d.ts +9 -0
- package/dist/cli/PermissionPrompt.d.ts.map +1 -0
- package/dist/cli/PermissionPrompt.js +56 -0
- package/dist/cli/PermissionPrompt.js.map +1 -0
- package/dist/cli/SessionPanel.d.ts +15 -0
- package/dist/cli/SessionPanel.d.ts.map +1 -0
- package/dist/cli/SessionPanel.js +28 -0
- package/dist/cli/SessionPanel.js.map +1 -0
- package/dist/cli/SetupUI.d.ts +34 -0
- package/dist/cli/SetupUI.d.ts.map +1 -0
- package/dist/cli/SetupUI.js +311 -0
- package/dist/cli/SetupUI.js.map +1 -0
- package/dist/cli/StatusBar.d.ts +12 -0
- package/dist/cli/StatusBar.d.ts.map +1 -0
- package/dist/cli/StatusBar.js +7 -0
- package/dist/cli/StatusBar.js.map +1 -0
- package/dist/cli/WhatsAppModal.d.ts +10 -0
- package/dist/cli/WhatsAppModal.d.ts.map +1 -0
- package/dist/cli/WhatsAppModal.js +78 -0
- package/dist/cli/WhatsAppModal.js.map +1 -0
- package/dist/cli/animation/useThinking.d.ts +2 -0
- package/dist/cli/animation/useThinking.d.ts.map +1 -0
- package/dist/cli/animation/useThinking.js +50 -0
- package/dist/cli/animation/useThinking.js.map +1 -0
- package/dist/cli/commands.d.ts +26 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +816 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/theme.d.ts +101 -0
- package/dist/cli/theme.d.ts.map +1 -0
- package/dist/cli/theme.js +222 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/commands/SlashCommands.d.ts +15 -0
- package/dist/commands/SlashCommands.d.ts.map +1 -0
- package/dist/commands/SlashCommands.js +238 -0
- package/dist/commands/SlashCommands.js.map +1 -0
- package/dist/gateway/Discord.d.ts +13 -0
- package/dist/gateway/Discord.d.ts.map +1 -0
- package/dist/gateway/Discord.js +144 -0
- package/dist/gateway/Discord.js.map +1 -0
- package/dist/gateway/Gateway.d.ts +71 -0
- package/dist/gateway/Gateway.d.ts.map +1 -0
- package/dist/gateway/Gateway.js +665 -0
- package/dist/gateway/Gateway.js.map +1 -0
- package/dist/gateway/Telegram.d.ts +18 -0
- package/dist/gateway/Telegram.d.ts.map +1 -0
- package/dist/gateway/Telegram.js +224 -0
- package/dist/gateway/Telegram.js.map +1 -0
- package/dist/gateway/WASessionStore.d.ts +13 -0
- package/dist/gateway/WASessionStore.d.ts.map +1 -0
- package/dist/gateway/WASessionStore.js +94 -0
- package/dist/gateway/WASessionStore.js.map +1 -0
- package/dist/gateway/WhatsApp.d.ts +19 -0
- package/dist/gateway/WhatsApp.d.ts.map +1 -0
- package/dist/gateway/WhatsApp.js +159 -0
- package/dist/gateway/WhatsApp.js.map +1 -0
- package/dist/gateway-entry.d.ts +3 -0
- package/dist/gateway-entry.d.ts.map +1 -0
- package/dist/gateway-entry.js +50 -0
- package/dist/gateway-entry.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +213 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/index.d.ts +70 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +390 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/skills/SkillRegistry.d.ts +33 -0
- package/dist/skills/SkillRegistry.d.ts.map +1 -0
- package/dist/skills/SkillRegistry.js +102 -0
- package/dist/skills/SkillRegistry.js.map +1 -0
- package/dist/token-counter.linux-x64-gnu.node +0 -0
- package/dist/tools/Backend.d.ts +3 -0
- package/dist/tools/Backend.d.ts.map +1 -0
- package/dist/tools/Backend.js +154 -0
- package/dist/tools/Backend.js.map +1 -0
- package/dist/tools/Blockchain.d.ts +3 -0
- package/dist/tools/Blockchain.d.ts.map +1 -0
- package/dist/tools/Blockchain.js +82 -0
- package/dist/tools/Blockchain.js.map +1 -0
- package/dist/tools/Browser.d.ts +5 -0
- package/dist/tools/Browser.d.ts.map +1 -0
- package/dist/tools/Browser.js +2253 -0
- package/dist/tools/Browser.js.map +1 -0
- package/dist/tools/Cloud.d.ts +3 -0
- package/dist/tools/Cloud.d.ts.map +1 -0
- package/dist/tools/Cloud.js +115 -0
- package/dist/tools/Cloud.js.map +1 -0
- package/dist/tools/CodeExec.d.ts +3 -0
- package/dist/tools/CodeExec.d.ts.map +1 -0
- package/dist/tools/CodeExec.js +76 -0
- package/dist/tools/CodeExec.js.map +1 -0
- package/dist/tools/Cybersec.d.ts +3 -0
- package/dist/tools/Cybersec.d.ts.map +1 -0
- package/dist/tools/Cybersec.js +186 -0
- package/dist/tools/Cybersec.js.map +1 -0
- package/dist/tools/Deploy.d.ts +3 -0
- package/dist/tools/Deploy.d.ts.map +1 -0
- package/dist/tools/Deploy.js +87 -0
- package/dist/tools/Deploy.js.map +1 -0
- package/dist/tools/Diagram.d.ts +3 -0
- package/dist/tools/Diagram.d.ts.map +1 -0
- package/dist/tools/Diagram.js +38 -0
- package/dist/tools/Diagram.js.map +1 -0
- package/dist/tools/Docker.d.ts +3 -0
- package/dist/tools/Docker.d.ts.map +1 -0
- package/dist/tools/Docker.js +45 -0
- package/dist/tools/Docker.js.map +1 -0
- package/dist/tools/Email.d.ts +3 -0
- package/dist/tools/Email.d.ts.map +1 -0
- package/dist/tools/Email.js +172 -0
- package/dist/tools/Email.js.map +1 -0
- package/dist/tools/Excel.d.ts +3 -0
- package/dist/tools/Excel.d.ts.map +1 -0
- package/dist/tools/Excel.js +41 -0
- package/dist/tools/Excel.js.map +1 -0
- package/dist/tools/FileEdit.d.ts +3 -0
- package/dist/tools/FileEdit.d.ts.map +1 -0
- package/dist/tools/FileEdit.js +69 -0
- package/dist/tools/FileEdit.js.map +1 -0
- package/dist/tools/FileOps.d.ts +5 -0
- package/dist/tools/FileOps.d.ts.map +1 -0
- package/dist/tools/FileOps.js +76 -0
- package/dist/tools/FileOps.js.map +1 -0
- package/dist/tools/Frontend.d.ts +3 -0
- package/dist/tools/Frontend.d.ts.map +1 -0
- package/dist/tools/Frontend.js +124 -0
- package/dist/tools/Frontend.js.map +1 -0
- package/dist/tools/GifSearch.d.ts +3 -0
- package/dist/tools/GifSearch.d.ts.map +1 -0
- package/dist/tools/GifSearch.js +36 -0
- package/dist/tools/GifSearch.js.map +1 -0
- package/dist/tools/Github.d.ts +3 -0
- package/dist/tools/Github.d.ts.map +1 -0
- package/dist/tools/Github.js +95 -0
- package/dist/tools/Github.js.map +1 -0
- package/dist/tools/GithubConnect.d.ts +3 -0
- package/dist/tools/GithubConnect.d.ts.map +1 -0
- package/dist/tools/GithubConnect.js +282 -0
- package/dist/tools/GithubConnect.js.map +1 -0
- package/dist/tools/Humanizer.d.ts +3 -0
- package/dist/tools/Humanizer.d.ts.map +1 -0
- package/dist/tools/Humanizer.js +45 -0
- package/dist/tools/Humanizer.js.map +1 -0
- package/dist/tools/Maps.d.ts +3 -0
- package/dist/tools/Maps.d.ts.map +1 -0
- package/dist/tools/Maps.js +51 -0
- package/dist/tools/Maps.js.map +1 -0
- package/dist/tools/McpManage.d.ts +26 -0
- package/dist/tools/McpManage.d.ts.map +1 -0
- package/dist/tools/McpManage.js +229 -0
- package/dist/tools/McpManage.js.map +1 -0
- package/dist/tools/Memory.d.ts +3 -0
- package/dist/tools/Memory.d.ts.map +1 -0
- package/dist/tools/Memory.js +68 -0
- package/dist/tools/Memory.js.map +1 -0
- package/dist/tools/Music.d.ts +3 -0
- package/dist/tools/Music.d.ts.map +1 -0
- package/dist/tools/Music.js +274 -0
- package/dist/tools/Music.js.map +1 -0
- package/dist/tools/Notifier.d.ts +3 -0
- package/dist/tools/Notifier.d.ts.map +1 -0
- package/dist/tools/Notifier.js +31 -0
- package/dist/tools/Notifier.js.map +1 -0
- package/dist/tools/Osint.d.ts +3 -0
- package/dist/tools/Osint.d.ts.map +1 -0
- package/dist/tools/Osint.js +57 -0
- package/dist/tools/Osint.js.map +1 -0
- package/dist/tools/Pdf.d.ts +3 -0
- package/dist/tools/Pdf.d.ts.map +1 -0
- package/dist/tools/Pdf.js +152 -0
- package/dist/tools/Pdf.js.map +1 -0
- package/dist/tools/Planning.d.ts +3 -0
- package/dist/tools/Planning.d.ts.map +1 -0
- package/dist/tools/Planning.js +212 -0
- package/dist/tools/Planning.js.map +1 -0
- package/dist/tools/Pptx.d.ts +3 -0
- package/dist/tools/Pptx.d.ts.map +1 -0
- package/dist/tools/Pptx.js +47 -0
- package/dist/tools/Pptx.js.map +1 -0
- package/dist/tools/Registry.d.ts +39 -0
- package/dist/tools/Registry.d.ts.map +1 -0
- package/dist/tools/Registry.js +151 -0
- package/dist/tools/Registry.js.map +1 -0
- package/dist/tools/Research.d.ts +3 -0
- package/dist/tools/Research.d.ts.map +1 -0
- package/dist/tools/Research.js +126 -0
- package/dist/tools/Research.js.map +1 -0
- package/dist/tools/ResearchForums.d.ts +3 -0
- package/dist/tools/ResearchForums.d.ts.map +1 -0
- package/dist/tools/ResearchForums.js +84 -0
- package/dist/tools/ResearchForums.js.map +1 -0
- package/dist/tools/Scraper.d.ts +3 -0
- package/dist/tools/Scraper.d.ts.map +1 -0
- package/dist/tools/Scraper.js +54 -0
- package/dist/tools/Scraper.js.map +1 -0
- package/dist/tools/SendFile.d.ts +4 -0
- package/dist/tools/SendFile.d.ts.map +1 -0
- package/dist/tools/SendFile.js +71 -0
- package/dist/tools/SendFile.js.map +1 -0
- package/dist/tools/SkillLoader.d.ts +3 -0
- package/dist/tools/SkillLoader.d.ts.map +1 -0
- package/dist/tools/SkillLoader.js +132 -0
- package/dist/tools/SkillLoader.js.map +1 -0
- package/dist/tools/SystemMonitor.d.ts +3 -0
- package/dist/tools/SystemMonitor.d.ts.map +1 -0
- package/dist/tools/SystemMonitor.js +59 -0
- package/dist/tools/SystemMonitor.js.map +1 -0
- package/dist/tools/Terminal.d.ts +3 -0
- package/dist/tools/Terminal.d.ts.map +1 -0
- package/dist/tools/Terminal.js +32 -0
- package/dist/tools/Terminal.js.map +1 -0
- package/dist/tools/Todo.d.ts +3 -0
- package/dist/tools/Todo.d.ts.map +1 -0
- package/dist/tools/Todo.js +87 -0
- package/dist/tools/Todo.js.map +1 -0
- package/dist/tools/Trading.d.ts +3 -0
- package/dist/tools/Trading.d.ts.map +1 -0
- package/dist/tools/Trading.js +277 -0
- package/dist/tools/Trading.js.map +1 -0
- package/dist/tools/Vision.d.ts +3 -0
- package/dist/tools/Vision.d.ts.map +1 -0
- package/dist/tools/Vision.js +99 -0
- package/dist/tools/Vision.js.map +1 -0
- package/dist/tools/Vps.d.ts +3 -0
- package/dist/tools/Vps.d.ts.map +1 -0
- package/dist/tools/Vps.js +178 -0
- package/dist/tools/Vps.js.map +1 -0
- package/dist/tools/WebSearch.d.ts +3 -0
- package/dist/tools/WebSearch.d.ts.map +1 -0
- package/dist/tools/WebSearch.js +115 -0
- package/dist/tools/WebSearch.js.map +1 -0
- package/dist/tools/YouTube.d.ts +3 -0
- package/dist/tools/YouTube.d.ts.map +1 -0
- package/dist/tools/YouTube.js +30 -0
- package/dist/tools/YouTube.js.map +1 -0
- package/dist/utils/ascii-logo.d.ts +9 -0
- package/dist/utils/ascii-logo.d.ts.map +1 -0
- package/dist/utils/ascii-logo.js +34 -0
- package/dist/utils/ascii-logo.js.map +1 -0
- package/dist/utils/base-url.d.ts +9 -0
- package/dist/utils/base-url.d.ts.map +1 -0
- package/dist/utils/base-url.js +58 -0
- package/dist/utils/base-url.js.map +1 -0
- package/native/token-counter/index.d.ts +7 -0
- package/native/token-counter/index.js +316 -0
- package/native/token-counter/node_modules/.package-lock.json +568 -0
- package/native/token-counter/node_modules/2/array.js +25 -0
- package/native/token-counter/node_modules/2/index.js +12 -0
- package/native/token-counter/node_modules/2/iterator.js +13 -0
- package/native/token-counter/node_modules/2/license.txt +21 -0
- package/native/token-counter/node_modules/2/map.js +27 -0
- package/native/token-counter/node_modules/2/number.js +109 -0
- package/native/token-counter/node_modules/2/object.js +23 -0
- package/native/token-counter/node_modules/2/package.json +60 -0
- package/native/token-counter/node_modules/2/readme.md +246 -0
- package/native/token-counter/node_modules/2/string.js +11 -0
- package/native/token-counter/node_modules/2/test.js +520 -0
- package/native/token-counter/node_modules/@lamansky/every/index.js +16 -0
- package/native/token-counter/node_modules/@lamansky/every/license.txt +21 -0
- package/native/token-counter/node_modules/@lamansky/every/package.json +38 -0
- package/native/token-counter/node_modules/@lamansky/every/readme.md +46 -0
- package/native/token-counter/node_modules/@lamansky/flatten/index.js +5 -0
- package/native/token-counter/node_modules/@lamansky/flatten/license.txt +21 -0
- package/native/token-counter/node_modules/@lamansky/flatten/package.json +35 -0
- package/native/token-counter/node_modules/@lamansky/flatten/readme.md +41 -0
- package/native/token-counter/node_modules/@napi-rs/cli/LICENSE +21 -0
- package/native/token-counter/node_modules/@napi-rs/cli/README.md +96 -0
- package/native/token-counter/node_modules/@napi-rs/cli/package.json +65 -0
- package/native/token-counter/node_modules/@napi-rs/cli/scripts/index.js +51371 -0
- package/native/token-counter/node_modules/add-counter/index.js +3 -0
- package/native/token-counter/node_modules/add-counter/license.txt +21 -0
- package/native/token-counter/node_modules/add-counter/package.json +34 -0
- package/native/token-counter/node_modules/add-counter/readme.md +36 -0
- package/native/token-counter/node_modules/array-pad/LICENSE +22 -0
- package/native/token-counter/node_modules/array-pad/README.md +80 -0
- package/native/token-counter/node_modules/array-pad/index.js +30 -0
- package/native/token-counter/node_modules/array-pad/package.json +28 -0
- package/native/token-counter/node_modules/arrify/index.js +8 -0
- package/native/token-counter/node_modules/arrify/license +21 -0
- package/native/token-counter/node_modules/arrify/package.json +33 -0
- package/native/token-counter/node_modules/arrify/readme.md +36 -0
- package/native/token-counter/node_modules/case-insensitive/index.js +72 -0
- package/native/token-counter/node_modules/case-insensitive/license.txt +21 -0
- package/native/token-counter/node_modules/case-insensitive/package.json +39 -0
- package/native/token-counter/node_modules/case-insensitive/readme.md +39 -0
- package/native/token-counter/node_modules/case-insensitive/test.js +114 -0
- package/native/token-counter/node_modules/class-chain/index.js +32 -0
- package/native/token-counter/node_modules/class-chain/license.txt +21 -0
- package/native/token-counter/node_modules/class-chain/package.json +39 -0
- package/native/token-counter/node_modules/class-chain/readme.md +23 -0
- package/native/token-counter/node_modules/class-chain/test.js +77 -0
- package/native/token-counter/node_modules/copy-own/index.js +10 -0
- package/native/token-counter/node_modules/copy-own/license.txt +21 -0
- package/native/token-counter/node_modules/copy-own/package.json +37 -0
- package/native/token-counter/node_modules/copy-own/readme.md +67 -0
- package/native/token-counter/node_modules/def-props/index.js +43 -0
- package/native/token-counter/node_modules/def-props/license.txt +21 -0
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/index.d.ts +22 -0
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/index.js +6 -0
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/license +9 -0
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/package.json +34 -0
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/readme.md +39 -0
- package/native/token-counter/node_modules/def-props/package.json +51 -0
- package/native/token-counter/node_modules/def-props/readme.md +117 -0
- package/native/token-counter/node_modules/empty-iterator/index.js +3 -0
- package/native/token-counter/node_modules/empty-iterator/license.txt +21 -0
- package/native/token-counter/node_modules/empty-iterator/package.json +33 -0
- package/native/token-counter/node_modules/empty-iterator/readme.md +23 -0
- package/native/token-counter/node_modules/enforce-range/index.js +15 -0
- package/native/token-counter/node_modules/enforce-range/license.txt +21 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/array.js +43 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/index.js +10 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/iterator.js +26 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/license.txt +21 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/map.js +47 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/number.js +33 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/object.js +61 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/package.json +41 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/readme.md +210 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/string.js +37 -0
- package/native/token-counter/node_modules/enforce-range/node_modules/2/test.js +413 -0
- package/native/token-counter/node_modules/enforce-range/package.json +36 -0
- package/native/token-counter/node_modules/enforce-range/readme.md +53 -0
- package/native/token-counter/node_modules/english-list/.travis.yml +6 -0
- package/native/token-counter/node_modules/english-list/LICENSE +22 -0
- package/native/token-counter/node_modules/english-list/README.md +44 -0
- package/native/token-counter/node_modules/english-list/index.js +34 -0
- package/native/token-counter/node_modules/english-list/package.json +31 -0
- package/native/token-counter/node_modules/english-list/test.log +6 -0
- package/native/token-counter/node_modules/errate/index.js +19 -0
- package/native/token-counter/node_modules/errate/license.txt +21 -0
- package/native/token-counter/node_modules/errate/package.json +39 -0
- package/native/token-counter/node_modules/errate/readme.md +79 -0
- package/native/token-counter/node_modules/ffn/index.js +9 -0
- package/native/token-counter/node_modules/ffn/license.txt +21 -0
- package/native/token-counter/node_modules/ffn/package.json +34 -0
- package/native/token-counter/node_modules/ffn/readme.md +51 -0
- package/native/token-counter/node_modules/get-own-property/index.js +5 -0
- package/native/token-counter/node_modules/get-own-property/license.txt +21 -0
- package/native/token-counter/node_modules/get-own-property/package.json +31 -0
- package/native/token-counter/node_modules/get-own-property/readme.md +22 -0
- package/native/token-counter/node_modules/has-duplicates/index.js +11 -0
- package/native/token-counter/node_modules/has-duplicates/license.txt +21 -0
- package/native/token-counter/node_modules/has-duplicates/package.json +32 -0
- package/native/token-counter/node_modules/has-duplicates/readme.md +23 -0
- package/native/token-counter/node_modules/has-duplicates/test.js +30 -0
- package/native/token-counter/node_modules/if-else-throw/index.js +8 -0
- package/native/token-counter/node_modules/if-else-throw/license.txt +21 -0
- package/native/token-counter/node_modules/if-else-throw/package.json +37 -0
- package/native/token-counter/node_modules/if-else-throw/readme.md +32 -0
- package/native/token-counter/node_modules/is-array-of-length/index.js +7 -0
- package/native/token-counter/node_modules/is-array-of-length/license.txt +21 -0
- package/native/token-counter/node_modules/is-array-of-length/package.json +42 -0
- package/native/token-counter/node_modules/is-array-of-length/readme.md +41 -0
- package/native/token-counter/node_modules/is-class-of/index.js +7 -0
- package/native/token-counter/node_modules/is-class-of/license.txt +21 -0
- package/native/token-counter/node_modules/is-class-of/package.json +35 -0
- package/native/token-counter/node_modules/is-class-of/readme.md +57 -0
- package/native/token-counter/node_modules/is-global-object/index.js +6 -0
- package/native/token-counter/node_modules/is-global-object/license.txt +21 -0
- package/native/token-counter/node_modules/is-global-object/package.json +34 -0
- package/native/token-counter/node_modules/is-global-object/readme.md +22 -0
- package/native/token-counter/node_modules/is-instance-of/index.js +28 -0
- package/native/token-counter/node_modules/is-instance-of/license.txt +21 -0
- package/native/token-counter/node_modules/is-instance-of/package.json +44 -0
- package/native/token-counter/node_modules/is-instance-of/readme.md +55 -0
- package/native/token-counter/node_modules/is-iterable/index.js +5 -0
- package/native/token-counter/node_modules/is-iterable/license +21 -0
- package/native/token-counter/node_modules/is-iterable/package.json +30 -0
- package/native/token-counter/node_modules/is-iterable/readme.md +23 -0
- package/native/token-counter/node_modules/is-nil/LICENSE +21 -0
- package/native/token-counter/node_modules/is-nil/README.md +47 -0
- package/native/token-counter/node_modules/is-nil/index.js +6 -0
- package/native/token-counter/node_modules/is-nil/package.json +46 -0
- package/native/token-counter/node_modules/is-obj/index.js +5 -0
- package/native/token-counter/node_modules/is-obj/license +21 -0
- package/native/token-counter/node_modules/is-obj/package.json +33 -0
- package/native/token-counter/node_modules/is-obj/readme.md +34 -0
- package/native/token-counter/node_modules/is-object/.eslintignore +1 -0
- package/native/token-counter/node_modules/is-object/.eslintrc +5 -0
- package/native/token-counter/node_modules/is-object/.nycrc +13 -0
- package/native/token-counter/node_modules/is-object/.testem.json +14 -0
- package/native/token-counter/node_modules/is-object/CHANGELOG.md +121 -0
- package/native/token-counter/node_modules/is-object/LICENSE +19 -0
- package/native/token-counter/node_modules/is-object/README.md +48 -0
- package/native/token-counter/node_modules/is-object/index.js +5 -0
- package/native/token-counter/node_modules/is-object/package.json +78 -0
- package/native/token-counter/node_modules/is-object/test/index.js +44 -0
- package/native/token-counter/node_modules/is-plain-object/LICENSE +21 -0
- package/native/token-counter/node_modules/is-plain-object/README.md +104 -0
- package/native/token-counter/node_modules/is-plain-object/index.d.ts +5 -0
- package/native/token-counter/node_modules/is-plain-object/index.js +37 -0
- package/native/token-counter/node_modules/is-plain-object/package.json +79 -0
- package/native/token-counter/node_modules/isobject/LICENSE +21 -0
- package/native/token-counter/node_modules/isobject/README.md +122 -0
- package/native/token-counter/node_modules/isobject/index.d.ts +5 -0
- package/native/token-counter/node_modules/isobject/index.js +12 -0
- package/native/token-counter/node_modules/isobject/package.json +74 -0
- package/native/token-counter/node_modules/lodash.set/LICENSE +47 -0
- package/native/token-counter/node_modules/lodash.set/README.md +18 -0
- package/native/token-counter/node_modules/lodash.set/index.js +990 -0
- package/native/token-counter/node_modules/lodash.set/package.json +17 -0
- package/native/token-counter/node_modules/longest-first/index.js +3 -0
- package/native/token-counter/node_modules/longest-first/license.txt +21 -0
- package/native/token-counter/node_modules/longest-first/package.json +36 -0
- package/native/token-counter/node_modules/longest-first/readme.md +29 -0
- package/native/token-counter/node_modules/m-o/index.js +27 -0
- package/native/token-counter/node_modules/m-o/license.txt +21 -0
- package/native/token-counter/node_modules/m-o/node_modules/new-object/index.js +23 -0
- package/native/token-counter/node_modules/m-o/node_modules/new-object/license.txt +21 -0
- package/native/token-counter/node_modules/m-o/node_modules/new-object/package.json +40 -0
- package/native/token-counter/node_modules/m-o/node_modules/new-object/readme.md +55 -0
- package/native/token-counter/node_modules/m-o/package.json +45 -0
- package/native/token-counter/node_modules/m-o/readme.md +87 -0
- package/native/token-counter/node_modules/map-iter/index.js +6 -0
- package/native/token-counter/node_modules/map-iter/license.txt +21 -0
- package/native/token-counter/node_modules/map-iter/package.json +40 -0
- package/native/token-counter/node_modules/map-iter/readme.md +46 -0
- package/native/token-counter/node_modules/new-object/index.js +5 -0
- package/native/token-counter/node_modules/new-object/license.txt +21 -0
- package/native/token-counter/node_modules/new-object/package.json +49 -0
- package/native/token-counter/node_modules/new-object/readme.md +145 -0
- package/native/token-counter/node_modules/ofn/index.js +22 -0
- package/native/token-counter/node_modules/ofn/license.txt +21 -0
- package/native/token-counter/node_modules/ofn/package.json +40 -0
- package/native/token-counter/node_modules/ofn/readme.md +63 -0
- package/native/token-counter/node_modules/otherwise/index.js +11 -0
- package/native/token-counter/node_modules/otherwise/license.txt +21 -0
- package/native/token-counter/node_modules/otherwise/package.json +38 -0
- package/native/token-counter/node_modules/otherwise/readme.md +29 -0
- package/native/token-counter/node_modules/parser-factory/index.js +138 -0
- package/native/token-counter/node_modules/parser-factory/license.txt +21 -0
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/index.d.ts +38 -0
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/index.js +23 -0
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/license +9 -0
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/package.json +35 -0
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/readme.md +39 -0
- package/native/token-counter/node_modules/parser-factory/package.json +38 -0
- package/native/token-counter/node_modules/parser-factory/readme.md +15 -0
- package/native/token-counter/node_modules/pfn/index.js +5 -0
- package/native/token-counter/node_modules/pfn/license.txt +21 -0
- package/native/token-counter/node_modules/pfn/package.json +41 -0
- package/native/token-counter/node_modules/pfn/readme.md +111 -0
- package/native/token-counter/node_modules/pfn/strict.js +8 -0
- package/native/token-counter/node_modules/plainify/index.js +5 -0
- package/native/token-counter/node_modules/plainify/license.txt +21 -0
- package/native/token-counter/node_modules/plainify/package.json +36 -0
- package/native/token-counter/node_modules/plainify/readme.md +47 -0
- package/native/token-counter/node_modules/possible-function/changelog.md +7 -0
- package/native/token-counter/node_modules/possible-function/index.js +43 -0
- package/native/token-counter/node_modules/possible-function/license.txt +21 -0
- package/native/token-counter/node_modules/possible-function/package.json +34 -0
- package/native/token-counter/node_modules/possible-function/readme.md +77 -0
- package/native/token-counter/node_modules/possible-function/test.js +32 -0
- package/native/token-counter/node_modules/qfn/index.js +11 -0
- package/native/token-counter/node_modules/qfn/license.txt +21 -0
- package/native/token-counter/node_modules/qfn/package.json +40 -0
- package/native/token-counter/node_modules/qfn/readme.md +45 -0
- package/native/token-counter/node_modules/roadblock/index.js +3 -0
- package/native/token-counter/node_modules/roadblock/license.txt +21 -0
- package/native/token-counter/node_modules/roadblock/package.json +40 -0
- package/native/token-counter/node_modules/roadblock/readme.md +59 -0
- package/native/token-counter/node_modules/round-to/index.d.ts +56 -0
- package/native/token-counter/node_modules/round-to/index.js +37 -0
- package/native/token-counter/node_modules/round-to/license +9 -0
- package/native/token-counter/node_modules/round-to/package.json +38 -0
- package/native/token-counter/node_modules/round-to/readme.md +71 -0
- package/native/token-counter/node_modules/rtrim-array/index.js +10 -0
- package/native/token-counter/node_modules/rtrim-array/license.txt +21 -0
- package/native/token-counter/node_modules/rtrim-array/package.json +41 -0
- package/native/token-counter/node_modules/rtrim-array/readme.md +75 -0
- package/native/token-counter/node_modules/sbo/index.js +25 -0
- package/native/token-counter/node_modules/sbo/license.txt +21 -0
- package/native/token-counter/node_modules/sbo/package.json +50 -0
- package/native/token-counter/node_modules/sbo/readme.md +105 -0
- package/native/token-counter/node_modules/sorp/index.js +3 -0
- package/native/token-counter/node_modules/sorp/license.txt +21 -0
- package/native/token-counter/node_modules/sorp/package.json +34 -0
- package/native/token-counter/node_modules/sorp/readme.md +25 -0
- package/native/token-counter/node_modules/trim-call/index.js +6 -0
- package/native/token-counter/node_modules/trim-call/license.txt +21 -0
- package/native/token-counter/node_modules/trim-call/package.json +40 -0
- package/native/token-counter/node_modules/trim-call/readme.md +80 -0
- package/native/token-counter/node_modules/type-error/LICENSE +21 -0
- package/native/token-counter/node_modules/type-error/README.md +24 -0
- package/native/token-counter/node_modules/type-error/index.js +35 -0
- package/native/token-counter/node_modules/type-error/package.json +11 -0
- package/native/token-counter/node_modules/vfn/index.js +21 -0
- package/native/token-counter/node_modules/vfn/license.txt +21 -0
- package/native/token-counter/node_modules/vfn/package.json +40 -0
- package/native/token-counter/node_modules/vfn/readme.md +81 -0
- package/native/token-counter/node_modules/wfn/index.js +43 -0
- package/native/token-counter/node_modules/wfn/license.txt +21 -0
- package/native/token-counter/node_modules/wfn/package.json +38 -0
- package/native/token-counter/node_modules/wfn/readme.md +81 -0
- package/native/token-counter/package-lock.json +578 -0
- package/native/token-counter/package.json +21 -0
- package/native/token-counter/token-counter.linux-x64-gnu.node +0 -0
- package/package.json +98 -0
- package/scripts/build.cjs +27 -0
- package/scripts/deploy.sh +29 -0
- package/scripts/music.py +268 -0
- package/scripts/postinstall.mjs +81 -0
- package/scripts/push.sh +5 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('assert')
|
|
4
|
+
const {toArray, toIterator, toMap, toNumber, toObject, toString} = require('.')
|
|
5
|
+
|
|
6
|
+
describe('2', function () {
|
|
7
|
+
describe('#toArray()', function () {
|
|
8
|
+
it('should convert array to array', function () {
|
|
9
|
+
const array = []
|
|
10
|
+
assert.strictEqual(toArray(array), array)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('should convert arguments object to array', function () {
|
|
14
|
+
const array = ['first', 'second']
|
|
15
|
+
|
|
16
|
+
function argumentsTest () {
|
|
17
|
+
const args = toArray(arguments)
|
|
18
|
+
assert(Array.isArray(args))
|
|
19
|
+
assert.strictEqual(JSON.stringify(args), JSON.stringify(array))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
argumentsTest.apply(null, array)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should convert Map to array', function () {
|
|
26
|
+
const array = [['a', 'b']]
|
|
27
|
+
const map = new Map(array)
|
|
28
|
+
assert.strictEqual(JSON.stringify(toArray(map)), JSON.stringify(array))
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should `detectIndexKeys` of array-like Map', function () {
|
|
32
|
+
const map = new Map([[0, 'a'], ['1', 'b']])
|
|
33
|
+
assert.strictEqual(JSON.stringify(toArray(map, {detectIndexKeys: true})), JSON.stringify(['a', 'b']))
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should convert Set to array', function () {
|
|
37
|
+
const array = [1, 2, 3]
|
|
38
|
+
const set = new Set(array)
|
|
39
|
+
assert.strictEqual(JSON.stringify(toArray(set)), JSON.stringify(array))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should convert object to array of key/value pairs', function () {
|
|
43
|
+
const object = {a: 1, b: 2, c: 3}
|
|
44
|
+
const array = [['a', 1], ['b', 2], ['c', 3]]
|
|
45
|
+
assert.strictEqual(JSON.stringify(toArray(object)), JSON.stringify(array))
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should `detectIndexKeys` of array-like object', function () {
|
|
49
|
+
const object = {0: 'a', 1: 'b'}
|
|
50
|
+
assert.strictEqual(JSON.stringify(toArray(object, {detectIndexKeys: true})), JSON.stringify(['a', 'b']))
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should `detectIndexKeys` of array-like object with nonsequential keys', function () {
|
|
54
|
+
const object = {1: 'b', 0: 'a'}
|
|
55
|
+
assert.strictEqual(JSON.stringify(toArray(object, {detectIndexKeys: true})), JSON.stringify(['a', 'b']))
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should convert primitive value to single-element array', function () {
|
|
59
|
+
assert.strictEqual(JSON.stringify(toArray('test')), JSON.stringify(['test']))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
for (const value of [undefined, null, NaN]) { // eslint-disable-line no-undefined
|
|
63
|
+
it(`should convert ${value} to empty array`, function () {
|
|
64
|
+
assert.strictEqual(JSON.stringify(toArray(value)), JSON.stringify([]))
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('#toIterator()', function () {
|
|
70
|
+
it('should convert primitive value to single-run iterator', function () {
|
|
71
|
+
const iterator = toIterator('test')
|
|
72
|
+
assert.strictEqual(typeof iterator, 'object')
|
|
73
|
+
assert.strictEqual(typeof iterator.next, 'function')
|
|
74
|
+
let r = iterator.next()
|
|
75
|
+
assert.notEqual(r.done, true)
|
|
76
|
+
assert.strictEqual(r.value, 'test')
|
|
77
|
+
r = iterator.next()
|
|
78
|
+
assert.strictEqual(r.done, true)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const valueTests = [
|
|
82
|
+
['should convert array to iterator', [1, 2]],
|
|
83
|
+
['should convert Set to iterator', new Set([1, 2])],
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
for (const [description, object] of valueTests) {
|
|
87
|
+
it(description, function () {
|
|
88
|
+
const iterator = toIterator(object)
|
|
89
|
+
assert.strictEqual(typeof iterator, 'object')
|
|
90
|
+
assert.strictEqual(typeof iterator.next, 'function')
|
|
91
|
+
let r = iterator.next()
|
|
92
|
+
assert.notEqual(r.done, true)
|
|
93
|
+
assert.strictEqual(r.value, 1)
|
|
94
|
+
r = iterator.next()
|
|
95
|
+
assert.notEqual(r.done, true)
|
|
96
|
+
assert.strictEqual(r.value, 2)
|
|
97
|
+
r = iterator.next()
|
|
98
|
+
assert.strictEqual(r.done, true)
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const keyValueTests = [
|
|
103
|
+
['should convert Map to iterator', new Map([['a', 1], ['b', 2]])],
|
|
104
|
+
['should convert object to iterator', {a: 1, b: 2}],
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
for (const [description, object] of keyValueTests) {
|
|
108
|
+
it(description, function () {
|
|
109
|
+
const iterator = toIterator(object)
|
|
110
|
+
assert.strictEqual(typeof iterator, 'object')
|
|
111
|
+
assert.strictEqual(typeof iterator.next, 'function')
|
|
112
|
+
let r = iterator.next()
|
|
113
|
+
assert.notEqual(r.done, true)
|
|
114
|
+
assert(Array.isArray(r.value))
|
|
115
|
+
assert.strictEqual(r.value.length, 2)
|
|
116
|
+
assert.strictEqual(r.value[0], 'a')
|
|
117
|
+
assert.strictEqual(r.value[1], 1)
|
|
118
|
+
r = iterator.next()
|
|
119
|
+
assert.notEqual(r.done, true)
|
|
120
|
+
assert(Array.isArray(r.value))
|
|
121
|
+
assert.strictEqual(r.value.length, 2)
|
|
122
|
+
assert.strictEqual(r.value[0], 'b')
|
|
123
|
+
assert.strictEqual(r.value[1], 2)
|
|
124
|
+
r = iterator.next()
|
|
125
|
+
assert.strictEqual(r.done, true)
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const value of [undefined, null, NaN]) { // eslint-disable-line no-undefined
|
|
130
|
+
it(`should convert ${value} to empty iterator`, function () {
|
|
131
|
+
const iterator = toIterator(value)
|
|
132
|
+
assert.strictEqual(typeof iterator, 'object')
|
|
133
|
+
const r = iterator.next()
|
|
134
|
+
assert.strictEqual(r.done, true)
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('#toMap()', function () {
|
|
140
|
+
it('should convert Map to Map', function () {
|
|
141
|
+
assert(toMap(new Map()) instanceof Map)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('should convert array of key/value pairs to Map', function () {
|
|
145
|
+
const map = toMap([['a', 1], ['b', 2]])
|
|
146
|
+
assert.strictEqual(map.get('a'), 1)
|
|
147
|
+
assert.strictEqual(map.get('b'), 2)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('should convert values-only array to Map', function () {
|
|
151
|
+
const a = {}
|
|
152
|
+
const b = []
|
|
153
|
+
const map = toMap([a, b])
|
|
154
|
+
assert.strictEqual(map.get(0), a)
|
|
155
|
+
assert.strictEqual(map.get(1), b)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('should `mirror` array across keys and values', function () {
|
|
159
|
+
const map = toMap(['100', 200], {mirror: true})
|
|
160
|
+
assert.strictEqual(map.get('100'), '100')
|
|
161
|
+
assert.strictEqual(map.get(200), 200)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should convert object to Map', function () {
|
|
165
|
+
const map = toMap({a: 1, b: 2})
|
|
166
|
+
assert.strictEqual(map.get('a'), 1)
|
|
167
|
+
assert.strictEqual(map.get('b'), 2)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('should convert primitive value to empty Map', function () {
|
|
171
|
+
const map = toMap('not a map')
|
|
172
|
+
assert(map instanceof Map)
|
|
173
|
+
assert.strictEqual(map.size, 0)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('should return the provided fallback if input is unconvertible', function () {
|
|
177
|
+
const map = toMap('not a map', {fallback: new Map([['a', 1], ['b', 2]])})
|
|
178
|
+
assert.strictEqual(map.get('a'), 1)
|
|
179
|
+
assert.strictEqual(map.get('b'), 2)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('should throw error if input is unconvertible and fallback is not a Map', function () {
|
|
183
|
+
assert.throws(() => { toMap('not a map', {fallback: null}) }, TypeError)
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
describe('#toNumber()', function () {
|
|
188
|
+
it('should convert number to number', function () {
|
|
189
|
+
assert.strictEqual(toNumber(1), 1)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('should convert Number object to number', function () {
|
|
193
|
+
assert.strictEqual(toNumber(new Number(1)), 1) // eslint-disable-line no-new-wrappers
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('should convert integer string to number', function () {
|
|
197
|
+
assert.strictEqual(toNumber('100'), 100)
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('should convert integer String object to number', function () {
|
|
201
|
+
assert.strictEqual(toNumber(new String('100')), 100) // eslint-disable-line no-new-wrappers
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('should convert float string to number', function () {
|
|
205
|
+
assert.strictEqual(toNumber('1.2'), 1.2)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('should round float to integer if `round` is true', function () {
|
|
209
|
+
assert.strictEqual(toNumber(4.7, {round: true}), 5)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('should return fallback (default 0) for Infinity', function () {
|
|
213
|
+
assert.strictEqual(toNumber(Infinity), 0)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('should allow +Infinity if `finite` is false', function () {
|
|
217
|
+
assert.strictEqual(toNumber(Infinity, {finite: false}), Infinity)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('should allow -Infinity if `finite` is false', function () {
|
|
221
|
+
assert.strictEqual(toNumber(-Infinity, {finite: false}), -Infinity)
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('should return fallback (default 0) for NaN', function () {
|
|
225
|
+
assert.strictEqual(toNumber(NaN), 0)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('should return 0 if number is invalid and no fallback provided', function () {
|
|
229
|
+
assert.strictEqual(toNumber('not a number'), 0)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('should return the provided fallback if number is invalid', function () {
|
|
233
|
+
assert.strictEqual(toNumber('not a number', {fallback: 2}), 2)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('should round fallback if `round` is true', function () {
|
|
237
|
+
assert.strictEqual(toNumber({}, {fallback: 3.3, round: true}), 3)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('should convert Number object fallback to primitive number', function () {
|
|
241
|
+
assert.strictEqual(typeof toNumber({}, {fallback: new Number(1)}), 'number') // eslint-disable-line no-new-wrappers
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('should throw error if number is invalid and fallback is not a number', function () {
|
|
245
|
+
assert.throws(() => { toNumber('not a number', {fallback: null}) }, TypeError)
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
describe('#toObject()', function () {
|
|
250
|
+
it('should convert object to object', function () {
|
|
251
|
+
const object = {a: 1, b: 2}
|
|
252
|
+
assert.strictEqual(JSON.stringify(toObject(object)), JSON.stringify(object))
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('should convert array of key/value pairs to object', function () {
|
|
256
|
+
const object = toObject([['a', 1], ['b', 2]])
|
|
257
|
+
assert.strictEqual(object.a, 1)
|
|
258
|
+
assert.strictEqual(object.b, 2)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
it('should convert array of strings to object with numerical keys', function () {
|
|
262
|
+
const object = toObject(['a', 'b'])
|
|
263
|
+
assert.strictEqual(object[0], 'a')
|
|
264
|
+
assert.strictEqual(object[1], 'b')
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('should `mirror` string array across keys and values', function () {
|
|
268
|
+
const object = toObject(['100', '200'], {mirror: true})
|
|
269
|
+
assert.strictEqual(object[100], '100')
|
|
270
|
+
assert.strictEqual(object[200], '200')
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
it('should only `mirror` values to keys if all values can be object keys', function () {
|
|
274
|
+
const nonKeyable = {}
|
|
275
|
+
const object = toObject(['100', nonKeyable], {mirror: true})
|
|
276
|
+
assert.strictEqual(object[0], '100')
|
|
277
|
+
assert.strictEqual(object[1], nonKeyable)
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
it('should convert Map to object', function () {
|
|
281
|
+
const object = toObject(new Map([['a', 1], ['b', 2]]))
|
|
282
|
+
assert.strictEqual(object.a, 1)
|
|
283
|
+
assert.strictEqual(object.b, 2)
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
it('should convert primitive value to empty object', function () {
|
|
287
|
+
assert.strictEqual(JSON.stringify(toObject('not an object')), JSON.stringify({}))
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
it('should return the provided fallback if input is unconvertible', function () {
|
|
291
|
+
assert.strictEqual(JSON.stringify(toObject('not an object', {fallback: {a: 1}})), JSON.stringify({a: 1}))
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('should throw error if input is unconvertible and fallback is not object', function () {
|
|
295
|
+
assert.throws(() => { toObject('not an object', {fallback: null}) }, TypeError)
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('should throw error if Map has keys that are not strings/numbers', function () {
|
|
299
|
+
assert.throws(() => { toObject(new Map([{}, 'test'])) }, TypeError)
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
describe('#toString()', function () {
|
|
304
|
+
it('should convert string to string', function () {
|
|
305
|
+
assert.strictEqual(toString('test'), 'test')
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it('should convert String object to string', function () {
|
|
309
|
+
assert.strictEqual(typeof toString(new String('test')), typeof 'test') // eslint-disable-line no-new-wrappers
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('should convert number to string', function () {
|
|
313
|
+
assert.strictEqual(toString(-123), '-123')
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
it('should convert 0 to "0"', function () {
|
|
317
|
+
assert.strictEqual(toString(0), '0')
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
it('should convert -0 to "0"', function () {
|
|
321
|
+
assert.strictEqual(toString(-0), '0')
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('should convert NaN to empty string', function () {
|
|
325
|
+
assert.strictEqual(toString(NaN), '')
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('should convert Infinity to empty string', function () {
|
|
329
|
+
assert.strictEqual(toString(Infinity), '')
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('should convert true to empty string', function () {
|
|
333
|
+
assert.strictEqual(toString(true), '')
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
it('should convert false to empty string', function () {
|
|
337
|
+
assert.strictEqual(toString(true), '')
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
it('should convert null to empty string', function () {
|
|
341
|
+
assert.strictEqual(toString(null), '')
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it('should convert undefined to empty string', function () {
|
|
345
|
+
assert.strictEqual(toString(undefined), '') // eslint-disable-line no-undefined
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
it('should convert function to empty string', function () {
|
|
349
|
+
assert.strictEqual(toString(function () {}), '')
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
it('should convert array to empty string', function () {
|
|
353
|
+
assert.strictEqual(toString([]), '')
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
it('should convert plain object to empty string', function () {
|
|
357
|
+
assert.strictEqual(toString({}), '')
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
it('should convert symbol to empty string', function () {
|
|
361
|
+
assert.strictEqual(toString(Symbol('test')), '')
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it('should convert object to string using object’s custom toString() method', function () {
|
|
365
|
+
class TestClass {
|
|
366
|
+
toString () {
|
|
367
|
+
return 'string value'
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const object = new TestClass()
|
|
371
|
+
assert.strictEqual(toString(object), 'string value')
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
it('should return the provided fallback if input is unconvertible', function () {
|
|
375
|
+
assert.strictEqual(toString({}, {fallback: 'test'}), 'test')
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
it('should convert String object fallback to primitive string', function () {
|
|
379
|
+
assert.strictEqual(typeof toString({}, {fallback: new String('test')}), 'string') // eslint-disable-line no-new-wrappers
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
it('should throw error if input is unconvertible and fallback is not string', function () {
|
|
383
|
+
assert.throws(() => { toString({}, {fallback: null}) }, TypeError)
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
it('should result in object surviving multiple chained conversions', function () {
|
|
388
|
+
let data = {a: 1, b: 2}
|
|
389
|
+
data = toMap(data)
|
|
390
|
+
data = toArray(data)
|
|
391
|
+
data = toObject(data)
|
|
392
|
+
data = toIterator(data)
|
|
393
|
+
data = toArray(data)
|
|
394
|
+
data = toMap(data)
|
|
395
|
+
data = toObject(data)
|
|
396
|
+
assert.strictEqual(Object.keys(data).length, 2)
|
|
397
|
+
assert.strictEqual(data.a, 1)
|
|
398
|
+
assert.strictEqual(data.b, 2)
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
it('should result in array surviving multiple chained conversions', function () {
|
|
402
|
+
let data = ['first', 'second']
|
|
403
|
+
data = toMap(data)
|
|
404
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
405
|
+
data = toObject(data)
|
|
406
|
+
data = toIterator(data)
|
|
407
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
408
|
+
data = toMap(data)
|
|
409
|
+
data = toObject(data)
|
|
410
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
411
|
+
assert.strictEqual(JSON.stringify(data), JSON.stringify(['first', 'second']))
|
|
412
|
+
})
|
|
413
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "enforce-range",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Enforce a minimum and/or maximum value for a number.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"number",
|
|
7
|
+
"range",
|
|
8
|
+
"min",
|
|
9
|
+
"minimum",
|
|
10
|
+
"max",
|
|
11
|
+
"maximum",
|
|
12
|
+
"value"
|
|
13
|
+
],
|
|
14
|
+
"author": "John Lamansky",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"homepage": "https://github.com/lamansky/enforce-range",
|
|
17
|
+
"repository": "lamansky/enforce-range",
|
|
18
|
+
"main": "index.js",
|
|
19
|
+
"files": [],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"2": "^1.0.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"eslint-config-lamansky": "^1.0.0",
|
|
25
|
+
"mocha": "^4.0.1"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "mocha"
|
|
29
|
+
},
|
|
30
|
+
"eslintConfig": {
|
|
31
|
+
"extends": "lamansky",
|
|
32
|
+
"env": {
|
|
33
|
+
"mocha": true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# enforce-range
|
|
2
|
+
|
|
3
|
+
Enforce a minimum and/or maximum value for a number.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install enforce-range --save
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const enforceRange = require('enforce-range')
|
|
15
|
+
|
|
16
|
+
// Number should be between 0 and 100
|
|
17
|
+
enforceRange(0, 100, 51) // 51
|
|
18
|
+
enforceRange(0, 100, -123) // 0
|
|
19
|
+
enforceRange(0, 100, 456) // 100
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Partial Application
|
|
23
|
+
|
|
24
|
+
If you provide only the first two arguments (a minimum and a maximum value), the module will create a partially-applied function which enforces that range. Here's the above example repeated with this usage mode:
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const enforce0to100 = require('enforce-range')(0, 100)
|
|
28
|
+
|
|
29
|
+
// Number should be between 0 and 100
|
|
30
|
+
enforce0to100(51) // 51
|
|
31
|
+
enforce0to100(-123) // 0
|
|
32
|
+
enforce0to100(456) // 100
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Open-Ended Ranges
|
|
36
|
+
|
|
37
|
+
If, for some reason, you want this module to enforce a range that is only bound on one end, you can do so by passing `null` or ±`Infinity` as the minimum/maximum value. (However, in such a case you’re probably better off cutting the overhead of using a module and just using `Math.min()` or `Math.max()`.)
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const enforceRange = require('enforce-range')
|
|
41
|
+
|
|
42
|
+
// Maximum only
|
|
43
|
+
enforceRange(null, 100, 200) // 100
|
|
44
|
+
enforceRange(-Infinity, 100, 200) // 100
|
|
45
|
+
|
|
46
|
+
// Minimum only
|
|
47
|
+
enforceRange(0, null, 51) // 51
|
|
48
|
+
enforceRange(0, Infinity, 51) // 51
|
|
49
|
+
|
|
50
|
+
// No range enforcement at all (module does nothing)
|
|
51
|
+
enforceRange(null, null, 12345) // 12345
|
|
52
|
+
enforceRange(-Infinity, Infinity, 12345) // 12345
|
|
53
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Kyle E. Mitchell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included
|
|
14
|
+
in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Make "X, Y, and Z"-style lists from arrays.
|
|
2
|
+
|
|
3
|
+
```javascript
|
|
4
|
+
var list = require('english-list')
|
|
5
|
+
var assert = require('assert')
|
|
6
|
+
|
|
7
|
+
assert.equal(
|
|
8
|
+
list('and', ['John']),
|
|
9
|
+
'John'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
assert.equal(
|
|
13
|
+
list('and', ['John', 'Paul']),
|
|
14
|
+
'John and Paul'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
assert.equal(
|
|
18
|
+
list('and', ['John', 'Paul', 'George']),
|
|
19
|
+
'John, Paul, and George'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
assert.equal(
|
|
23
|
+
list('and', ['John', 'Paul', 'George'], false),
|
|
24
|
+
'John, Paul and George'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
assert.equal(
|
|
28
|
+
list('and', ['John', 'Paul', 'George'], true),
|
|
29
|
+
'John, Paul, and George'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
assert.equal(
|
|
33
|
+
list('or', ['John', 'Paul', 'George']),
|
|
34
|
+
'John, Paul, or George'
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
assert.throws(function () {
|
|
38
|
+
list('and', null)
|
|
39
|
+
}, TypeError)
|
|
40
|
+
|
|
41
|
+
assert.throws(function () {
|
|
42
|
+
list('and', [])
|
|
43
|
+
}, Error)
|
|
44
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module.exports = function (conjunction, array, serialComma) {
|
|
2
|
+
if (!Array.isArray(array) || !conjunction.toString) {
|
|
3
|
+
throw new TypeError()
|
|
4
|
+
}
|
|
5
|
+
conjunction = conjunction.toString()
|
|
6
|
+
serialComma = serialComma === undefined ? true : !!serialComma
|
|
7
|
+
var length = array.length
|
|
8
|
+
if (length === 0) {
|
|
9
|
+
throw new Error('Cannot create an English list of an empty array')
|
|
10
|
+
} else if (length === 1) {
|
|
11
|
+
return array[0].toString()
|
|
12
|
+
} else if (length === 2) {
|
|
13
|
+
return (
|
|
14
|
+
array[0].toString() +
|
|
15
|
+
' ' +
|
|
16
|
+
conjunction +
|
|
17
|
+
' ' +
|
|
18
|
+
array[1].toString()
|
|
19
|
+
)
|
|
20
|
+
} else {
|
|
21
|
+
var strings = array.map(function (element) {
|
|
22
|
+
return element.toString()
|
|
23
|
+
})
|
|
24
|
+
var front = strings.slice(0, length - 1)
|
|
25
|
+
var last = strings[length - 1]
|
|
26
|
+
return (
|
|
27
|
+
front.join(', ') +
|
|
28
|
+
(serialComma ? ', ' : ' ') +
|
|
29
|
+
conjunction +
|
|
30
|
+
' ' +
|
|
31
|
+
last
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "english-list",
|
|
3
|
+
"description": "make \"X, Y, and Z\"-style lists from arrays",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)",
|
|
6
|
+
"bugs": "https://github.com/kemitchell/english-list.js/issues",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"defence-cli": "^2.0.1",
|
|
9
|
+
"literate-assertions": "^0.1.1",
|
|
10
|
+
"replace-require-self": "^1.1.1",
|
|
11
|
+
"standard": "^10.0.3",
|
|
12
|
+
"standard-markdown": "^4.0.2"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/kemitchell/english-list.js",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"array",
|
|
17
|
+
"conjunction",
|
|
18
|
+
"English",
|
|
19
|
+
"enumeration",
|
|
20
|
+
"language",
|
|
21
|
+
"list",
|
|
22
|
+
"natural"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": "kemitchell/english-list.js",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"travis-ci": "npm run test",
|
|
28
|
+
"lint": "standard && standard-markdown",
|
|
29
|
+
"test": "defence -i javascript README.md | replace-require-self | node"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const copyOwn = require('copy-own')
|
|
4
|
+
const isClassOf = require('is-class-of')
|
|
5
|
+
const is = require('is-instance-of')
|
|
6
|
+
const trimCall = require('trim-call')
|
|
7
|
+
|
|
8
|
+
module.exports = function errate (e, Cls = Error, {defaultMessage, forceClass = true} = {}) {
|
|
9
|
+
if (isClassOf(e, 'Error')) {
|
|
10
|
+
Cls = e
|
|
11
|
+
e = null
|
|
12
|
+
} else if (!isClassOf(Cls, 'Error')) {
|
|
13
|
+
throw new TypeError('Invalid error class')
|
|
14
|
+
}
|
|
15
|
+
if (!e || e === true) return trimCall.new(Cls, defaultMessage)
|
|
16
|
+
if (is(e, Cls)) return e
|
|
17
|
+
if (is(e, 'Error')) return forceClass ? copyOwn(e, new Cls()) : e
|
|
18
|
+
return new Cls(e)
|
|
19
|
+
}
|