Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
my-node
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
Harshith Karkera
my-node
Commits
626f49e7
Commit
626f49e7
authored
3 months ago
by
Harshith Karkera
Browse files
Options
Downloads
Patches
Plain Diff
file create function added
parent
ae2cfff7
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.js
+21
-4
21 additions, 4 deletions
index.js
message.txt
+1
-0
1 addition, 0 deletions
message.txt
with
22 additions
and
4 deletions
index.js
+
21
−
4
View file @
626f49e7
// Creating a Promise
const
myPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
resolve
(
"
Hello World
"
);
},
1000
);
// Simulating an async operation with setTimeout
},
1000
);
});
// Calling the Promise
myPromise
.
then
((
message
)
=>
{
console
.
log
(
"
Message:
"
,
message
);
// Display the message
console
.
log
(
"
Message:
"
,
message
);
})
.
catch
((
error
)
=>
{
console
.
error
(
"
Error:
"
,
error
);
});
const
fs
=
require
(
'
fs/promises
'
);
async
function
createFile
()
{
try
{
const
message
=
"
New File Created
"
;
await
fs
.
writeFile
(
"
message.txt
"
,
message
);
console
.
log
(
"
File 'message.txt' has been created successfully.
"
);
}
catch
(
error
)
{
console
.
error
(
"
Error creating file:
"
,
error
);
}
}
createFile
();
This diff is collapsed.
Click to expand it.
message.txt
0 → 100644
+
1
−
0
View file @
626f49e7
New File Created
\ 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