Lawrence  Lesch

Lawrence Lesch

1673415300

Deno_std: Deno Standard Library

Deno Standard Modules

These modules do not have external dependencies and they are reviewed by the Deno core team. The intention is to have a standard set of high quality code that all Deno projects can use fearlessly.

Contributions are welcome!

Releases

Standard library is currently tagged independently of Deno version. This will change once the library is stabilized.

To check compatibility of different version of standard library with Deno CLI see this list.

How to use

These modules will eventually be tagged in accordance with Deno releases but as of today we do not yet consider them stable and so we version the standard modules differently from the Deno runtime to reflect this.

It is strongly recommended that you link to tagged releases to avoid unintended updates and breaking changes.

Don't link to / import any module whose path:

  • Has a name or parent with an underscore prefix: _foo.ts, _util/bar.ts.
  • Is that of a test module or test data: test.ts, foo_test.ts, testdata/bar.txt.

Don't import any symbol with an underscore prefix: export function _baz() {}.

These elements are not considered part of the public API, thus no stability is guaranteed for them.

Documentation

To browse documentation for modules:

Contributing

NOTE: This repository was unarchived and synced on Feb, 1st, 2021. If you already had it cloned, we suggest to do a fresh clone to avoid git conflicts.

deno_std is a loose port of Go's standard library. When in doubt, simply port Go's source code, documentation, and tests. There are many times when the nature of JavaScript, TypeScript, or Deno itself justifies diverging from Go, but if possible we want to leverage the energy that went into building Go. We generally welcome direct ports of Go's code.

Please ensure the copyright headers cite the code's origin.

Follow the style guide.

Opening a pull request

After cloning don't forget to git submodule update --init.

Before opening a PR make sure to:

  • have the latest Deno version installed locally
  • add tests that cover your changes.
  • deno task test passes.
  • deno fmt --check passes.
  • deno task lint passes.

Give the PR a descriptive title.

Examples of good titles:

  • fix(http): Fix race condition in server
  • docs(fmt): Update docstrings
  • feat(log): Handle nested messages

Examples of bad titles:

  • fix #7123
  • update docs
  • fix bugs

Ensure there is a related issue and it is referenced in the PR text.

For contributions to the Node compatibility library please check the std/node contributing guide

About CI checks:

We currently have 9 checks on CI. Each PR should pass all of these checks to be accepted.

  • test with Deno canary on Windows
  • test with Deno canary on Linux
  • test with Deno canary on macOS
  • test Node polyfill with Deno canary on Windows
  • test Node polyfill with Deno canary on Linux
  • test Node polyfill with Deno canary on macOS
  • lint
  • wasm crypto check
  • CLA

For maintainers:

To release a new version a tag in the form of x.y.z should be added.

Internal Assertions

All internal non-test code, that is files that do not have test or bench in the name, must use the assertion functions within _utils/asserts.ts and not testing/asserts.ts. This is to create a separation of concerns between internal and testing assertions.

Types

Deno is moving away from non-native IO functions and interfaces in favor of the Streams API. These types are to be defined here, in the Standard Library, instead of in the Deno namespace in the future. As a rule, use the following corresponding and identical types from types.d.ts:

  • Deno.Reader
  • Deno.Writer
  • Deno.ReaderSync
  • Deno.WriterSync
  • Deno.Closer

See the tracking issue here.

Download Details:

Author: Denoland
Source Code: https://github.com/denoland/deno_std 
License: MIT license

#typescript #javascript #deno 

What is GEEK

Buddha Community

Deno_std: Deno Standard Library
Lawrence  Lesch

Lawrence Lesch

1673415300

Deno_std: Deno Standard Library

Deno Standard Modules

These modules do not have external dependencies and they are reviewed by the Deno core team. The intention is to have a standard set of high quality code that all Deno projects can use fearlessly.

Contributions are welcome!

Releases

Standard library is currently tagged independently of Deno version. This will change once the library is stabilized.

To check compatibility of different version of standard library with Deno CLI see this list.

How to use

These modules will eventually be tagged in accordance with Deno releases but as of today we do not yet consider them stable and so we version the standard modules differently from the Deno runtime to reflect this.

It is strongly recommended that you link to tagged releases to avoid unintended updates and breaking changes.

Don't link to / import any module whose path:

  • Has a name or parent with an underscore prefix: _foo.ts, _util/bar.ts.
  • Is that of a test module or test data: test.ts, foo_test.ts, testdata/bar.txt.

Don't import any symbol with an underscore prefix: export function _baz() {}.

