Git Product home page Git Product logo

aeterna's People

Watchers

 avatar  avatar  avatar

aeterna's Issues

Lazy Interface

Would be good to provide an interface for lazy application.

Cheap solution. Wrap eager types in lazy objects that store method calls. Whitelist the methods that resolve with a fixed value.

Auto binding

The value for this should be autobound onto each method to allow for proper functional usage of the instance methods.

import { Vector } from 'aeterna';

const v = Vector([1, 2, 3]);
v.map(v.peek);
// [3, 3, 3]

Can autobind at declare time:

function Vector() {
  const v = [];

  Object.keys(Vector.prototype).forEach(function(k) {
    Object.defineProperty(v, k, {
      enumerable: false,
      value: Vector.prototype[k].bind(v)
    });
  });
}

Or retain access through closures.

function Vector() {
  const v = [];

  Object.defineProperty(v, 'map', {
      enumerable: false,
      value: function map(f) {
        // refer to `v` instead of `this`
      }
  });
}

Dropped features

Leaving a list of features that I deliberately dropped for historical context.

pipeline

Most pipelines can be achieved by chaining calls together. In the cases where they can't comp and partial can be used to build pipelines without much syntactic overhead.

into

If a need arose to transform these collections into Sets and native Maps, then these might be helpful, but otherwise for now, they'd be overkill.

count

Vectors already have precomputed length property.

intoArray

Can't yet think of a justification for needing to turn vectors into plain arrays.

primSeq

Got internals/_toConsumableArray but not super happy with it. Maybe a primSeq ish thing will re-appear in the future.

sum

Bit too specific to include.

fnil

Doesn't make much sense within the context of the current semantics, might revisit it in the future. Might be more sensible to skip to Just/Nothing though.

toClj/toJS

Already using native Javascript data structures.

Remove internals

The consumableArray code from the internals namespace is small/simple enough that it makes more sense to move it out into util.

Type predicates

Each data structure needs to come with a predicate for identifying those types.

import { Map } from 'aeterna';

const m = Map({ a: 1, b: 2 });
Map.isMap(m);

Could tag each instance/prototype with a non-enumerable unique string?

Object.defineProperty(Map.prototype, 'type', {
  enumerable: false,
  value: '#MAP#'
});

Could build this into the prototype chain and use instanceof?

Batched Interface

Would be good to provide a batched interface, so that large transformations can take place over the course of multiple repaints.

For instace, a batched map function.

const { partition, Vector } from 'aeterna';

function batchedMap(f, coll, done) {
   const batches = partition(coll, 500);
   let mapped = Vector([]);

   function $recur(batches) {
     if(batches.length == 0) done(mapped);
     const batch = batches.first();
     mapped = mapped.concat(batch.map(f));
     requestAnimationFrame(() => $recur(batches.rest()));
   }

   $recur(batches);
}

Can't think of a good way to create this as a generic wrapper unless each operation was to expose some kind of request/response interface, but that would force asynchronicity on all operations.

Polymorphism

It would be really handy for some methods to be shared between vectors and maps. Specifically get/getIn and assoc/assocIn/updateIn.

There should be no reason why these functions can't be moved out to a common namespace, then required by both types.

// vector.js
Vector.prototype = {
  assocIn: require('../common/assoc-in');
};

// map.js
Map.prototype = {
  assocIn: require('../common/assoc-in');
};

The other option is to go one step further and have a seq-like prototype that both inherit from.

Seq = {
  assocIn: require('./assocIn')
};

Map.prototype = Object.create(Seq);
Vector.prototype = Object.create(Seq);

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.