Coder Social home page Coder Social logo

dhershman1 / dustyjs Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 1.47 MB

A little library of functional operators

Home Page: http://dusty.codes/dusty-fns

License: MIT License

JavaScript 100.00%
dusty functional-programming javascript library pure single-type utility

dustyjs's Introduction

Welcome

Hello! ๐Ÿ‘‹ Welcome to my profile

I'm Dustin, a Fullstack Software Engineer,

I'm a Functional Developer at heart, and my most used toolset/language is JavaScript. I've authored many cool and fun libraries for the language!

I'm always looking to expand my horizons though and I've been delving little by little into other languages like Haskell, Clojure, Elm, and Scheme/Racket!

Thanks for taking the time to read this, check out my toolsets and feel free to ask questions/open issues/contibute where you see fit.

Dustin's GitHub stats Top Langs

dustyjs's People

Contributors

dhershman1 avatar

Watchers

 avatar  avatar

dustyjs's Issues

Error Throwing Or Unminify Library

Overall there is a lack of actually throwing informative errors back to the user and for a minified library that can cause a lot of headaches

I propose throwing TypeErrors or Errors in functionality to catch these things and inform the user what went wrong.

OR we unminify the library on delivery which personally I don't think I want to do this however it is an option if needed.

Suggestion: Perhaps creating an internal error handler that can monitor and throw errors for the library instead of individual functionality throwing errors all over the place?

Stabilization & Performance

Overall Stabilization of the library and it's held methods

Including any additional methods and obviously current ones

As well as making sure we are optimized and performant as we can be.

Add More Testing

At the moment the testing is there but rather sub par. I'd like to go through and add onto our testing across the board for the library.

I'd like to have a good amount of tests per functional operator in the library! (As well as any newly added ones too)

Optimize Size of distribution files

I want to go through and optimize the file sizes of all of our functions. The folder has gotten pretty big.

Relates to issue #2

So far the biggest offenders are:

  • compress - 6.06KB
  • isEmpty - 5.82KB
  • contains - 4.55KB
  • isEqual - 4.26KB
  • empty - 2.36KB
  • defaults- 2.18KB
  • omit - 1.74KB
  • last - 1.68KB
  • first - 1.68KB
  • reject - 1.65KB
  • find - 1.60KB
  • clone - 1.57KB

Empty and Equal are our biggest issues because they are quite large (the empty internal is a prime example) I may not be able to clean this up as much as I hope but anything is better than nothing.

Issue with Webpack Build

Seems like when you import the module on an app thats being built out by webpack the module returns an undefined.

So

import dusty from 'dusty-fns';

console.log(dusty); // => is undefined

However doing this

import isObject from 'dusty-fns/isObject';

console.log(isObject); // => returns the function

Will be digging into this for a v0.2.2 patch.

Add prepend function

Add a prepend function that allows prepending data to the start of a list

  • Curried: Yes

example:

import prepend from 'dusty-fns/prepend';