These elements are not considered part of the public API, thus no stability is guaranteed for them.

Documentation

To browse documentation for modules:

Contributing

NOTE: This repository was unarchived and synced on Feb, 1st, 2021. If you already had it cloned, we suggest to do a fresh clone to avoid git conflicts.

deno_std is a loose port of Go's standard library. When in doubt, simply port Go's source code, documentation, and tests. There are many times when the nature of JavaScript, TypeScript, or Deno itself justifies diverging from Go, but if possible we want to leverage the energy that went into building Go. We generally welcome direct ports of Go's code.

Please ensure the copyright headers cite the code's origin.

Follow the style guide.

Opening a pull request

After cloning don't forget to git submodule update --init.

Before opening a PR make sure to:

  • have the latest Deno version installed locally
  • add tests that cover your changes.
  • deno task test passes.
  • deno fmt --check passes.
  • deno task lint passes.

Give the PR a descriptive title.

Examples of good titles:

  • fix(http): Fix race condition in server
  • docs(fmt): Update docstrings
  • feat(log): Handle nested messages

Examples of bad titles:

  • fix #7123
  • update docs
  • fix bugs

Ensure there is a related issue and it is referenced in the PR text.

For contributions to the Node compatibility library please check the std/node contributing guide

About CI checks:

We currently have 9 checks on CI. Each PR should pass all of these checks to be accepted.

  • test with Deno canary on Windows
  • test with Deno canary on Linux
  • test with Deno canary on macOS
  • test Node polyfill with Deno canary on Windows
  • test Node polyfill with Deno canary on Linux
  • test Node polyfill with Deno canary on macOS
  • lint
  • wasm crypto check
  • CLA

For maintainers:

To release a new version a tag in the form of x.y.z should be added.

Internal Assertions

All internal non-test code, that is files that do not have test or bench in the name, must use the assertion functions within _utils/asserts.ts and not testing/asserts.ts. This is to create a separation of concerns between internal and testing assertions.

Types

Deno is moving away from non-native IO functions and interfaces in favor of the Streams API. These types are to be defined here, in the Standard Library, instead of in the Deno namespace in the future. As a rule, use the following corresponding and identical types from types.d.ts:

  • Deno.Reader
  • Deno.Writer
  • Deno.ReaderSync
  • Deno.WriterSync
  • Deno.Closer

See the tracking issue here.

Download Details:

Author: Denoland
Source Code: https://github.com/denoland/deno_std 
License: MIT license

#typescript #javascript #deno 

Brandon  Adams

Brandon Adams

1625629740

What is a Library? Using Libraries in Code Tutorial | C Library Examples

In this tutorial, we’ll be talking about what a library is and how they are useful. We will be looking at some examples in C, including the C Standard I/O Library and the C Standard Math Library, but these concepts can be applied to many different languages. Thank you for watching and happy coding!

Need some new tech gadgets or a new charger? Buy from my Amazon Storefront https://www.amazon.com/shop/blondiebytes

Also check out…
What is a Framework? https://youtu.be/HXqBlAywTjU
What is a JSON Object? https://youtu.be/nlYiOcMNzyQ
What is an API? https://youtu.be/T74OdSCBJfw
What are API Keys? https://youtu.be/1yFggyk--Zo
Using APIs with Postman https://youtu.be/0LFKxiATLNQ

Check out my courses on LinkedIn Learning!
REFERRAL CODE: https://linkedin-learning.pxf.io/blondiebytes
https://www.linkedin.com/learning/instructors/kathryn-hodge

Support me on Patreon!
https://www.patreon.com/blondiebytes

Check out my Python Basics course on Highbrow!
https://gohighbrow.com/portfolio/python-basics/

Check out behind-the-scenes and more tech tips on my Instagram!
https://instagram.com/blondiebytes/

Free HACKATHON MODE playlist:
https://open.spotify.com/user/12124758083/playlist/6cuse5033woPHT2wf9NdDa?si=VFe9mYuGSP6SUoj8JBYuwg

MY FAVORITE THINGS:
Stitch Fix Invite Code: https://www.stitchfix.com/referral/10013108?sod=w&som=c
FabFitFun Invite Code: http://xo.fff.me/h9-GH
Uber Invite Code: kathrynh1277ue
Postmates Invite Code: 7373F
SoulCycle Invite Code: https://www.soul-cycle.com/r/WY3DlxF0/
Rent The Runway: https://rtr.app.link/e/rfHlXRUZuO

Want to BINGE?? Check out these playlists…

Quick Code Tutorials: https://www.youtube.com/watch?v=4K4QhIAfGKY&index=1&list=PLcLMSci1ZoPu9ryGJvDDuunVMjwKhDpkB

Command Line: https://www.youtube.com/watch?v=Jm8-UFf8IMg&index=1&list=PLcLMSci1ZoPvbvAIn_tuSzMgF1c7VVJ6e

30 Days of Code: https://www.youtube.com/watch?v=K5WxmFfIWbo&index=2&list=PLcLMSci1ZoPs6jV0O3LBJwChjRon3lE1F

Intermediate Web Dev Tutorials: https://www.youtube.com/watch?v=LFa9fnQGb3g&index=1&list=PLcLMSci1ZoPubx8doMzttR2ROIl4uzQbK

GitHub | https://github.com/blondiebytes

Twitter | https://twitter.com/blondiebytes

LinkedIn | https://www.linkedin.com/in/blondiebytes

#blondiebytes #c library #code tutorial #library

Khaitan

Khaitan

1591842117

Deno Tutorial - Standard Library & Servers

Hey gang, in this Deno tutorial we’ll take a look at a couple of modules from the standard library & also see how to set up a server.

— Chapters —

  • 0:00 - uuid module
  • 2:56 - fs module
  • 7:48 - http module (server)

#deno #node #javascript #developer

Andrew French

1597854420

REST Framework for Deno Standard HTTP Library

mei-long

REST Framework for Deno Standard HTTP Library

Introduction

mei-long is a wrapper around the Deno Standard HTTP Library. The goal of this framework is to create a small overhead while providing convenience for the developer by making it as easy as possible to create a REST-conform HTTP/HTTPS server. This is a open-source project and MIT licensed. Any serious participation is welcome.

Getting started

To create your first server you can simply run the following code:

import {
  Application,
  Routes,
  RouteGroup,
  HttpMethods,
} from "https://deno.land/x/mei_long/mei-long.ts";

const apiV1Routes: Routes = [{
  method: HttpMethods.GET,
  url: "/",
  callback: (req) => {
    req.respond({ body: "HelloWorld" });
  },
}];

const apiV1: RouteGroup = {
  urlPrefix: "api/v1",
  routes: apiV1Routes,
};

const app = new Application(
  {
    port: 3003,
    routeGroups: [apiV1],
  },
);
app.start();
console.log("Server started");

Usage

As already told, the main idea was simplicity and keep the overhead as small as possible. Like the Deno Standard HTTP Library.

Application

To start the server:

const app = new Application(
  {
    port: 3003,
    routeGroups: [...],
  },
);
app.start();

should do the job. Where you define the following config:

interface ApplicationConfig {
  port: number;
  routeGroups: RouteGroup[];
  hostname?: string;
}

RouteGroups and Routes

But what are RouteGroups? The idea of a RouteGroup is that you can group separate routes that belong together. For example because of same functionality, API version, etc. . Especially if you are working on an updated version (V2) of your API, you can just create a new group, define the urlPrefix property (e.g. api/v2) and add it to your application.

type RouteGroup = {
  routes: Routes;
  urlPrefix: string;
  middlewares?: Middleware[];
};

Each RouteGroup has a different set of Routes. Routes are defined as an Array of Route objects. With Routes being an array you can easily define multiple arrays of Route objects (e.g. sorted by main, login, user, etc.) and then spread them to one big array ([...mainRoutes, ...loginRoutes, ...userRoutes]). This allows you to better manage your routes.

A Route is simple what you would expect in any REST environment.

  • It got a method, that must be a valid HTTP method (You can also just use a string here, but using the HttpMethods enum is recommended)
  • An url (e.g. “/customer/123/”)
  • A callback function that will simple pass through the req (“ServerRequest”) object from the Deno Standard HTTP Library, while providing params (“Map<string,string>”)
  • And middlewares which are also just passthrough functions like the callback
type Route = {
  method: HttpMethods | string;
  url: string;
  callback: RouteCallback;
  middlewares?: Middleware[];
};

RouteCallback

The RouteCallback is the function where your code (database operations, static data servings, etc.) will be written. You have access to the ServerRequest object of the Deno Standard HTTP Library. A little goody is, that you also have access to params which is a Map<string,string> and it stores all the parameters of the request.

For example:

  • The defined route /user/:id/ will with a call of /user/123 will give you 123 as value of the key user_id

The key string will be a combination of the parameter name and the previous url segment. Therefore you can use e.g. id more than once in your url.

  • /group/:id/user/:id/ will give you group_id and user_id

