Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:26:18+00:00 2026-06-07T09:26:18+00:00

I need to watch a small number of directories in a Node.JS application: function

  • 0

I need to watch a small number of directories in a Node.JS application:

function updated(event, filename){
    log("CHANGED\t/share/channels/" + filename);
}
for(i in channels)
    fs.watch('share/channels/' + channels[i], {persistent: false}, updated);

The problem is that fs.watch only passes the filename to the callback function, without including the directory it’s in. Is there a way I can somehow pass in an extra parameter to the updated() function so it knows where the file is?

I think I’m looking for something similar to Python’s functools.partial, if that helps any.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:26:20+00:00Added an answer on June 7, 2026 at 9:26 am

    You can use Function.bind:

    function updated(extraInformation, event, filename) {
        log("CHANGED\t/share/channels/" + extraInformation + filename);
    }
    
    for(i in channels)
        fs.watch('share/channels/' + channels[i], {persistent: false},
                  updated.bind(null, 'wherever/it/is/'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iPhone OS application I want (need) to watch for changes in the
http://www.youtube.com/watch?v=MfpnteZVFjI I need to implement from above video link Calendar... in my application.. Any
Need to call a filter function on some options based on a radio selected
In my app I need to watch a directory for new files. The amount
I created my ClickOnce application witch will install a small windows form application that
I need to watch when certain processes are started or stopped on a Windows
I need to watch properties for changes. Which method is better in terms of
I need a function similar to gobject.io_add_watch but for a variable. For example it
I am trying to make a small application for learning Morse code and I
How can I hide null members in watch screen? I don't need that. Below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.