console.log(prepend(10, [11, 12, 13, 14]); // => [10, 11, 12, 13, 14]

More Currying

I want to curry more of the functionality through out dusty-fns to make it a lot better and hopefully easier to use overall.

For functionality like nth to make it better to use, for example:

import nth from 'dusty-fns/nth';

const third = nth(2);

third([1, 2, 3, 4, 5]); // => 3

But while also keeping the overall functionality of course:

import nth from 'dusty-fns/nth';

nth(2, [1, 2, 3, 4, 5]); // => 3

And many more functions I think could benefit from this.

Remove Multiple is methods in favor of single is function

Currently we have a list of different is functions the proposed thought is to replace most of these with a single is function.

Functionality that would be replaced:

  • isArray
  • isObject
  • isString
  • isNumber
  • isRegExp
  • isFunction

Functionality that would not be affected would be:

  • isEqual
  • isEmpty
  • isNull

Since this functionality is considered far different than the more simple types.

The new functionality would operate like so:

import is from 'dusty-fns/is';

is(String, 'test'); // => true
is(Number, 10); // => true
is(Array, []); // => true
is(Object, {}); // => true
is(Function, function test(a) { return a; }); // => true
is(RegExp, /[0-9]/g); // => true
is(String, new String()); // => true
is(Object, new String()); // => true

This will also be a curried function so something like this would be possible:

const isObject = is(Object);

isObject({}); // => true

Clean Up Omit

Currently the omit source code is a bit messy I'd like to try and improve the flow and functionality of the omit helper as best I can.

Possibly add support for objects but possibly not because I want to keep it consistent and pure if able.

This probably just falls under #2 but I wanted to make a direct issue so that I don't forget

New Functionality

New functionality we want to add to dusty.js (This list is subject to grow)

All Examples are concepts of use for the function

  • is - Curried: Yes - In v0.5.0
    Example:
import is from 'dusty-fns/is';

is(String, 'test'); // => true
is(Number, 10); // => true
is(Array, []); // => true
is(Object, {}); // => true
is(Function, function test(a) { return a; }); // => true
is(RegExp, /[0-9]/g); // => true
is(String, new String()); // => true
is(Object, new String()); // => true
  • prepend - Curried: Yes - In v0.5.0
    Example:
import prepend from 'dusty-fns/prepend';

console.log(prepend(10, [11, 12, 13, 14]); // => [10, 11, 12, 13, 14]
  • partition - Curried: Yes - In v0.5.0
    Example:
import partition from 'dusty-fns/partition';

partition(({val}) => val === 1, [{ val: 1 }, { val: 2 }]);
// => [{ val: 1}] [{ val: 2 }]
  • reject - Curried: Yes - In v0.5.0
    Example:
import reject from 'dusty-fns/reject';

reject(num => num % 2 == 0, [1, 2, 3, 4, 5, 6]); // => [1, 3, 5]
reject(num => num % 2 == 0, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
  • defaults - Curried: Yes - In v0.5.0
    Example:
import defaults from 'dusty-fns/defaults';

const data = { thing: 4 };

defaults({ test: 1, thing: 2 }, data); // => { test: 1, thing: 4 }
  • juxt - Curried: Yes - In v0.5.0
    Example: (Note example/idea inspired by Ramdas juxt functionality)
import juxt from 'dusty-fns/juxt';

const getRange = juxt([Math.min, Math.max]);

getRange(3, 4, 9, -3); // =>[-3, 9]
  • contains - Curried: Yes - In v0.5.0
    Example:
import contains from 'dusty-fns/contains';

contains(3, [1, 2, 3]); // => true
contains({ val: 1 }, [{ val: 2 }, { val: 1 }]); // => true
  • filter- Curried: Yes - In v0.5.0
    Example:
import filter from 'dusty-fns/filter';

const isEven = n => n % 2 === 0;

filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
  • complement- Curried: Yes - in v0.6.0
    Example:
import complement from 'dusty-fns/complement';
import isNull from 'dusty-fns/isNull';

const reverseNull = complement(isNull);

isNull(null); // => true
reverseNull(null); // => false
  • pluck- Curried: Yes - in v0.6.0
    Example:
import pluck from 'dusty-fns/pluck';

pluck('a', [{ a: 1 }, { b: 2 }]); // => { a: 1 }
pluck(0, [[1, 2], [3, 4]]); // => [1, 3]
  • prop - Curried: Yes - in v0.6.0
    Example:
import prop from 'dusty-fns/prop';

prop('thing', {thing: 'test'}); //=> 'test'
prop('thing', {}); //=> undefined
  • every - Curried: Yes - in v0.6.0
    Example:
import every from 'dusty-fns/every';

every(is(String), ['test', 'foo', 'bar']); //=> true
every(is(String), ['test', 1, 2, 'bar']); //=> false
  • any - Curried: Yes - in v0.6.0
    Example:
import any from 'dusty-fns/any';

any(is(String), ['test', 'foo', 'bar']); //=> true
any(is(String), ['test', 1, 2, 'bar']); //=> true
  • min - Curried: Yes
    Example:
import min from 'dusty-fns/min';
import __ from 'dusty-fns/__';

const sqr = n => n * n;

min([-1, -3, 1, 3, 4]); //=> 1
min([0, 1, 2, 3]); //=> 0
min(['a', 'b']); // => 'a'
  • max - Curried: Yes
    Example:
import max from 'dusty-fns/max';
import __ from 'dusty-fns/__';

const sqr = n => n * n;

max([-1, -3, 1, 3, 4]); //=> 1
max([0, 1, 2, 3]); //=> 3
max(['a', 'b']); // => 'b'
  • map - Curried: Yes - in v0.6.0
    Example:
import map from 'dusty-fns/map';

const sqr = n => n * n;

map(sqr, [-1, -3, 1, 3, 4]); //=> [1, 9, 1, 9, 16]

More In Depth Documentation

The current documentation is there and is "okay" to say the least. I should most likely skim through and create more in depth documentation as well as more in depth examples.

Add defaults function

A defaults function that would replace undefined values in an object with defaulted ones.

  • Curried: Yes

example:

import defaults from 'dusty-fns/defaults';

const data = { thing: 4 };

defaults({ test: 1, thing: 2 }, data); // => { test: 1, thing: 4 }

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.