A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
975B

  1. var SCHEMA_LIST = [];
  2. var CUR_AJV = new Ajv();
  3. export default Object.freeze({
  4. add:function(s){
  5. if (!("$id" in s))
  6. throw new Error("Missing '$id' property in schema.");
  7. for (let i=0; i < SCHEMA_LIST.length; i++){
  8. if (SCHEMA_LIST[i]["$id"] === s["$id"])
  9. throw new Error("Schema already exists with $id '" + s["$id"] + "'.");
  10. }
  11. SCHEMA_LIST.push(s);
  12. CUR_AJV.addSchema(s);
  13. },
  14. remove:function(id){
  15. var idx = SCHEMA_LIST.findIndex((item) => {
  16. return item["$id"] === id;
  17. });
  18. if (idx >= 0){
  19. SCHEMA_LIST.splice(idx, 1);
  20. CUR_AJV.removeSchema(id);
  21. }
  22. },
  23. has:function(id){
  24. return SCHEMA_LIST.findIndex((item) => {
  25. return item["$id"] === id;
  26. }) >= 0;
  27. },
  28. getValidator:function(id){
  29. return (CUR_AJV !== null) ? CUR_AJV.getSchema(id) : null;
  30. },
  31. getLastErrors:function(){
  32. if (CUR_AJV === null || CUR_AJV.errors === null){return null;}
  33. return CUR_AJV.errors;
  34. }
  35. });