Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
node_promise
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nitesh Verma
node_promise
Commits
69bac5e2
Commit
69bac5e2
authored
2 months ago
by
Nitesh Verma
Browse files
Options
Downloads
Patches
Plain Diff
Write file function implemented
parent
7b24ebb6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.js
+15
-0
15 additions, 0 deletions
index.js
message.txt
+1
-0
1 addition, 0 deletions
message.txt
with
16 additions
and
0 deletions
index.js
+
15
−
0
View file @
69bac5e2
const
fs
=
require
(
'
fs
'
).
promises
;
/// Promise method
const
displayMessage
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
...
...
@@ -9,3 +12,15 @@ const displayMessage = () => {
// Calling the promise
displayMessage
().
then
(
console
.
log
).
catch
(
console
.
error
);
// Creating a file using fs module
const
writeFile
=
async
()
=>
{
try
{
await
fs
.
writeFile
(
"
message.txt
"
,
"
This file was created using fs module!
"
);
console
.
log
(
"
File created successfully!
"
);
}
catch
(
error
)
{
console
.
error
(
"
Error creating file:
"
,
error
);
}
};
// Calling the write file function
writeFile
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
message.txt
0 → 100644
+
1
−
0
View file @
69bac5e2
This file was created using fs module!
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment