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,109 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const otherwise = require('otherwise')
|
|
4
|
+
const roundTo = require('round-to')
|
|
5
|
+
const sbo = require('sbo')
|
|
6
|
+
|
|
7
|
+
const thousandsSepOnly = [' ', '\u2009', "'"]
|
|
8
|
+
const numberDigits = '0123456789'
|
|
9
|
+
|
|
10
|
+
const infinities = [
|
|
11
|
+
['infinity', '+infinity'],
|
|
12
|
+
['-infinity', '\u2212infinity'],
|
|
13
|
+
]
|
|
14
|
+
const suffixes = ['kg', 'm', 'b']
|
|
15
|
+
|
|
16
|
+
const stringToNumber = require('parser-factory')('main', {
|
|
17
|
+
main ({char, consume, consumeRest, shift}, {userArgs: [{decimalComma, decimalPlacesInInt, ignoreBadChars} = {}]}) {
|
|
18
|
+
let thousandsSep = ''
|
|
19
|
+
let decimalSep = ''
|
|
20
|
+
let decimals = ''
|
|
21
|
+
let units = ''
|
|
22
|
+
let group = ''
|
|
23
|
+
let sign = 1
|
|
24
|
+
|
|
25
|
+
let leftParen
|
|
26
|
+
const rightParen = consume(')')
|
|
27
|
+
|
|
28
|
+
for (const [i, s] of suffixes.entries()) {
|
|
29
|
+
if (consume(...s)) {
|
|
30
|
+
units = '000'.repeat(i + 1)
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
while (char()) {
|
|
36
|
+
const sep = consume(',', '.', ...thousandsSepOnly)
|
|
37
|
+
if (sep) {
|
|
38
|
+
if (!decimals && !thousandsSep && !thousandsSepOnly.includes(sep)) {
|
|
39
|
+
decimalSep = sep
|
|
40
|
+
decimals = units
|
|
41
|
+
units = ''
|
|
42
|
+
group = ''
|
|
43
|
+
} else if ((group.length !== 3 && !(group.length === 2 && units.length >= 5 && (units - 3) % 2 === 0)) || (thousandsSep && thousandsSep !== sep && !(thousandsSep === '.' && sep === ' ')) || (decimalSep && decimalSep === sep)) {
|
|
44
|
+
if (!ignoreBadChars) return NaN
|
|
45
|
+
} else {
|
|
46
|
+
if (!thousandsSep) thousandsSep = sep
|
|
47
|
+
group = ''
|
|
48
|
+
}
|
|
49
|
+
} else if (consumeRest('-', '\u2212')) {
|
|
50
|
+
sign = -1
|
|
51
|
+
} else if (rightParen && consumeRest('(')) {
|
|
52
|
+
sign = -1
|
|
53
|
+
leftParen = true
|
|
54
|
+
} else {
|
|
55
|
+
const n = shift(1)
|
|
56
|
+
if (numberDigits.includes(n)) {
|
|
57
|
+
units = n + units
|
|
58
|
+
group = n + group
|
|
59
|
+
} else if (!ignoreBadChars) {
|
|
60
|
+
return NaN
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!ignoreBadChars && rightParen && !leftParen) return NaN
|
|
66
|
+
|
|
67
|
+
if (decimals.length === 3 && decimalSep && !thousandsSep && !decimalComma === (decimalSep === ',')) {
|
|
68
|
+
units += decimals
|
|
69
|
+
decimals = ''
|
|
70
|
+
} else if (decimals) {
|
|
71
|
+
if (decimalPlacesInInt > 0) {
|
|
72
|
+
decimals = decimals.substr(0, decimalPlacesInInt).padEnd(2, '0')
|
|
73
|
+
} else {
|
|
74
|
+
decimals = '.' + decimals
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const n = units + decimals
|
|
79
|
+
if (!n.length) return NaN
|
|
80
|
+
return sign * Number(n)
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
module.exports = sbo(function toNumber (x, {decimalComma, decimalPlacesInInt, elseCall, elseReturn = 0, elseThrow, finite = true, ignoreBadChars, round = false} = {}) {
|
|
85
|
+
if (x instanceof String) x = String(x)
|
|
86
|
+
if (typeof x === 'string') {
|
|
87
|
+
x = x.toLowerCase()
|
|
88
|
+
|
|
89
|
+
const testForInfinityString = positive => infinities[+!positive].some(
|
|
90
|
+
ignoreBadChars ? inf => x.includes(inf) : inf => x === inf,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
x = testForInfinityString(true) ? Infinity
|
|
94
|
+
: testForInfinityString(false) ? -Infinity
|
|
95
|
+
: stringToNumber(
|
|
96
|
+
x.split('').reverse().join(''),
|
|
97
|
+
{decimalComma, decimalPlacesInInt, ignoreBadChars},
|
|
98
|
+
)
|
|
99
|
+
} else if (x !== null) {
|
|
100
|
+
x = Number(x)
|
|
101
|
+
}
|
|
102
|
+
if (x === null || Number.isNaN(x) || (finite && !Number.isFinite(x))) {
|
|
103
|
+
return otherwise({elseCall, elseReturn, elseThrow}, {defaultErrorClass: TypeError})
|
|
104
|
+
}
|
|
105
|
+
if (!decimalPlacesInInt && (round || round === 0)) {
|
|
106
|
+
return roundTo(x, round === true ? 0 : +round)
|
|
107
|
+
}
|
|
108
|
+
return x
|
|
109
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const addCounter = require('add-counter')
|
|
4
|
+
const every = require('@lamansky/every')
|
|
5
|
+
const isArrayOfLength = require('is-array-of-length')
|
|
6
|
+
const isInstanceOf = require('is-instance-of')
|
|
7
|
+
const isIterable = require('is-iterable')
|
|
8
|
+
const isObject = require('is-object')
|
|
9
|
+
const map = require('map-iter')
|
|
10
|
+
const newObject = require('new-object')
|
|
11
|
+
const otherwise = require('otherwise')
|
|
12
|
+
const sbo = require('sbo')
|
|
13
|
+
|
|
14
|
+
module.exports = sbo(function toObject (x, {arrays = [], descriptors: descDefaults, elseCall, elseReturn = {}, elseThrow, maps = [], mirror = false, throwIfEquivKeys = true} = {}) {
|
|
15
|
+
if (isInstanceOf(x, [Map, maps])) return newObject(x.entries(), {descDefaults, throwIfEquivKeys})
|
|
16
|
+
if (isIterable(x) && typeof x !== 'string') {
|
|
17
|
+
if (every(x, el => isArrayOfLength(el, 2))) return newObject(x, {descDefaults, throwIfEquivKeys})
|
|
18
|
+
if (mirror) return newObject(map(x, v => [v, v]), {descDefaults, throwIfEquivKeys})
|
|
19
|
+
return newObject(addCounter(x), {descDefaults})
|
|
20
|
+
}
|
|
21
|
+
if (isObject(x)) return x
|
|
22
|
+
return otherwise({elseCall, elseReturn, elseThrow}, {defaultErrorClass: TypeError})
|
|
23
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "2",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "The Type Conversion Library. Numbers, Strings, Arrays, Maps, Objects, and Iterators.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"type",
|
|
7
|
+
"convert",
|
|
8
|
+
"conversion",
|
|
9
|
+
"to",
|
|
10
|
+
"array",
|
|
11
|
+
"iterator",
|
|
12
|
+
"map",
|
|
13
|
+
"number",
|
|
14
|
+
"int",
|
|
15
|
+
"integer",
|
|
16
|
+
"float",
|
|
17
|
+
"object",
|
|
18
|
+
"string"
|
|
19
|
+
],
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Fr. John Lamansky",
|
|
22
|
+
"url": "lamansky.com"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"homepage": "https://github.com/lamansky/2",
|
|
26
|
+
"repository": "lamansky/2",
|
|
27
|
+
"main": "index.js",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=8.3.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@lamansky/every": "^1.0.0",
|
|
33
|
+
"add-counter": "^1.0.0",
|
|
34
|
+
"empty-iterator": "^1.0.0",
|
|
35
|
+
"is-array-of-length": "^1.0.0",
|
|
36
|
+
"is-instance-of": "^1.0.2",
|
|
37
|
+
"is-iterable": "^1.1.1",
|
|
38
|
+
"is-nil": "^1.0.1",
|
|
39
|
+
"is-object": "^1.0.1",
|
|
40
|
+
"map-iter": "^1.0.0",
|
|
41
|
+
"new-object": "^4.0.0",
|
|
42
|
+
"otherwise": "^2.0.0",
|
|
43
|
+
"parser-factory": "^1.1.0",
|
|
44
|
+
"round-to": "^4.0.0",
|
|
45
|
+
"sbo": "^1.1.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"eslint-config-lamansky": "^2.0.0",
|
|
49
|
+
"mocha": "^6.2.2"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"test": "mocha"
|
|
53
|
+
},
|
|
54
|
+
"eslintConfig": {
|
|
55
|
+
"extends": "lamansky",
|
|
56
|
+
"env": {
|
|
57
|
+
"mocha": true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# “2”: The Type Conversion Library
|
|
2
|
+
|
|
3
|
+
A [Node.js](https://nodejs.org/) module for converting between various JavaScript types: arrays, iterators, maps, numbers, objects, and strings.
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
const {toArray, toIterator, toMap, toNumber, toObject, toString} = require('2')
|
|
7
|
+
|
|
8
|
+
const obj = {a: 1, b: 2}
|
|
9
|
+
obj::toMap()::toArray()::toObject()::toIterator()
|
|
10
|
+
::toArray()::toMap()::toObject() // {a: 1, b: 2}
|
|
11
|
+
|
|
12
|
+
let data = '1.23'
|
|
13
|
+
data = toNumber(data)
|
|
14
|
+
data = toString(data) // '1.23'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Requires [Node.js](https://nodejs.org/) 8.3.0 or above.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i 2
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Requiring the Functions
|
|
28
|
+
|
|
29
|
+
You can require needed functions via a destructuring assignment:
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const {toArray, toIterator, toMap, toNumber, toObject, toString} = require('2')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
(If your project has a linting rule that precludes shadowing the global `toString` function, you can also destructure the `toStr` function, which is the same as `toString`.)
|
|
36
|
+
|
|
37
|
+
You can also require individual functions via submodules:
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const toArray = require('2/array')
|
|
41
|
+
const toIterator = require('2/iterator')
|
|
42
|
+
const toMap = require('2/map')
|
|
43
|
+
const toNumber = require('2/number')
|
|
44
|
+
const toObject = require('2/object')
|
|
45
|
+
const toString = require('2/string')
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Converting to Arrays
|
|
49
|
+
```javascript
|
|
50
|
+
const toArray = require('2/array')
|
|
51
|
+
|
|
52
|
+
// Map => Array
|
|
53
|
+
const map = new Map()
|
|
54
|
+
map.set('a', 1)
|
|
55
|
+
map.set('b', 2)
|
|
56
|
+
toArray(map) // [['a', 1], ['b', 2]]
|
|
57
|
+
|
|
58
|
+
// Iterator => Array
|
|
59
|
+
toArray(map.values()) // [1, 2]
|
|
60
|
+
|
|
61
|
+
// Object => Array
|
|
62
|
+
toArray({a: 1, b: 2}) // [['a', 1], ['b', 2]]
|
|
63
|
+
|
|
64
|
+
// Array-like object => Array
|
|
65
|
+
toArray({0: 'first', 1: 'second'}, {detectIndexKeys: true}) // ['first', 'second']
|
|
66
|
+
|
|
67
|
+
// Primitive value => Array
|
|
68
|
+
toArray('test') // ['test']
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Converting to Iterators
|
|
72
|
+
```javascript
|
|
73
|
+
const toIterator = require('2/iterator')
|
|
74
|
+
|
|
75
|
+
// Object => Iterator
|
|
76
|
+
let iterator = toIterator({a: 1, b: 2})
|
|
77
|
+
iterator.next().value // ['a', 1]
|
|
78
|
+
iterator.next().value // ['b', 2]
|
|
79
|
+
iterator.next().done // true
|
|
80
|
+
|
|
81
|
+
// Primitive value => Iterator
|
|
82
|
+
toIterator('test').next().value // 'test'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Converting to Maps
|
|
86
|
+
```javascript
|
|
87
|
+
const toMap = require('2/map')
|
|
88
|
+
|
|
89
|
+
// Array of key/value pairs => Map
|
|
90
|
+
const map1 = toMap([['a', 1], ['b', 2]])
|
|
91
|
+
map1.get('a') // 1
|
|
92
|
+
map1.get('b') // 2
|
|
93
|
+
|
|
94
|
+
// Array of values => Map
|
|
95
|
+
const map2 = toMap(['a', 'b'])
|
|
96
|
+
map2.get(0) // 'a'
|
|
97
|
+
map2.get(1) // 'b'
|
|
98
|
+
|
|
99
|
+
// Object => Map
|
|
100
|
+
const map3 = toMap({a: 1, b: 2})
|
|
101
|
+
map3.get('a') // 1
|
|
102
|
+
map3.get('b') // 2
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Converting to Numbers
|
|
106
|
+
```javascript
|
|
107
|
+
const toNumber = require('2/number')
|
|
108
|
+
|
|
109
|
+
toNumber('1.2') // 1.2
|
|
110
|
+
toNumber(Infinity) // 0
|
|
111
|
+
toNumber(NaN) // 0
|
|
112
|
+
toNumber('not a number') // 0
|
|
113
|
+
|
|
114
|
+
// Can specify a fallback other than zero:
|
|
115
|
+
toNumber('not a number', {elseReturn: 100}) // 100
|
|
116
|
+
|
|
117
|
+
// You can choose to throw an error for invalid inputs.
|
|
118
|
+
toNumber('not a number', {elseThrow: true}) // throws error
|
|
119
|
+
toNumber('not a number', {elseThrow: new TypeError('Not a number!')})
|
|
120
|
+
|
|
121
|
+
// Option to round floats:
|
|
122
|
+
toNumber('4.7') // 4.7
|
|
123
|
+
toNumber('4.7', {round: true}) // 5
|
|
124
|
+
|
|
125
|
+
// By default, Infinity is not considered a valid number,
|
|
126
|
+
// but this can be changed:
|
|
127
|
+
toNumber(Infinity) // 0
|
|
128
|
+
toNumber(Infinity, {finite: false}) // Infinity
|
|
129
|
+
|
|
130
|
+
// Number object => Number
|
|
131
|
+
const numberObject = new Number(123)
|
|
132
|
+
typeof numberObject // 'object'
|
|
133
|
+
typeof toNumber(numberObject) // 'number'
|
|
134
|
+
|
|
135
|
+
// Can parse strings that have digit grouping:
|
|
136
|
+
toNumber('1,234') // 1234
|
|
137
|
+
// The built-in Number function, on the other hand, cannot:
|
|
138
|
+
Number('1,234') // NaN
|
|
139
|
+
|
|
140
|
+
// Can be configured to interpret the comma as a decimal point:
|
|
141
|
+
toNumber('1,234', {decimalComma: true}) // 1.234
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Converting to Objects
|
|
145
|
+
```javascript
|
|
146
|
+
const toObject = require('2/object')
|
|
147
|
+
|
|
148
|
+
// Array of key/value pairs => Object
|
|
149
|
+
const obj1 = toObject([['a', 1], ['b', 2]])
|
|
150
|
+
obj1.a // 1
|
|
151
|
+
obj1.b // 2
|
|
152
|
+
|
|
153
|
+
// Array => Object
|
|
154
|
+
const obj2 = toObject(['first', 'second'])
|
|
155
|
+
Object.keys(obj2).length // 2
|
|
156
|
+
obj2[0] // 'first'
|
|
157
|
+
obj2[1] // 'second'
|
|
158
|
+
|
|
159
|
+
// In the above example, the array indices become the object keys.
|
|
160
|
+
// But you can make the keys mirror the values instead:
|
|
161
|
+
const obj3 = toObject(['first', 'second'], {mirror: true})
|
|
162
|
+
Object.keys(obj3).length // 2
|
|
163
|
+
obj3.first // 'first'
|
|
164
|
+
obj3.second // 'second'
|
|
165
|
+
|
|
166
|
+
// Map => Object
|
|
167
|
+
const map = new Map()
|
|
168
|
+
map.set('key1', 'value1')
|
|
169
|
+
map.set('key2', 'value2')
|
|
170
|
+
const obj4 = toObject(map)
|
|
171
|
+
obj4.key1 // 'value1'
|
|
172
|
+
obj4.key2 // 'value2'
|
|
173
|
+
|
|
174
|
+
// Duplicate keys
|
|
175
|
+
toObject([['key', 1], ['key', 2]]) // throws an error (default behavior)
|
|
176
|
+
const obj5 = toObject([['key', 1], ['key', 2]], {throwIfEquivKeys: false}) // error-throwing disabled
|
|
177
|
+
Object.keys(obj5).length // 1
|
|
178
|
+
obj5.key // 2
|
|
179
|
+
|
|
180
|
+
// Setting property descriptors
|
|
181
|
+
const obj6 = toObject([['a', 1], ['b', 2]], {descriptors: {enumerable: false}})
|
|
182
|
+
Object.keys(obj6).length // 0 (because the properties are non-enumerable)
|
|
183
|
+
obj6.a // 1
|
|
184
|
+
obj6.b // 2
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Converting to Strings
|
|
188
|
+
```javascript
|
|
189
|
+
const toString = require('2/string')
|
|
190
|
+
|
|
191
|
+
toString(123) // '123'
|
|
192
|
+
toString(-0) // '0'
|
|
193
|
+
|
|
194
|
+
toString(true) // ''
|
|
195
|
+
toString(false) // ''
|
|
196
|
+
toString(undefined) // ''
|
|
197
|
+
toString(null) // ''
|
|
198
|
+
toString(Infinity) // ''
|
|
199
|
+
toString(NaN) // ''
|
|
200
|
+
toString({}) // ''
|
|
201
|
+
toString([]) // ''
|
|
202
|
+
toString(function () {}) // ''
|
|
203
|
+
toString(Symbol('test')) // ''
|
|
204
|
+
|
|
205
|
+
// Compare the above to standard JavaScript string conversion:
|
|
206
|
+
String(true) // 'true'
|
|
207
|
+
String(false) // 'false'
|
|
208
|
+
String(undefined) // 'undefined'
|
|
209
|
+
String(null) // 'null'
|
|
210
|
+
String(Infinity) // 'Infinity'
|
|
211
|
+
String(NaN) // 'NaN'
|
|
212
|
+
String({}) // '[object Object]'
|
|
213
|
+
String([]) // ''
|
|
214
|
+
String(function () {}) // 'function () {}'
|
|
215
|
+
String(Symbol('test')) // 'Symbol(test)'
|
|
216
|
+
|
|
217
|
+
// Default fallback is an empty string, but you can change it:
|
|
218
|
+
toString(undefined) // ''
|
|
219
|
+
toString(undefined, {elseReturn: 'N/A'}) // 'N/A'
|
|
220
|
+
|
|
221
|
+
// You can choose to throw an error for invalid inputs.
|
|
222
|
+
toString(undefined, {elseThrow: true}) // throws error
|
|
223
|
+
|
|
224
|
+
// String object => String
|
|
225
|
+
const stringObject = new String('test')
|
|
226
|
+
typeof stringObject // 'object'
|
|
227
|
+
typeof toString(stringObject) // 'string'
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Version Migration Guide
|
|
231
|
+
|
|
232
|
+
Here are backward-incompatible changes you need to know about.
|
|
233
|
+
|
|
234
|
+
### 2.x ⇒ 3.x
|
|
235
|
+
|
|
236
|
+
* The minimum supported Node version is now 8.3.0 (instead of 7.0.0).
|
|
237
|
+
* `toNumber` no lounger rounds the `elseReturn` value when `round` is `true`. If you need this behavior, apply `Math.round` to your `elseReturn` value manually.
|
|
238
|
+
* `toObject` will now throw an error if an entries array contains duplicate keys. In version 2, the last equivalent key would have silently overwritten the prior ones. You can restore the previous behavior by setting the new `throwIfEquivKeys` option to `false`.
|
|
239
|
+
|
|
240
|
+
### 1.x ⇒ 2.x
|
|
241
|
+
|
|
242
|
+
* `fallback` has been renamed to `elseReturn`.
|
|
243
|
+
* Use `elseThrow: true` instead of `fallback: null`.
|
|
244
|
+
* Unlike the old `fallback` parameter, `elseReturn` does _not_ type-enforce its values.
|
|
245
|
+
* `toObject` with `mirror: true` will now throw an error if any key would overwrite another key. In version 1, this would have been allowed.
|
|
246
|
+
* `toObject` with `mirror: true` will now allow an object to become an object key, so long as its string representation is not equivalent to that of any other key. In version 1, attempting to use an object as an object key would silently fail and would result in numeric index keys being used instead.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const isObject = require('is-object')
|
|
4
|
+
const otherwise = require('otherwise')
|
|
5
|
+
const sbo = require('sbo')
|
|
6
|
+
|
|
7
|
+
module.exports = sbo(function toStr (x, {elseCall, elseReturn = '', elseThrow} = {}) {
|
|
8
|
+
if (typeof x === 'string') return x
|
|
9
|
+
if (x instanceof String || Number.isFinite(x) || (isObject(x) && x.toString !== Object.prototype.toString)) return String(x)
|
|
10
|
+
return otherwise({elseCall, elseReturn, elseThrow}, {defaultErrorClass: TypeError})
|
|
11
|
+
})
|