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,520 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('assert')
|
|
4
|
+
const {toArray, toIterator, toMap, toNumber, toObject, toString: toStr} = 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.notStrictEqual(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.notStrictEqual(r.done, true)
|
|
93
|
+
assert.strictEqual(r.value, 1)
|
|
94
|
+
r = iterator.next()
|
|
95
|
+
assert.notStrictEqual(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.notStrictEqual(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.notStrictEqual(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', {elseReturn: 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 `elseThrow` if input is unconvertible', function () {
|
|
183
|
+
assert.throws(() => { toMap('not a map', {elseThrow: TypeError}) }, 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 convert negative number string to number', function () {
|
|
209
|
+
assert.strictEqual(toNumber('-1.2'), -1.2)
|
|
210
|
+
assert.strictEqual(toNumber('−123'), -123)
|
|
211
|
+
assert.strictEqual(toNumber('−123K'), -123000)
|
|
212
|
+
assert.strictEqual(toNumber('0−123'), 0) // Invalid
|
|
213
|
+
assert.strictEqual(toNumber('(123.45)'), -123.45)
|
|
214
|
+
assert.strictEqual(toNumber('(-123.45)'), 0) // Invalid
|
|
215
|
+
assert.strictEqual(toNumber('123.45)'), 0) // Invalid
|
|
216
|
+
assert.strictEqual(toNumber('(123.45'), 0) // Invalid
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('should support digit grouping', function () {
|
|
220
|
+
assert.strictEqual(toNumber('1,000'), 1000)
|
|
221
|
+
assert.strictEqual(toNumber('1 000'), 1000)
|
|
222
|
+
assert.strictEqual(toNumber('1 000'), 1000)
|
|
223
|
+
assert.strictEqual(toNumber('1.000'), 1)
|
|
224
|
+
assert.strictEqual(toNumber('1.00'), 1)
|
|
225
|
+
assert.strictEqual(toNumber('1,234.56'), 1234.56)
|
|
226
|
+
assert.strictEqual(toNumber('12,34,567.89'), 1234567.89)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it('should support decimal comma syntax', function () {
|
|
230
|
+
assert.strictEqual(toNumber('1.000', {decimalComma: true}), 1000)
|
|
231
|
+
assert.strictEqual(toNumber('1,234'), 1234)
|
|
232
|
+
assert.strictEqual(toNumber('1,234', {decimalComma: true}), 1.234)
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
it('should return fallback (default 0) for invalid digit grouping', function () {
|
|
236
|
+
assert.strictEqual(toNumber('1 23'), 0)
|
|
237
|
+
assert.strictEqual(toNumber('1,234,56'), 0)
|
|
238
|
+
assert.strictEqual(toNumber('1,2,3'), 0)
|
|
239
|
+
assert.strictEqual(toNumber('1,234,56', {decimalComma: true}), 0)
|
|
240
|
+
assert.strictEqual(toNumber('1,234,56789'), 0)
|
|
241
|
+
assert.strictEqual(toNumber('1,234.567,890'), 0)
|
|
242
|
+
assert.strictEqual(toNumber('1,234 567 890'), 0)
|
|
243
|
+
assert.strictEqual(toNumber('1,2,34,567.89'), 0)
|
|
244
|
+
assert.strictEqual(toNumber('1,2,,34,567.89'), 0)
|
|
245
|
+
assert.strictEqual(toNumber('12,34,56.7'), 0)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('should allow contrary punctuation if there’s no ambiguity', function () {
|
|
249
|
+
assert.strictEqual(toNumber('1,23'), 1.23)
|
|
250
|
+
assert.strictEqual(toNumber('1.234,56', {decimalComma: true}), 1234.56)
|
|
251
|
+
assert.strictEqual(toNumber('1.234,56'), 1234.56)
|
|
252
|
+
assert.strictEqual(toNumber('1234,56'), 1234.56)
|
|
253
|
+
assert.strictEqual(toNumber('1,23456'), 1.23456)
|
|
254
|
+
assert.strictEqual(toNumber('1,234.00', {decimalComma: true}), 1234)
|
|
255
|
+
assert.strictEqual(toNumber('1 234.00', {decimalComma: true}), 1234)
|
|
256
|
+
assert.strictEqual(toNumber('1 234.567,890'), 1234567.89)
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it('should support `decimalPlacesInInt`', function () {
|
|
260
|
+
assert.strictEqual(toNumber('1,23', {decimalPlacesInInt: 2}), 123)
|
|
261
|
+
assert.strictEqual(toNumber('1.23', {decimalPlacesInInt: 2}), 123)
|
|
262
|
+
assert.strictEqual(toNumber('1.2345', {decimalPlacesInInt: 2}), 123)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('should support k/g/m/b suffixes', function () {
|
|
266
|
+
assert.strictEqual(toNumber('1k'), 1000)
|
|
267
|
+
assert.strictEqual(toNumber('2K'), 2000)
|
|
268
|
+
assert.strictEqual(toNumber('3g'), 3000)
|
|
269
|
+
assert.strictEqual(toNumber('400G'), 400000)
|
|
270
|
+
assert.strictEqual(toNumber('5k0'), 0) // Invalid
|
|
271
|
+
assert.strictEqual(toNumber('5bk'), 0) // Invalid
|
|
272
|
+
assert.strictEqual(toNumber('6m'), 6000000)
|
|
273
|
+
assert.strictEqual(toNumber('7M'), 7000000)
|
|
274
|
+
assert.strictEqual(toNumber('8b'), 8000000000)
|
|
275
|
+
assert.strictEqual(toNumber('9B'), 9000000000)
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
it('should guess at bad input if `ignoreBadChars` is `true`', function () {
|
|
279
|
+
assert.strictEqual(toNumber('--1', {ignoreBadChars: true}), -1)
|
|
280
|
+
assert.strictEqual(toNumber('1,234,56789', {ignoreBadChars: true}), 1234.56789)
|
|
281
|
+
assert.strictEqual(toNumber('1,234,56789', {ignoreBadChars: true, decimalPlacesInInt: 2}), 123456)
|
|
282
|
+
assert.strictEqual(toNumber('1,2,,34,567.89', {ignoreBadChars: true}), 1234567.89)
|
|
283
|
+
assert.strictEqual(toNumber('1,000', {ignoreBadChars: true}), 1000)
|
|
284
|
+
assert.strictEqual(toNumber('5k0', {ignoreBadChars: true}), 50)
|
|
285
|
+
assert.strictEqual(toNumber('5bk', {ignoreBadChars: true}), 5000)
|
|
286
|
+
assert.strictEqual(toNumber('5)', {ignoreBadChars: true}), 5)
|
|
287
|
+
assert.strictEqual(toNumber('This is 1 number', {ignoreBadChars: true}), 1)
|
|
288
|
+
assert.strictEqual(toNumber('This is Infinity!', {finite: false, ignoreBadChars: true}), Infinity)
|
|
289
|
+
assert.strictEqual(toNumber('not a number', {ignoreBadChars: true, elseReturn: 100}), 100)
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
it('should round float to integer if `round` is true', function () {
|
|
293
|
+
assert.strictEqual(toNumber(4.7, {round: true}), 5)
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
it('should return fallback (default 0) for Infinity', function () {
|
|
297
|
+
assert.strictEqual(toNumber(Infinity), 0)
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
it('should allow +Infinity if `finite` is false', function () {
|
|
301
|
+
assert.strictEqual(toNumber(Infinity, {finite: false}), Infinity)
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
it('should allow -Infinity if `finite` is false', function () {
|
|
305
|
+
assert.strictEqual(toNumber(-Infinity, {finite: false}), -Infinity)
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it('should convert string representations of Infinity', function () {
|
|
309
|
+
assert.strictEqual(toNumber('Infinity', {finite: false}), Infinity)
|
|
310
|
+
assert.strictEqual(toNumber('infinity', {finite: false}), Infinity)
|
|
311
|
+
|
|
312
|
+
assert.strictEqual(toNumber('-Infinity', {finite: false}), -Infinity)
|
|
313
|
+
assert.strictEqual(toNumber('−Infinity', {finite: false}), -Infinity)
|
|
314
|
+
assert.strictEqual(toNumber('−infinity', {finite: false}), -Infinity)
|
|
315
|
+
|
|
316
|
+
assert.strictEqual(toNumber('Infinity'), 0)
|
|
317
|
+
assert.strictEqual(toNumber('--Infinity', {finite: false}), 0) // Invalid
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
it('should return fallback (default 0) for NaN', function () {
|
|
321
|
+
assert.strictEqual(toNumber(NaN), 0)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('should return fallback (default 0) for null', function () {
|
|
325
|
+
assert.strictEqual(toNumber(null), 0)
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('should return fallback (default 0) for undefined', function () {
|
|
329
|
+
assert.strictEqual(toNumber(undefined), 0) // eslint-disable-line no-undefined
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('should return 0 if number is invalid and no fallback provided', function () {
|
|
333
|
+
assert.strictEqual(toNumber('not a number'), 0)
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
it('should return `elseReturn` if number is unconvertible', function () {
|
|
337
|
+
assert.strictEqual(toNumber('not a number', {elseReturn: 2}), 2)
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
it('should not round `elseReturn` if `round` is true', function () {
|
|
341
|
+
assert.strictEqual(toNumber({}, {elseReturn: 3.3, round: true}), 3.3)
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it('should throw `elseThrow` if input is unconvertible', function () {
|
|
345
|
+
assert.throws(() => { toNumber('not a number', {elseThrow: new RangeError()}) }, RangeError)
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
describe('#toObject()', function () {
|
|
350
|
+
it('should convert object to object', function () {
|
|
351
|
+
const object = {a: 1, b: 2}
|
|
352
|
+
assert.strictEqual(JSON.stringify(toObject(object)), JSON.stringify(object))
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
it('should convert array of key/value pairs to object', function () {
|
|
356
|
+
const object = toObject([['a', 1], ['b', 2]])
|
|
357
|
+
assert.strictEqual(object.a, 1)
|
|
358
|
+
assert.strictEqual(object.b, 2)
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
it('should convert array of strings to object with numerical keys', function () {
|
|
362
|
+
const object = toObject(['a', 'b'])
|
|
363
|
+
assert.strictEqual(object[0], 'a')
|
|
364
|
+
assert.strictEqual(object[1], 'b')
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
it('should `mirror` string array across keys and values', function () {
|
|
368
|
+
const object = toObject(['100', '200'], {mirror: true})
|
|
369
|
+
assert.strictEqual(object[100], '100')
|
|
370
|
+
assert.strictEqual(object[200], '200')
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
it('should throw if mirrored values would be string-equivalent keys', function () {
|
|
374
|
+
toObject(['100', {}], {mirror: true})
|
|
375
|
+
assert.throws(() => { toObject(['100', {}, {}], {mirror: true}) })
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
it('should convert Map to object', function () {
|
|
379
|
+
const object = toObject(new Map([['a', 1], ['b', 2]]))
|
|
380
|
+
assert.strictEqual(object.a, 1)
|
|
381
|
+
assert.strictEqual(object.b, 2)
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
it('should convert primitive value to empty object', function () {
|
|
385
|
+
assert.strictEqual(JSON.stringify(toObject('not an object')), JSON.stringify({}))
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
it('should return `elseReturn` if input is unconvertible', function () {
|
|
389
|
+
assert.strictEqual(JSON.stringify(toObject('not an object', {elseReturn: {a: 1}})), JSON.stringify({a: 1}))
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('should throw error if Map has keys that are not strings/numbers', function () {
|
|
393
|
+
assert.throws(() => { toObject(new Map([{}, 'test'])) }, TypeError)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
it('should accept property descriptor settings', function () {
|
|
397
|
+
const map = new Map([['a', 1], ['b', 2]])
|
|
398
|
+
|
|
399
|
+
{
|
|
400
|
+
const object = toObject(map, {descriptors: {}})
|
|
401
|
+
assert.strictEqual(Object.entries(object).length, 0)
|
|
402
|
+
assert.strictEqual(object.a, 1)
|
|
403
|
+
assert.strictEqual(object.b, 2)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
{
|
|
407
|
+
const object = toObject(map, {descriptors: {enumerable: true}})
|
|
408
|
+
assert.strictEqual(Object.entries(object).length, 2)
|
|
409
|
+
assert.throws(() => { object.a = 3 })
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
})
|
|
413
|
+
|
|
414
|
+
describe('#toString()', function () {
|
|
415
|
+
it('should convert string to string', function () {
|
|
416
|
+
assert.strictEqual(toStr('test'), 'test')
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
it('should convert String object to string', function () {
|
|
420
|
+
assert.strictEqual(typeof toStr(new String('test')), typeof 'test') // eslint-disable-line no-new-wrappers
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
it('should convert number to string', function () {
|
|
424
|
+
assert.strictEqual(toStr(-123), '-123')
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
it('should convert 0 to "0"', function () {
|
|
428
|
+
assert.strictEqual(toStr(0), '0')
|
|
429
|
+
})
|
|
430
|
+
|
|
431
|
+
it('should convert -0 to "0"', function () {
|
|
432
|
+
assert.strictEqual(toStr(-0), '0')
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
it('should convert NaN to empty string', function () {
|
|
436
|
+
assert.strictEqual(toStr(NaN), '')
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
it('should convert Infinity to empty string', function () {
|
|
440
|
+
assert.strictEqual(toStr(Infinity), '')
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
it('should convert true to empty string', function () {
|
|
444
|
+
assert.strictEqual(toStr(true), '')
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
it('should convert false to empty string', function () {
|
|
448
|
+
assert.strictEqual(toStr(true), '')
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it('should convert null to empty string', function () {
|
|
452
|
+
assert.strictEqual(toStr(null), '')
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
it('should convert undefined to empty string', function () {
|
|
456
|
+
assert.strictEqual(toStr(undefined), '') // eslint-disable-line no-undefined
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
it('should convert function to empty string', function () {
|
|
460
|
+
assert.strictEqual(toStr(function () {}), '')
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
it('should convert array to empty string', function () {
|
|
464
|
+
assert.strictEqual(toStr([]), '')
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
it('should convert plain object to empty string', function () {
|
|
468
|
+
assert.strictEqual(toStr({}), '')
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
it('should convert symbol to empty string', function () {
|
|
472
|
+
assert.strictEqual(toStr(Symbol('test')), '')
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
it('should convert object to string using object’s custom toString() method', function () {
|
|
476
|
+
class TestClass {
|
|
477
|
+
toString () {
|
|
478
|
+
return 'string value'
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const object = new TestClass()
|
|
482
|
+
assert.strictEqual(toStr(object), 'string value')
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
it('should return `elseReturn` if input is unconvertible', function () {
|
|
486
|
+
assert.strictEqual(toStr({}, {elseReturn: 'test'}), 'test')
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
it('should throw `elseThrow` if input is unconvertible', function () {
|
|
490
|
+
assert.throws(() => { toStr({}, {elseThrow: true}) }, TypeError)
|
|
491
|
+
})
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
it('should result in object surviving multiple chained conversions', function () {
|
|
495
|
+
let data = {a: 1, b: 2}
|
|
496
|
+
data = toMap(data)
|
|
497
|
+
data = toArray(data)
|
|
498
|
+
data = toObject(data)
|
|
499
|
+
data = toIterator(data)
|
|
500
|
+
data = toArray(data)
|
|
501
|
+
data = toMap(data)
|
|
502
|
+
data = toObject(data)
|
|
503
|
+
assert.strictEqual(Object.keys(data).length, 2)
|
|
504
|
+
assert.strictEqual(data.a, 1)
|
|
505
|
+
assert.strictEqual(data.b, 2)
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
it('should result in array surviving multiple chained conversions', function () {
|
|
509
|
+
let data = ['first', 'second']
|
|
510
|
+
data = toMap(data)
|
|
511
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
512
|
+
data = toObject(data)
|
|
513
|
+
data = toIterator(data)
|
|
514
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
515
|
+
data = toMap(data)
|
|
516
|
+
data = toObject(data)
|
|
517
|
+
data = toArray(data, {detectIndexKeys: true})
|
|
518
|
+
assert.strictEqual(JSON.stringify(data), JSON.stringify(['first', 'second']))
|
|
519
|
+
})
|
|
520
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ffn = require('ffn')
|
|
4
|
+
const plainify = require('plainify')
|
|
5
|
+
const sbo = require('sbo')
|
|
6
|
+
|
|
7
|
+
module.exports = sbo(function every (iter, test, options) {
|
|
8
|
+
const {vacuously = true} = plainify('vacuously', options)
|
|
9
|
+
test = ffn(test)
|
|
10
|
+
let empty = true
|
|
11
|
+
for (const val of iter) {
|
|
12
|
+
empty = false
|
|
13
|
+
if (!test(val)) return false
|
|
14
|
+
}
|
|
15
|
+
return !empty || !!vacuously
|
|
16
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright ©2018 John Lamansky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lamansky/every",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A better Array.prototype.every(). Supports iterables, whitelist testing, and more.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"iterable",
|
|
7
|
+
"array",
|
|
8
|
+
"every",
|
|
9
|
+
"test"
|
|
10
|
+
],
|
|
11
|
+
"author": "John Lamansky",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://github.com/lamansky/every",
|
|
14
|
+
"repository": "lamansky/every",
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"files": [],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=6.0.0"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"ffn": "^2.1.0",
|
|
22
|
+
"plainify": "^1.0.0",
|
|
23
|
+
"sbo": "^1.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"eslint-config-lamansky": "^1.0.0",
|
|
27
|
+
"mocha": "^5.2.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "mocha"
|
|
31
|
+
},
|
|
32
|
+
"eslintConfig": {
|
|
33
|
+
"extends": "lamansky",
|
|
34
|
+
"env": {
|
|
35
|
+
"mocha": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# every
|
|
2
|
+
|
|
3
|
+
A better `Array.prototype.every()`. Supports iterables, whitelist testing, and more.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Requires [Node.js](https://nodejs.org/) 6.0.0 or above.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @lamansky/every
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
The module exports a single function.
|
|
16
|
+
|
|
17
|
+
### Parameters
|
|
18
|
+
|
|
19
|
+
1. Bindable: `iter` (iterable)
|
|
20
|
+
2. Optional: `test` (function, array, or any): If a function is provided, iterated values will be evaluated on whether `test` returns `true` when passed the value. If an array is provided, iterated values will be evaluated on whether they are contained in the array. If some other value is provided, iterated values will be evaluated on whether they strictly equal `test`. If `test` is omitted, iterated values will be evaluated on whether they are truthy.
|
|
21
|
+
3. Optional: Object argument (_or_ a value for `vacuously`):
|
|
22
|
+
* `vacuously` (boolean): What to return if `iter` doesn’t iterate anything. Defaults to `true`. Thiis is for consistency with [`Array.prototype.every()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every), which interprets any test on an empty array as being [vacuously true](https://en.wikipedia.org/wiki/Vacuous_truth).
|
|
23
|
+
|
|
24
|
+
### Return Values
|
|
25
|
+
|
|
26
|
+
* If `iter` doesn’t iterate anything, returns `vacuously` if set, otherwise `true`.
|
|
27
|
+
* Otherwise, returns `true` if every one of the iterated values of `iter` passes `test`; otherwise returns `false`.
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const every = require('@lamansky/every')
|
|
33
|
+
|
|
34
|
+
const arr = [1, 2, 3]
|
|
35
|
+
|
|
36
|
+
every(arr, n => n >= 1) // true
|
|
37
|
+
every(arr, [1, 2, 3, 4]) // true
|
|
38
|
+
|
|
39
|
+
every(arr, n => n > 1) // false
|
|
40
|
+
every(arr, 1) // false
|
|
41
|
+
every(arr, [1, 2]) // false
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Related
|
|
45
|
+
|
|
46
|
+
* [some](https://github.com/lamansky/some)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright ©2018 John Lamansky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|