Coder Social home page Coder Social logo

flatmap's People

Contributors

alombarte avatar deepsource-autofix[bot] avatar deepsourcebot avatar kpacha avatar walkline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flatmap's Issues

Add "whitelist" operation

Current operation types allow you to rename (move) or delete properties, but not to define which are the fields you want to pick.

If the move operation would let you take an object outside the current scope, picking a field would be as easy as { "type": "move", "args": [ "results.*.desired", "*.desired" ]} and { "type": "del", "args": [ "results" ]},. As the move does not support moving properties outside the scope, the semantics of writing "I want this field" are really verbose:

Verbose example

For instance, let's take the Get Popular Movies from The MovieDB API. Say that I want to keep only title and id from the results, then I would need to define a flatmap like this (delete every single field I don't want):

{ "type": "del", "args": [ "results.*.adult" ]},
{ "type": "del", "args": [ "results.*.backdrop_path" ]},
{ "type": "del", "args": [ "results.*.genre_ids" ]},
{ "type": "del", "args": [ "results.*.original_language" ]},
{ "type": "del", "args": [ "results.*.original_title" ]},
{ "type": "del", "args": [ "results.*.overview" ]},
{ "type": "del", "args": [ "results.*.popularity" ]},
{ "type": "del", "args": [ "results.*.poster_path" ]},
{ "type": "del", "args": [ "results.*.release_date" ]},
{ "type": "del", "args": [ "results.*.video" ]},
{ "type": "del", "args": [ "results.*.vote_average" ]},
{ "type": "del", "args": [ "results.*.vote_count" ]},

Desired functionality

The desired operation should allow an easier way to pick the desired fields and delete everything else.

For instance:

{ "type": "whitelist", "args": [ "results.*.id", "results.*.title" ]},

Keeps id and title inside the array and deletes any non-matching element.

The whitelist operation deletes all non-matching elements. Meaning that it makes no sense to stack several whitelist operations.

Evaluate - Adding copy functionality to flatmap

This is probably too much magic... but worth reviewing.

I was wondering if it would make sense to support copy as a new type of operation.

One of the use cases I am thinking of is when you want to extract nested parameters for a sequential proxy temporarily but you still need the response as is. The move is going to remove the element from its position, so it doesn't cover the case.

Sequential proxy could also support nested parameters, but not sure if I would do it.

Thoughts?

Improve Expand() performance

the performance of the current implementation of the Expand method is "sub-optimal" and it decays as the deep in the managed structs and the size of the contained collections increases.

Add append operation

So collections and maps could be appended into a single one

Ex: append collection2 collection

original:

{
	"collection": [1,2,3]
	"collection2": [10,20,30]
}

result:

{
	"collection": [1,2,3,10,20,30]
}

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.