A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

51 行
1017B

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