Coder Social home page Coder Social logo

Functional rewrite about jsverbalexpressions HOT 9 OPEN

jehna avatar jehna commented on June 26, 2024 2
Functional rewrite

from jsverbalexpressions.

Comments (9)

jehna avatar jehna commented on June 26, 2024

Some examples where compositional/functional patterns has been used:

from jsverbalexpressions.

shreyasminocha avatar shreyasminocha commented on June 26, 2024

Huh. Interesting.

from jsverbalexpressions.

shreyasminocha avatar shreyasminocha commented on June 26, 2024

So for something like:

VerEx(
  startOfLine,
  "http",
  maybe("s"),
  "://",
  maybe("www."),
  anythingBut(" "),
  endOfLine
)

… would the import statement look like one of the following:

import { VerEx, startOfLine, maybe, anythingBut, endOfLine } from verbal-expressions;
import * from verbal-expressions;

A bit concerned about global scope pollution…

from jsverbalexpressions.

jehna avatar jehna commented on June 26, 2024

ES module/TypeScript imports would look like this:

import { VerEx, startOfLine, maybe, anythingBut, endOfLine } from 'verbal-expressions'

On node.js require you can use:

const { VerEx, startOfLine, maybe, anythingBut, endOfLine } = require('verbal-expressions')

If we want to still support global browser scripts, then a common practice with this kind of libraries (e.g. Ramda, lodash) is to use a short single-character namespace. We could namespace with V or ve. In that case you would use the library as:

V.VerEx(
  V.startOfLine,
  "http",
  V.maybe("s"),
  "://",
  V.maybe("www."),
  V.anythingBut(" "),
  V.endOfLine
)

from jsverbalexpressions.

shreyasminocha avatar shreyasminocha commented on June 26, 2024

Sounds good.

I'd like to help out with this. How do we work this out?

from jsverbalexpressions.

jehna avatar jehna commented on June 26, 2024

I can create a POC draft pull request to show a couple of ideas, and we can iterate from that. Does that sound good?

from jsverbalexpressions.

shreyasminocha avatar shreyasminocha commented on June 26, 2024

Sure.

from jsverbalexpressions.

shreyasminocha avatar shreyasminocha commented on June 26, 2024

@jehna How about I create a 2.0.0 branch and write some failing tests while you build your proof of concept?

from jsverbalexpressions.

jehna avatar jehna commented on June 26, 2024

Ok, so I did some work that I'd like to show you:
#197

from jsverbalexpressions.

Related Issues (20)

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.