node_io 1.0.0-dev.10.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 68

node_io #

This library exposes Node I/O functionality in dart:io way. It wraps Node.js I/O modules (like fs and http) and implements them using abstractions provided by dart:io (like File, Directory or HttpServer).

If you are looking for direct access to Node.js API see node_interop package.

Usage #

A basic example of accessing file system:

import 'package:node_io/node_io.dart';

void main() {
  print(Directory.current);
  print("Current directory exists: ${Directory.current.existsSync()}");
  print('Current directory contents: ');
  Directory.current.list().listen(print);
}

Configuration and build #

Add build_node_compilers and build_runner to dev_dependencies section in pubspec.yaml of your project:

dev_dependencies:
  build_runner: # needed to run the build
  build_node_compilers:

Add build.yaml file to the root of your project:

targets:
  $default:
    sources:
      - "node/**"
      - "test/**" # Include this if you want to compile tests.
      - "example/**" # Include this if you want to compile examples.

By convention all Dart files which declare main function go in node/ folder.

To build your project run following:

pub run build_runner build --output=build/

Detailed instructions can be found in build_node_compilers package docs.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.0.0-dev.10.0 #

  • Fixed NodeHttpResponse.redirect failing to convert Uri to string.

1.0.0-dev.9.0 #

  • Upgraded to latest build_node_compilers (0.2.0)

1.0.0-dev.8.0 #

  • Fixed: analysis warnings with latest Pub and Dart SDK.

1.0.0-dev.7.0 #

  • Fixed: handling errors in Directory.delete.
  • Fixed: handling relative paths in Directory.list.
  • Fixed: strong mode issues in Directory and File.
  • Added: File.create, File.delete, File.readAsString, File.rename, File.writeAsBytes, File.writeAsString.
  • Fixed: handling errors in File.open, File.stat, File.statSync.
  • Fixed: converting byte data in NodeIOSink.
  • Added: Minimal scaffold for Link FS entities.

1.0.0-dev.6.0 #

  • Upgraded to latest build_node_compilers.

1.0.0-dev.5.0 #

  • Fixed deprecation warnings with Dart 2 dev 61 SDK version.

1.0.0-dev.4.0 #

  • Fixed deprecation warnings with latest Dart 2 dev SDK.
  • Refactored HttpHeaders to not rely on Node.js API introduced in v7.7.0 Allows using this wrapper in Google Cloud Functions environment which runs on Node.js 6.x (LTS).

1.0.0-dev.3.0 #

  • Allow list values in HttpHeaders.set.

1.0.0-dev.2.0 #

  • Complete implementation of InternetAddress.

1.0.0-dev.1.0 #

  • Split from node_interop.

example/node_io.dart

import 'package:node_io/node_io.dart';

void main() {
  print(Directory.current);
  print("Current directory exists: ${Directory.current.existsSync()}");
  print('Current directory contents: ');
  Directory.current.list().listen(print);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  node_io: ^1.0.0-dev.10.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:node_io/node_io.dart';
  
Version Uploaded Documentation Archive
1.0.0-dev.10.0 Nov 7, 2018 Go to the documentation of node_io 1.0.0-dev.10.0 Download node_io 1.0.0-dev.10.0 archive
1.0.0-dev.9.0 Oct 5, 2018 Go to the documentation of node_io 1.0.0-dev.9.0 Download node_io 1.0.0-dev.9.0 archive
1.0.0-dev.8.0 Jul 24, 2018 Go to the documentation of node_io 1.0.0-dev.8.0 Download node_io 1.0.0-dev.8.0 archive
1.0.0-dev.7.0 Jun 25, 2018 Go to the documentation of node_io 1.0.0-dev.7.0 Download node_io 1.0.0-dev.7.0 archive
1.0.0-dev.6.0 Jun 22, 2018 Go to the documentation of node_io 1.0.0-dev.6.0 Download node_io 1.0.0-dev.6.0 archive
1.0.0-dev.5.0 Jun 11, 2018 Go to the documentation of node_io 1.0.0-dev.5.0 Download node_io 1.0.0-dev.5.0 archive
1.0.0-dev.4.0 Jun 6, 2018 Go to the documentation of node_io 1.0.0-dev.4.0 Download node_io 1.0.0-dev.4.0 archive
1.0.0-dev.3.0 Apr 16, 2018 Go to the documentation of node_io 1.0.0-dev.3.0 Download node_io 1.0.0-dev.3.0 archive
1.0.0-dev.2.0 Feb 14, 2018 Go to the documentation of node_io 1.0.0-dev.2.0 Download node_io 1.0.0-dev.2.0 archive
1.0.0-dev.1.0 Feb 13, 2018 Go to the documentation of node_io 1.0.0-dev.1.0 Download node_io 1.0.0-dev.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
78
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
75
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1

Platforms

Detected platforms: web, other

Primary library: package:node_io/node_io.dart with components: js, io.

Health suggestions

Fix lib/src/file.dart. (-11.33 points)

Analysis of lib/src/file.dart reported 24 hints, including:

line 59 col 38: Use = to separate a named parameter from its default value.

line 82 col 34: Use = to separate a named parameter from its default value.

line 88 col 53: Use = to separate a named parameter from its default value.

line 108 col 34: Use = to separate a named parameter from its default value.

line 146 col 53: Use = to separate a named parameter from its default value.

Fix lib/src/directory.dart. (-4.41 points)

Analysis of lib/src/directory.dart reported 9 hints, including:

line 25 col 10: Avoid return types on setters.

line 43 col 53: Use = to separate a named parameter from its default value.

line 63 col 34: Use = to separate a named parameter from its default value.

line 71 col 22: Use = to separate a named parameter from its default value.

line 71 col 47: Use = to separate a named parameter from its default value.

Fix lib/src/http_server.dart. (-4.41 points)

Analysis of lib/src/http_server.dart reported 9 hints, including:

line 40 col 23: Use = to separate a named parameter from its default value.

line 40 col 39: Use = to separate a named parameter from its default value.

line 40 col 59: Use = to separate a named parameter from its default value.

line 107 col 19: Use = to separate a named parameter from its default value.

line 107 col 35: Use = to separate a named parameter from its default value.

Fix additional 4 files with analysis or formatting issues. (-3.99 points)

Additional issues in the following files:

  • lib/src/link.dart (4 hints)
  • lib/src/file_system_entity.dart (2 hints)
  • lib/src/http_headers.dart (1 hint)
  • lib/src/streams.dart (1 hint)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
node_interop ^1.0.0-dev.11.0 1.0.0
path ^1.6.2 1.6.2
Dev dependencies
build_node_compilers ^0.2.0
build_runner ^1.0.0
build_test any
js ^0.6.0 0.6.1+1
test ^1.0.0