npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fluentnode

v0.7.1

Published

Fluent apis for node (based on the concepts used in C#'s FluentSharp

Downloads

1,137

Readme

FluentNode    

NPM version NPM downloads MIT License Build Status Coverage Status

NPM

NPM

FluentNode is a set of Node.js Javascript APIs that support functional programming:

  • designed to extent core Javascript/Node objects,
  • represents a continuous effort of simplifying complex actions, in order to allow the easy development and testing of readable code
  • written in Literate Coffee-Script (using TDD)
  • 100% code coverage (on both code and tests)
  • based on fluent APIs
  • an Javascript implementation of FluentSharp (part of OWASP O2 Platform)

@Fogus Functional Javascript book contains a description which completely matches the philosophy behind FluentNode.

In page 25, Functional programming is defined as consisting of the following techniques:

  • Identifying an abstraction and building a function for it
  • Using existing functions to build more complex abstractions
  • Passing existing functions to other functions to build even more complex abstractions

Install on Node.js

npm install fluentnode --save

Documentation and FluentNode APIs

The code is written in literate coffee-script where the documentation is part of the sourcecode.

See http://o2platform.com/fluentnode for the list of available functions, annotated source code, and all tests (site created using docco)

if you are viewing this in GitHub, the individual source code files (linked below) look quite nice (due to GH's support for literate Coffee-Script):

Examples

To show FluentNode in action, here are some examples taken from FluentNode's UnitTests

String::folder_Create and String::folder_Delete (in fs.test.coffee)

  it 'folder_Create and folder_Delete' , ->               # tests the String's folder_Create and folder_Delete methods
    "".folder_Create.assert_Is_Function()                 # checks if String::folder_Create exists
    "".folder_Delete.assert_Is_Function()                 # checks if String::folder_Delete exists
    tmpDir = "./".temp_Name_In_Folder()                   # get a temp folder name in the folder provided as string
    tmpDir.folder_Exists().assert_Is_False()              # checks if the folder exists (expects it to be false)
    tmpDir.folder_Create().assert_Is tmpDir.realPath()    # creates folder and confirms that the return value is the full path to the folder
    tmpDir.folder_Exists().assert_Is_True()               # confirms that folders exists
    tmpDir.folder_Delete().assert_Is_True()               # deletes folder (confirming OK result from delete action)
    tmpDir.folder_Exists().assert_Is_False()              # confirms that doesn't exists

There are actually two asserts that can be used to simply this code:

    tmpDir.assert_Folder_Not_Exists()                     # asserts that folder doesn't exist
          .folder_Create().assert_Is tmpDir.realPath()    # creates folder and confirms that the return value is the full path to the folder
    tmpDir.assert_Folder_Exists()                         # assert that folders exists
          .folder_Delete().assert_Is_True()               # deletes folder (confirming OK result from delete action)

String::file_Contents (in fs.test.coffee)

  it 'file_Contents' , ->
    ''.file_Contents.assert_Is_Function()
    file_Name     = '_temp_name_'.add_Random_String(5)
    file_Contents = 'value_'.add_Random_String(5)
    (file_Name.file_Exists().assert_Is_False())
    file_Contents.saveAs(file_Name)
    file_Name.file_Exists().assert_Is_True()
    file_Name.file_Contents().assert_Is(file_Contents)
    file_Name.file_Delete().assert_Is_True()

String::files (in fs.test.coffee)

  it 'files' , ->
    ''.files.assert_Is_Function()
    files = './'.files().filter (file) -> file isnt '.DS_Store'.realPath()
    expectedFiles = (file.realPath() for file in '.gitignore,.travis.yml,LICENSE,README.md,package.json'.split(','))
    files.assert_Contains(expectedFiles)
    './'.files('.yml' ).assert_Is(['.travis.yml'.realPath()])
    './'.files('.json').assert_Is(['package.json'.realPath()])

String::http_Status (in http.test.coffee)

  it 'http_Status', (done)->
    ''.http_Status.assert_Is_Function()
    url.http_Status (status)->
      status.assert_Is(200)
      done()

String::http_Get (in http.test.coffee)

  it 'http_GET' , (done)->
    ''.http_Status.assert_Is_Function()
    req = url.http_GET (err, data, res)->
      assert_Is_Null(err)
      data.assert_Is_String()
      req.assert_Instance_Of(http.ClientRequest)
      res.assert_Instance_Of(http.IncomingMessage)
      data.assert_Is(test_Data)
      done()

String::start_Process_Redirect_Console (in process.test.coffee)

  it 'start_Process_Redirect_Console', (done)->
    original_log = console.log
    log_Messages = []
    console.log  = (logMsg)-> log_Messages.push(logMsg)

    childProcess = 'ls'.start_Process_Redirect_Console('.')
    childProcess.on 'exit', ->
      console.log 'process ended'
      log_Messages.first() .assert_Contains('README.md')
      log_Messages.second().assert_Is('process ended')
      console.log = original_log
      done()

##Contribute See the current Issues list for a good place to start

If you need a function that is currently missing, please fork this repo and send a PR with the implementation and tests :)

##Projects using FluentNode

  • TeamMentor 4.0 GraphDB - https://github.com/TeamMentor/TM_4_0_GraphDB