Coder Social home page Coder Social logo

shmew / fable.system.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jwosty/fable.system.io

1.0 1.0 0.0 159 KB

Lightweight Fable-compatible reimplementation of System.IO.Path in pure F# - https://www.nuget.org/packages/Fable.System.IO/

License: MIT License

F# 98.47% HTML 0.73% JavaScript 0.80%

fable.system.io's Introduction

Fable.System.IO

Fable.System.IO is a no-dependency, F#-only implementation of certain parts of the System.IO API. At the moment, this library only implements most of the methods in System.IO.Path. This library is built to be completely Fable-compatible, and behave exactly the same whether targetting .NET or Javascript.

To use the library, reference the Fable.System.IO nuget package. When targetting Fable, you also need the platform-detect NPM package, installed like so:

npm install [email protected]

Or:

Then, replace all occurrences of open System.IO with open Fable.System.IO.

Fable.System.IO will behave the same as the browser's current platform, as detected by platform-detect. In other words, when running in a Unix agent, it will use / as the directory separator; and in a Windows agent, it will use \ instead.

Choosing OS to emulate

By default, this library will emulate the path behavior for the current detected operating system. If you want to force Windows path behavior, you can open Fable.Windows.System.IO. Likewise, to force Unix path behavior, open Fable.Unix.System.IO. For example:

open Fable
open Fable.Unix.System.IO

printfn "Path.Combine(\"foo\", \"bar\") = \"%s\"" (Path.Combine ("foo", "bar"))

// This will output "foo/bar" on all systems

Supported APIs

Here is a list of currently implemented APIs in Fable.System.IO:

  • System.IO
    • Path (click here for Microsoft docs)
      • GetInvalidFileNameChars()
      • GetInvalidPathChars()
      • IsPathRooted(string)
      • Combine(string[])
      • Join(string, string)
      • GetRelativePath(string, string)
      • GetDirectoryName(string)
      • GetFileName(string)
      • GetFileNameWithoutExtension(string)
      • GetExtension(string)
      • HasExtension(string)
      • DirectorySeparatorChar : string
      • AltDirectorySeparatorChar : string

Development

You can open the Fable.System.IO.sln directly in your favorite .NET IDE.

You can run all tests (.NET and Javascript) with:

dotnet tool restore
dotnet paket restore
dotnet fable build -t Test

All the .NET tests include "Oracle" tests cases, which test the API against the BCL implementation. Therefore, for complete testing, one should make sure to run the test suite under a Windows system and a Unix system. The GitHub CI runs the full test suite under Windows and Ubuntu.

fable.system.io's People

Contributors

jwosty avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.