A special case is:

  • /:id will only provide you with id as key
...
    callback: (req, params) => {
        req.respond({ body: `The user id is: ${params.get("user_id")}` });
    }
  ...

Middlewares

As you might have noticed by now, you can define middlewares for Routes and/or for RouteGroups. This allows you to have for example a authentication for a group of routes while giving you the option to write code that should be executed before the RouteCallback of a single route.

Middlewares have acces to the ServerRequest object.

{
    ...
    myCoolMiddleware: (req) => {
        doSomethingCool();
        req.headers.get("Authorization");
        ...
    }
}

Download Details:

Author: martendV

Source Code: https://github.com/martendV/mei-long

#deno #nodejs #node #javascript

Colleen  Little

Colleen Little

1604542076

How To Use The Four Core Modules in Deno's Standard Library

In this guide, we’ll walk you through how to use the four core modules in Deno’s standard library: HTTP, hash, fs, and uuid.

The intention of Deno’s standard library is to provide a comprehensive collection of high-quality modules that all Deno projects can use seamlessly.

Among the many cool features Deno comes with is a set of standard modules designed to make developers’ lives easier. Largely inspired by existing languages such as Go and Python, these modules are Deno-approved and do not have any external dependencies.

What’s inside Deno’s standard library?

The intention of Deno’s standard library is to provide a comprehensive collection of high-quality code that all Deno projects can use seamlessly.

In this tutorial, we’ll explore four of the core standard libraries that can help you take your Deno app to the next level:

  1. http, for setting up an HTTP server
  2. hash, a crypto library for Deno
  3. fs, Deno’s file management system
  4. uuid, for generating unique IDs

Installing Deno

Before we start, let’s quickly walk through how to install Deno on your local machine.

Windows

To install Deno on our windows computer, open up the terminal and run this command:

iwr https://deno.land/x/install/install.ps1 -useb | iex

If you have Chocolatey installed on your machine, you could also run:

choco install deno

Mac

You can use Homebrew to install Deno on a Mac machine by running:

brew install deno

You can also install Deno using curl:

curl -fsSL https://deno.land/x/install/install.sh | sh

If Deno is properly installed, running the above command will generate the following output.

Output After Successful Installation of Deno on Mac

After installation, run the following command to confirm that Deno was properly installed on your local machine.

deno run https://deno.land/std/examples/welcome.ts

This very simple Deno command will print Welcome to Deno ![🦕](https://s.w.org/images/core/emoji/13.0.0/svg/1f995.svg) on the terminal.

Now that we have Deno installed, let’s zoom in on four of the most popular and useful modules in Deno’s standard library.

1. http

This library provides a simple way to set up a server.

First, bring the server instance into the application. Then, use the server instance to connect to a PORT.

import { serve } from "https://deno.land/std/http/server.ts";
const s = serve({ port: 8000 });
for await (const req of s) {
  req.respond({ body: "Hi,I'm Wisdom Ekpot" });
}

To start up your server, run:

deno run --allow-net http.ts

Due to Deno’s security, you’ll need to pass the --allow-net flag.

There are other ways to connect to a server in Deno, such as using Abc, which enables you to create chain routes using a single instance of the app method.

To create a server using Abc, add this to your http.ts file:

import { Application } from "https://deno.land/x/abc@v1.1.0/mod.ts";
const app = new Application();
const PORT = 8000;
let homepage = () => {
  return "This is the home page";
};
let contactPage = () => {
  return "You can contact Wisdom Ekpot with this contact Page";
};
app
  .get("/", homepage)
  .get("/contact", contactPage)
  .start({ port: PORT });
console.log(` Abc server running at http://localhost:${PORT}`);

Now you can create different routes for your application.

At the time of writing, https://deno.land/x/abc@v1.1.0/mod.ts is the latest version of Abc. Be sure to check the official docs for the latest version.

2. hash

Just like Node.js, Deno comes with its own hashing library. The hash module comes in handy when you want to implement things such as hashing of passwords or messages.

To use this module, you’ll need to import the instance of createHash, then create a variable to store this instance. This instance takes in an algorithm type:

import { createHash } from "https://deno.land/std/hash/mod.ts";
const hash = createHash("md5");
hash.update("All You need to know about deno");
const final = hash.digest();
console.log(final);

To run this application, run deno run <name of file>. This code will log the hashed data in an ArrayBuffer format_._

You can pass the hashing algorithm in the createHash instance as a param.

#deno #typescript #javascript #rust #developer