notation icon indicating copy to clipboard operation
notation copied to clipboard

Cannot assign to read only property '0' of string

Open Mosquid opened this issue 2 years ago • 0 comments

Am I doing it wrong or there is a bug?

const { Notation } = require("notation");
const data = {
  createdAt: "2022-02-25T23:48:54.746Z",
  status: "test",
  roles: [
    {
      type: "user",
      status: "Active",
      createdAt: "2021-04-05T16:28:29.412Z",
      titles: ["Back-End Developer"],
    },
  ],
  __v: 6,
};

function sanitize(obj, carry) {
  const globs = [
    "*",
    "!author",
    '!roles[*]',
    "roles[*].status",
    "roles[*].titles",
  ];

  return Notation.create(data).filter(globs).value;

This leads to the error:

TypeError: Cannot assign to read only property '0' of string 'Back-End Developer'
    at /~/node_modules/notation/lib/notation.min.js:1:18152

Mosquid avatar Feb 28 '22 16:02 Mosquid