Coder Social home page Coder Social logo

Make Color objects immutable about color HOT 22 CLOSED

qix- avatar qix- commented on June 2, 2024 5
Make Color objects immutable

from color.

Comments (22)

MoOx avatar MoOx commented on June 2, 2024

👍
PRs are welcome ;)

from color.

mindjuice avatar mindjuice commented on June 2, 2024

I would prefer an immutable, functional style too. In fact, without looking at the docs, that was how I started to use color and it didn't work! :-P

I would be willing to work on a PR for this, but it would break everyone's existing code, which is not advisable.

A few options:

  1. Add a function that selects immutable mode or mutable mode, but default to the current mutable behavior if that function is not called. This keeps compatibility, but adds overhead to every mutative function to check the flag and the extra code in the if/else bodies.
  2. Go ahead and break compatibility, but do a major version number bump so that most package.json files won't update automatically. Provide a section in the README with upgrade instructions.
  3. Start with option 1 and then move to option 2 in the near future.
  4. Fork the project and make the changes there.

Thoughts?

from color.

MoOx avatar MoOx commented on June 2, 2024

but it would break everyone's existing code, which is not advisable.

1.0 didn't exist yet, so we don't care. This project is sort of unmaintained. I am open to lead it (since I have the right for it) but didn't have too much time lately (busy with cssnext, stylelint...).

So please make a PR that break the current API. Major bump with a proper CHANGELOG that contains way to upgrade will do the trick.

from color.

mindjuice avatar mindjuice commented on June 2, 2024

I see. What do you mean by "since I have the right for it"? Is there a word missing there or are you referring to license rights?

from color.

MoOx avatar MoOx commented on June 2, 2024

The original author add me as a collaborator for this repo, so I can push, merge (& even push on npm).

from color.

sergey-lapin avatar sergey-lapin commented on June 2, 2024

T+1 to this, it was really odd to discover that it is mutable

from color.

wmira avatar wmira commented on June 2, 2024

this just bit me, i was writing some tests then it hit me... its mutable :( +1 for this pr please

from color.

MoOx avatar MoOx commented on June 2, 2024

Feel free to make the PR.

from color.

MoOx avatar MoOx commented on June 2, 2024

I am going to release this breaking change in 1.0 asap.

from color.

Qix- avatar Qix- commented on June 2, 2024

@MoOx does that mean you handled this? Or does this still need to happen?

from color.

MoOx avatar MoOx commented on June 2, 2024

I started to work on it, but I didn't finish. Too much work according to the time I allowed me to handle it :)

from color.

wmira avatar wmira commented on June 2, 2024

I did a stab at this. I'm still not familiar with some parts of the code but it probably can be used as basis for the actual change. I don't think I have broken anything -- tests still works etc.

from color.

kevinSuttle avatar kevinSuttle commented on June 2, 2024

https://github.com/facebook/immutable-js could help?

from color.

ooflorent avatar ooflorent commented on June 2, 2024

@kevinSuttle It won't. I'll try to submit a patch.

from color.

ooflorent avatar ooflorent commented on June 2, 2024

NVM #77 achieves it.

from color.

kevinSuttle avatar kevinSuttle commented on June 2, 2024

Woot

from color.

Qix- avatar Qix- commented on June 2, 2024

Going to keep this open until #77 is merged. Thanks @ooflorent 👍

from color.

dliv avatar dliv commented on June 2, 2024

Before this is closed, the README should be updated. The first example mutates a color. I'm willing to update the example if a more extensive update of the README isn't being worked on.

from color.

Qix- avatar Qix- commented on June 2, 2024

Agreed, though I'm working on a makeover branch right now that will have all of that included. You're welcome to submit a PR for the readme for the time being, though.

from color.

igl avatar igl commented on June 2, 2024

Just started to use color in our project and have already been bitten by this. :/
I see #77 was reverted. Any plans on still doing this?

from color.

Qix- avatar Qix- commented on June 2, 2024

@igl Yes - version 1 will definitely be immutable.

I should probably get to it soon. Every time I sit down to bang out the v1 rewrite it turns into a multi-day thing that ultimately goes by the wayside. I'll dedicate some time to this soon.

from color.

ericclemmons avatar ericclemmons commented on June 2, 2024

I came here to request the same, but offer help & support.

A work project is dependent on color so I'd be interested in helping out to get v1 out the door with any BC changes in this milestone & punting on feature additions:

https://github.com/Qix-/color/milestone/1

from color.

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.