0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSSで書いたやつをobj化?したい

Posted at

CSSで書いたやつをobj化?を楽にしたくて強引なの作ったけど使えるんか使えんのかよくわからん、、

const CSStoObj = css => {
  const obj = {};

  const lines = css.split(/\r\n|\r|\n/);
  const changedLines = lines.map(v => v.replace(/;| /g, "").split(":"));

  changedLines.map(v => {
    if (!v[0]) return;
    if (v[0].indexOf('/*') !== -1) return;
    obj[v[0]] = v[1];
  });

  return JSON.stringify(obj);
};
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?