Implement objectToAlternatingCase function
phocks opened this issue · comments
In response to Ash's question, it might be an idea to quickly implement this functionality.
So we can do somthing like:
import { objectToAlternatingCase } from "@abcnews/alternating-case-to-object";
const myObject = { test: "object" };
const myString: string = objectToAlternatingCase(myObject);
@AshKyd has said he's rolled his own version of this, so it could be a simple matter of pasting it in this repo with a little export
.
I'm using this. It doesn't deal with complex data types or anything.
function actoEncode(obj) {
return Object.entries(obj)
.map(([key, value]) => {
return [key.toUpperCase(), String(value).toLowerCase()].join('');
})
.join('');
}
I don't think it needs to deal with much. Strings, Numbers, Booleans ... anything else?
The decoder also handles arrays so probably also that.
Have started a branch https://github.com/abcnews/alternating-case-to-object/tree/object-to-alternating-case
The decoder also handles arrays so probably also that.
Yep, good point. So group: ['first', 'second', 'third']
will turn into 'GROUPfirstGROUPsecondGROUPthird'