XLibrary | 启动python服务 python3 | REST library
kandi X-RAY | XLibrary Summary
kandi X-RAY | XLibrary Summary
XLibrary
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handle click events
- Initialize the page
- The default femter for this element .
- Handle swipe events
- Functionality for modal
- Set the current page and refresh the list
- Search through a selector and returns the results
- Play animation .
- creates a promise which is resolved when no promises .
- Convert a string to blocks .
XLibrary Key Features
XLibrary Examples and Code Snippets
Community Discussions
Trending Discussions on XLibrary
QUESTION
I'm new to node.js but have developed enough server-side code that exporting and requiring a file for each custom-written library function is getting unwieldy. I've been reading about alternatives and am confused--perhaps because I should compromise on my goal.
There are 3 separate reusable .js files that are part of one logical kind of task. Let's call the task-type, "x".
- xLibrary.js - misc utilities specific to that task - many functions
- xSubtask1.js - some complex code and supporting functions
- xSubtask2.js - some complex code and supporting functions
I understand how to proceed if I treat each file as a separate module with a separate variable that references it. But since the subtasks are arbitrarily segregated (due to complexity not logical association) it creates confusion to have to remember which file contains a given function.
I'd like to put all the modules in 1 subdirectory and reference all the functions as xTask.*. The only way I know to do that is to combine all the files into one, but that makes maintaining the code more complex.
I've read articles and stackoverflow until my head is spinning. Many of the more comprehensive answers use logic to add each module in a subdirectory. I think hard-coding function and file names is more appropriate for my current level of expertise.
Can someone tell me how to proceed?
...ANSWER
Answered 2021-Jan-10 at 07:04For CommonJS modules, you can make a parent module that collects all the exports from a set of sub-modules and then exports them all as part of one main object. Here's some code I used in one of my projects that does that:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install XLibrary
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page