Skip to content
/ cjs Public

A Deno implementation to create variables like __dirname and __filename of Node.js

License

Notifications You must be signed in to change notification settings

sant123/cjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cjs Deno

Create variables like __dirname and __filename in Deno. Their behavior is the same as Node.js variables.

Usage

// example.ts
import { getDirname, getFilename } from "https://deno.land/x/cjs/mod.ts";

const __dirname = getDirname(import.meta.url);
const __filename = getFilename(import.meta.url);

// Your code here...

API

getDirname(importMetaUrl: string): string

Returns the directory of the current module.

getFilename(importMetaUrl: string): string

Returns the filename of the current module.

Node.js support

This should work with the stable Ecmascript modules implementation of Node.js. See this link for more information.

Testing

This library is highly tested to provide the same variables behavior of Node.js. If you see something is missing or ¿did you find a bug? pull requests are really welcome.

Benchmark

Tested with Deno v1.24.0:

About

A Deno implementation to create variables like __dirname and __filename of Node.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published