From b668aaa344950c30f7dfa39a4c6e9db71e2348c5 Mon Sep 17 00:00:00 2001 From: Lcfvs Date: Mon, 18 Mar 2019 00:19:54 +0100 Subject: [PATCH] V3.0.6 --- .gitignore | 3 +- .npmignore | 3 +- anticore.md | 147 ------ api/blob/blobToBuffer/index.js | 20 - api/blob/blobToBuffer/readme.md | 7 - api/blob/blobToDataURL/index.js | 21 - api/blob/blobToDataURL/readme.md | 7 - api/blob/blobToImage/index.js | 16 - api/blob/blobToImage/readme.md | 7 - api/blob/blobToText/index.js | 20 - api/blob/blobToText/readme.md | 7 - api/blob/readme.md | 6 - api/canvas/canvasToBlob/index.js | 9 - api/canvas/canvasToBlob/readme.md | 12 - api/canvas/canvasToBuffer/index.js | 6 - api/canvas/canvasToBuffer/readme.md | 12 - api/canvas/canvasToDataURL/index.js | 6 - api/canvas/canvasToDataURL/readme.md | 12 - api/canvas/canvasToImage/index.js | 6 - api/canvas/canvasToImage/readme.md | 12 - api/canvas/canvasToText/index.js | 6 - api/canvas/canvasToText/readme.md | 12 - api/canvas/readme.md | 7 - api/dataURL/dataURLToImage/index.js | 20 - api/dataURL/dataURLToImage/readme.md | 7 - api/dataURL/readme.md | 3 - api/image/compressImage/index.js | 30 -- api/image/compressImage/readme.md | 13 - api/image/imageFromInput/index.js | 13 - api/image/imageFromInput/readme.md | 9 - api/image/imageToBlob/index.js | 7 - api/image/imageToBlob/readme.md | 12 - api/image/imageToBuffer/index.js | 6 - api/image/imageToBuffer/readme.md | 12 - api/image/imageToCanvas/index.js | 21 - api/image/imageToCanvas/readme.md | 12 - api/image/imageToDataURL/index.js | 6 - api/image/imageToDataURL/readme.md | 12 - api/image/imageToText/index.js | 6 - api/image/imageToText/readme.md | 12 - api/image/readme.md | 10 - api/image/resizeImage/index.js | 76 ---- api/image/resizeImage/readme.md | 18 - api/readme.md | 6 - dom/emitter/.call.js | 5 - dom/emitter/.callEach.js | 46 -- dom/emitter/.matches.js | 12 - dom/emitter/getTarget/index.js | 3 - dom/emitter/getTarget/readme.md | 7 - dom/emitter/off/index.js | 15 - dom/emitter/off/offBack/index.js | 5 - dom/emitter/off/offBack/readme.md | 7 - dom/emitter/off/offBlur/index.js | 5 - dom/emitter/off/offBlur/readme.md | 7 - dom/emitter/off/offChange/index.js | 5 - dom/emitter/off/offChange/readme.md | 7 - dom/emitter/off/offClick/index.js | 5 - dom/emitter/off/offClick/readme.md | 7 - dom/emitter/off/offDelete/index.js | 5 - dom/emitter/off/offDelete/readme.md | 7 - dom/emitter/off/offDown/index.js | 5 - dom/emitter/off/offDown/readme.md | 7 - dom/emitter/off/offDrag/index.js | 5 - dom/emitter/off/offDrag/readme.md | 7 - dom/emitter/off/offDragEnter/index.js | 5 - dom/emitter/off/offDragEnter/readme.md | 7 - dom/emitter/off/offDrop/index.js | 5 - dom/emitter/off/offDrop/readme.md | 7 - dom/emitter/off/offEnter/index.js | 5 - dom/emitter/off/offEnter/readme.md | 7 - dom/emitter/off/offError/index.js | 5 - dom/emitter/off/offError/readme.md | 7 - dom/emitter/off/offFileInput/index.js | 12 - dom/emitter/off/offFileInput/readme.md | 7 - dom/emitter/off/offFocus/index.js | 5 - dom/emitter/off/offFocus/readme.md | 7 - dom/emitter/off/offInput/index.js | 5 - dom/emitter/off/offInput/readme.md | 7 - dom/emitter/off/offLeft/index.js | 5 - dom/emitter/off/offLeft/readme.md | 7 - dom/emitter/off/offLoad/index.js | 5 - dom/emitter/off/offLoad/readme.md | 7 - dom/emitter/off/offMessage/index.js | 5 - dom/emitter/off/offMessage/readme.md | 7 - dom/emitter/off/offMouseOut/index.js | 5 - dom/emitter/off/offMouseOut/readme.md | 7 - dom/emitter/off/offMouseOver/index.js | 5 - dom/emitter/off/offMouseOver/readme.md | 7 - dom/emitter/off/offRight/index.js | 5 - dom/emitter/off/offRight/readme.md | 7 - dom/emitter/off/offSelectionChange/index.js | 6 - dom/emitter/off/offSelectionChange/readme.md | 7 - dom/emitter/off/offShiftEnter/index.js | 5 - dom/emitter/off/offShiftEnter/readme.md | 7 - dom/emitter/off/offSpace/index.js | 5 - dom/emitter/off/offSpace/readme.md | 7 - dom/emitter/off/offSubmit/index.js | 5 - dom/emitter/off/offSubmit/readme.md | 7 - dom/emitter/off/offUp/index.js | 5 - dom/emitter/off/offUp/readme.md | 7 - dom/emitter/off/readme.md | 31 -- dom/emitter/on/index.js | 15 - dom/emitter/on/onBack/index.js | 10 - dom/emitter/on/onBack/readme.md | 7 - dom/emitter/on/onBlur/index.js | 5 - dom/emitter/on/onBlur/readme.md | 7 - dom/emitter/on/onChange/index.js | 5 - dom/emitter/on/onChange/readme.md | 7 - dom/emitter/on/onClick/index.js | 10 - dom/emitter/on/onClick/readme.md | 7 - dom/emitter/on/onDelete/index.js | 10 - dom/emitter/on/onDelete/readme.md | 7 - dom/emitter/on/onDown/index.js | 10 - dom/emitter/on/onDown/readme.md | 7 - dom/emitter/on/onDrag/index.js | 5 - dom/emitter/on/onDrag/readme.md | 7 - dom/emitter/on/onDragEnter/index.js | 5 - dom/emitter/on/onDragEnter/readme.md | 7 - dom/emitter/on/onDrop/index.js | 5 - dom/emitter/on/onDrop/readme.md | 7 - dom/emitter/on/onEnter/index.js | 10 - dom/emitter/on/onEnter/readme.md | 7 - dom/emitter/on/onError/index.js | 5 - dom/emitter/on/onError/readme.md | 7 - dom/emitter/on/onFileInput/index.js | 23 - dom/emitter/on/onFileInput/readme.md | 7 - dom/emitter/on/onFocus/index.js | 5 - dom/emitter/on/onFocus/readme.md | 7 - dom/emitter/on/onInput/index.js | 5 - dom/emitter/on/onInput/readme.md | 7 - dom/emitter/on/onLeft/index.js | 10 - dom/emitter/on/onLeft/readme.md | 7 - dom/emitter/on/onLoad/index.js | 5 - dom/emitter/on/onLoad/readme.md | 7 - dom/emitter/on/onMessage/index.js | 5 - dom/emitter/on/onMessage/readme.md | 7 - dom/emitter/on/onMouseOut/index.js | 5 - dom/emitter/on/onMouseOut/readme.md | 7 - dom/emitter/on/onMouseOver/index.js | 5 - dom/emitter/on/onMouseOver/readme.md | 7 - dom/emitter/on/onRight/index.js | 10 - dom/emitter/on/onRight/readme.md | 7 - dom/emitter/on/onSelectionChange/index.js | 6 - dom/emitter/on/onSelectionChange/readme.md | 7 - dom/emitter/on/onShiftEnter/index.js | 10 - dom/emitter/on/onShiftEnter/readme.md | 7 - dom/emitter/on/onSpace/index.js | 10 - dom/emitter/on/onSpace/readme.md | 7 - dom/emitter/on/onSubmit/index.js | 5 - dom/emitter/on/onSubmit/readme.md | 7 - dom/emitter/on/onUp/index.js | 10 - dom/emitter/on/onUp/readme.md | 7 - dom/emitter/on/readme.md | 33 -- dom/emitter/once/index.js | 20 - dom/emitter/once/onceBack/index.js | 5 - dom/emitter/once/onceBack/readme.md | 7 - dom/emitter/once/onceBlur/index.js | 5 - dom/emitter/once/onceBlur/readme.md | 7 - dom/emitter/once/onceChange/index.js | 5 - dom/emitter/once/onceChange/readme.md | 7 - dom/emitter/once/onceClick/index.js | 5 - dom/emitter/once/onceClick/readme.md | 7 - dom/emitter/once/onceDelete/index.js | 5 - dom/emitter/once/onceDelete/readme.md | 7 - dom/emitter/once/onceDown/index.js | 5 - dom/emitter/once/onceDown/readme.md | 7 - dom/emitter/once/onceDrag/index.js | 5 - dom/emitter/once/onceDrag/readme.md | 7 - dom/emitter/once/onceDragEnter/index.js | 5 - dom/emitter/once/onceDragEnter/readme.md | 7 - dom/emitter/once/onceDrop/index.js | 5 - dom/emitter/once/onceDrop/readme.md | 7 - dom/emitter/once/onceEnter/index.js | 5 - dom/emitter/once/onceEnter/readme.md | 7 - dom/emitter/once/onceError/index.js | 5 - dom/emitter/once/onceError/readme.md | 7 - dom/emitter/once/onceFileInput/index.js | 12 - dom/emitter/once/onceFileInput/readme.md | 7 - dom/emitter/once/onceFocus/index.js | 5 - dom/emitter/once/onceFocus/readme.md | 7 - dom/emitter/once/onceInput/index.js | 5 - dom/emitter/once/onceInput/readme.md | 7 - dom/emitter/once/onceLeft/index.js | 5 - dom/emitter/once/onceLeft/readme.md | 7 - dom/emitter/once/onceLoad/index.js | 5 - dom/emitter/once/onceLoad/readme.md | 7 - dom/emitter/once/onceMessage/index.js | 5 - dom/emitter/once/onceMessage/readme.md | 7 - dom/emitter/once/onceMouseOut/index.js | 5 - dom/emitter/once/onceMouseOut/readme.md | 7 - dom/emitter/once/onceMouseOver/index.js | 5 - dom/emitter/once/onceMouseOver/readme.md | 7 - dom/emitter/once/onceRight/index.js | 5 - dom/emitter/once/onceRight/readme.md | 7 - dom/emitter/once/onceSelectionChange/index.js | 6 - .../once/onceSelectionChange/readme.md | 7 - dom/emitter/once/onceShiftEnter/index.js | 5 - dom/emitter/once/onceShiftEnter/readme.md | 7 - dom/emitter/once/onceSpace/index.js | 5 - dom/emitter/once/onceSpace/readme.md | 7 - dom/emitter/once/onceSubmit/index.js | 5 - dom/emitter/once/onceSubmit/readme.md | 7 - dom/emitter/once/onceUp/index.js | 5 - dom/emitter/once/onceUp/readme.md | 7 - dom/emitter/once/readme.md | 31 -- dom/emitter/options/index.js | 3 - dom/emitter/options/readme.md | 7 - dom/emitter/prevent/index.js | 5 - dom/emitter/prevent/readme.md | 7 - dom/emitter/readme.md | 9 - dom/emitter/stop/index.js | 9 - dom/emitter/stop/readme.md | 7 - dom/info/boundingRect/index.js | 3 - dom/info/boundingRect/readme.md | 7 - dom/info/contains/index.js | 3 - dom/info/contains/readme.md | 7 - dom/info/isCollection/index.js | 11 - dom/info/isCollection/readme.md | 7 - dom/info/isElement/index.js | 5 - dom/info/isElement/readme.md | 7 - dom/info/isEmpty/index.js | 8 - dom/info/isEmpty/readme.md | 7 - dom/info/isText/index.js | 5 - dom/info/isText/readme.md | 7 - dom/info/matches/index.js | 16 - dom/info/matches/readme.md | 7 - dom/info/nodeName/index.js | 9 - dom/info/nodeName/readme.md | 7 - dom/info/readme.md | 10 - dom/info/rects/index.js | 3 - dom/info/rects/readme.md | 7 - dom/node/document/index.js | 5 - dom/node/document/readme.md | 7 - dom/node/element/index.js | 5 - dom/node/element/readme.md | 7 - dom/node/fragment/index.js | 18 - dom/node/fragment/readme.md | 7 - dom/node/readme.md | 6 - dom/node/text/index.js | 5 - dom/node/text/readme.md | 7 - dom/query/all/index.js | 5 - dom/query/all/readme.md | 7 - dom/query/closest/index.js | 18 - dom/query/closest/readme.md | 7 - dom/query/closestOrSelf/index.js | 9 - dom/query/closestOrSelf/readme.md | 7 - dom/query/elements/index.js | 3 - dom/query/elements/readme.md | 7 - dom/query/firstElement/index.js | 3 - dom/query/firstElement/readme.md | 7 - dom/query/firstNode/index.js | 3 - dom/query/firstNode/readme.md | 7 - dom/query/firstOrSelf/index.js | 7 - dom/query/firstOrSelf/readme.md | 7 - dom/query/lastElement/index.js | 3 - dom/query/lastElement/readme.md | 7 - dom/query/lastNode/index.js | 3 - dom/query/lastNode/readme.md | 7 - dom/query/lastOrSelf/index.js | 7 - dom/query/lastOrSelf/readme.md | 7 - dom/query/nextElement/index.js | 3 - dom/query/nextElement/readme.md | 7 - dom/query/nextElements/index.js | 7 - dom/query/nextElements/readme.md | 7 - dom/query/nextNode/index.js | 3 - dom/query/nextNode/readme.md | 7 - dom/query/nextNodes/index.js | 10 - dom/query/nextNodes/readme.md | 7 - dom/query/nodes/index.js | 3 - dom/query/nodes/readme.md | 7 - dom/query/one/index.js | 5 - dom/query/one/readme.md | 7 - dom/query/parent/index.js | 3 - dom/query/parent/readme.md | 7 - dom/query/previousElement/index.js | 3 - dom/query/previousElement/readme.md | 7 - dom/query/previousElements/index.js | 7 - dom/query/previousElements/readme.md | 7 - dom/query/previousNode/index.js | 3 - dom/query/previousNode/readme.md | 7 - dom/query/previousNodes/index.js | 10 - dom/query/previousNodes/readme.md | 7 - dom/query/readme.md | 23 - dom/readme.md | 8 - dom/selection/anchor/index.js | 12 - dom/selection/anchor/readme.md | 13 - dom/selection/current/index.js | 3 - dom/selection/current/readme.md | 7 - dom/selection/end/index.js | 11 - dom/selection/end/readme.md | 7 - dom/selection/ends/index.js | 14 - dom/selection/ends/readme.md | 7 - dom/selection/focus/index.js | 13 - dom/selection/focus/readme.md | 17 - dom/selection/insert/index.js | 20 - dom/selection/insert/readme.md | 7 - dom/selection/isCollapsed/index.js | 5 - dom/selection/isCollapsed/readme.md | 7 - dom/selection/next/index.js | 17 - dom/selection/next/readme.md | 7 - dom/selection/previous/index.js | 17 - dom/selection/previous/readme.md | 7 - dom/selection/readme.md | 14 - dom/selection/select/index.js | 30 -- dom/selection/select/readme.md | 7 - dom/selection/start/index.js | 10 - dom/selection/start/readme.md | 7 - dom/selection/starts/index.js | 28 -- dom/selection/starts/readme.md | 7 - dom/tree/after/index.js | 7 - dom/tree/after/readme.md | 7 - dom/tree/afterAll/index.js | 19 - dom/tree/afterAll/readme.md | 7 - dom/tree/append/index.js | 5 - dom/tree/append/readme.md | 7 - dom/tree/appendAll/index.js | 11 - dom/tree/appendAll/readme.md | 7 - dom/tree/attr/index.js | 23 - dom/tree/attr/readme.md | 7 - dom/tree/before/index.js | 11 - dom/tree/before/readme.md | 7 - dom/tree/beforeAll/index.js | 11 - dom/tree/beforeAll/readme.md | 7 - dom/tree/clone/index.js | 3 - dom/tree/clone/readme.md | 7 - dom/tree/data/index.js | 22 - dom/tree/data/readme.md | 7 - dom/tree/empty/index.js | 13 - dom/tree/empty/readme.md | 7 - dom/tree/html/index.js | 18 - dom/tree/html/readme.md | 7 - dom/tree/prepend/index.js | 6 - dom/tree/prepend/readme.md | 7 - dom/tree/prependAll/index.js | 15 - dom/tree/prependAll/readme.md | 7 - dom/tree/readme.md | 24 - dom/tree/remove/index.js | 9 - dom/tree/remove/readme.md | 7 - dom/tree/removeAll/index.js | 9 - dom/tree/removeAll/readme.md | 7 - dom/tree/replace/index.js | 7 - dom/tree/replace/readme.md | 7 - dom/tree/sanitize/index.js | 22 - dom/tree/sanitize/readme.md | 7 - dom/tree/style/index.js | 19 - dom/tree/style/readme.md | 7 - dom/tree/text/index.js | 18 - dom/tree/text/readme.md | 7 - dom/tree/update/index.js | 44 -- dom/tree/update/readme.md | 35 -- dom/tree/updateAll/index.js | 10 - dom/tree/updateAll/readme.md | 7 - dom/tree/wrap/index.js | 7 - dom/tree/wrap/readme.md | 7 - dom/tree/wrapAll/index.js | 11 - dom/tree/wrapAll/readme.md | 7 - global/index.js | 1 - global/readme.md | 7 - index.js | 425 +++++------------- middleware/main/mono/index.js | 85 ---- middleware/main/mono/readme.md | 7 - middleware/main/readme.md | 3 - middleware/readme.md | 4 - middleware/time/localizer/index.js | 39 -- middleware/time/localizer/readme.md | 7 - middleware/time/readme.md | 3 - package-lock.json | 28 +- package.json | 8 +- primitive/array/every/index.js | 3 - primitive/array/every/readme.md | 7 - primitive/array/filter/index.js | 3 - primitive/array/filter/readme.md | 7 - primitive/array/forEach/index.js | 3 - primitive/array/forEach/readme.md | 7 - primitive/array/grep/index.js | 6 - primitive/array/grep/readme.md | 7 - primitive/array/indexOf/index.js | 3 - primitive/array/indexOf/readme.md | 7 - primitive/array/isArray/index.js | 9 - primitive/array/isArray/readme.md | 7 - primitive/array/map/index.js | 3 - primitive/array/map/readme.md | 7 - primitive/array/readme.md | 12 - primitive/array/reverse/index.js | 8 - primitive/array/reverse/readme.md | 7 - primitive/array/slice/index.js | 3 - primitive/array/slice/readme.md | 7 - primitive/array/slot/index.js | 9 - primitive/array/slot/readme.md | 7 - primitive/boolean/isBoolean/index.js | 9 - primitive/boolean/isBoolean/readme.md | 7 - primitive/boolean/readme.md | 3 - primitive/function/curry/index.js | 3 - primitive/function/curry/readme.md | 7 - primitive/function/demethodize/index.js | 1 - primitive/function/demethodize/readme.md | 7 - primitive/function/isFunction/index.js | 7 - primitive/function/isFunction/readme.md | 7 - primitive/function/promise/index.js | 8 - primitive/function/promise/readme.md | 7 - primitive/function/readme.md | 6 - primitive/null/isNull/index.js | 3 - primitive/null/isNull/readme.md | 7 - primitive/null/readme.md | 3 - primitive/number/isNumber/index.js | 9 - primitive/number/isNumber/readme.md | 7 - primitive/number/readme.md | 3 - primitive/object/create/index.js | 3 - primitive/object/create/readme.md | 7 - primitive/object/getPrimitiveOf/index.js | 41 -- primitive/object/getPrimitiveOf/readme.md | 7 - primitive/object/getTypeOf/index.js | 3 - primitive/object/getTypeOf/readme.md | 7 - primitive/object/isInstanceOf/index.js | 15 - primitive/object/isInstanceOf/readme.md | 7 - primitive/object/isObject/index.js | 5 - primitive/object/isObject/readme.md | 7 - primitive/object/keys/index.js | 1 - primitive/object/keys/readme.md | 7 - primitive/object/readme.md | 9 - primitive/object/toString/index.js | 3 - primitive/object/toString/readme.md | 7 - primitive/readme.md | 11 - primitive/string/camelToDash/index.js | 9 - primitive/string/camelToDash/readme.md | 7 - primitive/string/dashToCamel/index.js | 9 - primitive/string/dashToCamel/readme.md | 7 - primitive/string/isString/index.js | 9 - primitive/string/isString/readme.md | 7 - primitive/string/readme.md | 8 - primitive/string/toDOM/index.js | 8 - primitive/string/toDOM/readme.md | 7 - primitive/string/toLowerCase/index.js | 3 - primitive/string/toLowerCase/readme.md | 7 - primitive/string/toUpperCase/index.js | 3 - primitive/string/toUpperCase/readme.md | 7 - primitive/symbol/isSymbol/index.js | 9 - primitive/symbol/isSymbol/readme.md | 7 - primitive/symbol/readme.md | 3 - primitive/undefined/isUndefined/index.js | 3 - primitive/undefined/isUndefined/readme.md | 7 - primitive/undefined/readme.md | 3 - readme.md | 123 +++-- request/.queue.js | 9 - request/index.js | 182 -------- request/readme.md | 7 - sse.js | 22 + 447 files changed, 220 insertions(+), 4490 deletions(-) delete mode 100644 anticore.md delete mode 100644 api/blob/blobToBuffer/index.js delete mode 100644 api/blob/blobToBuffer/readme.md delete mode 100644 api/blob/blobToDataURL/index.js delete mode 100644 api/blob/blobToDataURL/readme.md delete mode 100644 api/blob/blobToImage/index.js delete mode 100644 api/blob/blobToImage/readme.md delete mode 100644 api/blob/blobToText/index.js delete mode 100644 api/blob/blobToText/readme.md delete mode 100644 api/blob/readme.md delete mode 100644 api/canvas/canvasToBlob/index.js delete mode 100644 api/canvas/canvasToBlob/readme.md delete mode 100644 api/canvas/canvasToBuffer/index.js delete mode 100644 api/canvas/canvasToBuffer/readme.md delete mode 100644 api/canvas/canvasToDataURL/index.js delete mode 100644 api/canvas/canvasToDataURL/readme.md delete mode 100644 api/canvas/canvasToImage/index.js delete mode 100644 api/canvas/canvasToImage/readme.md delete mode 100644 api/canvas/canvasToText/index.js delete mode 100644 api/canvas/canvasToText/readme.md delete mode 100644 api/canvas/readme.md delete mode 100644 api/dataURL/dataURLToImage/index.js delete mode 100644 api/dataURL/dataURLToImage/readme.md delete mode 100644 api/dataURL/readme.md delete mode 100644 api/image/compressImage/index.js delete mode 100644 api/image/compressImage/readme.md delete mode 100644 api/image/imageFromInput/index.js delete mode 100644 api/image/imageFromInput/readme.md delete mode 100644 api/image/imageToBlob/index.js delete mode 100644 api/image/imageToBlob/readme.md delete mode 100644 api/image/imageToBuffer/index.js delete mode 100644 api/image/imageToBuffer/readme.md delete mode 100644 api/image/imageToCanvas/index.js delete mode 100644 api/image/imageToCanvas/readme.md delete mode 100644 api/image/imageToDataURL/index.js delete mode 100644 api/image/imageToDataURL/readme.md delete mode 100644 api/image/imageToText/index.js delete mode 100644 api/image/imageToText/readme.md delete mode 100644 api/image/readme.md delete mode 100644 api/image/resizeImage/index.js delete mode 100644 api/image/resizeImage/readme.md delete mode 100644 api/readme.md delete mode 100644 dom/emitter/.call.js delete mode 100644 dom/emitter/.callEach.js delete mode 100644 dom/emitter/.matches.js delete mode 100644 dom/emitter/getTarget/index.js delete mode 100644 dom/emitter/getTarget/readme.md delete mode 100644 dom/emitter/off/index.js delete mode 100644 dom/emitter/off/offBack/index.js delete mode 100644 dom/emitter/off/offBack/readme.md delete mode 100644 dom/emitter/off/offBlur/index.js delete mode 100644 dom/emitter/off/offBlur/readme.md delete mode 100644 dom/emitter/off/offChange/index.js delete mode 100644 dom/emitter/off/offChange/readme.md delete mode 100644 dom/emitter/off/offClick/index.js delete mode 100644 dom/emitter/off/offClick/readme.md delete mode 100644 dom/emitter/off/offDelete/index.js delete mode 100644 dom/emitter/off/offDelete/readme.md delete mode 100644 dom/emitter/off/offDown/index.js delete mode 100644 dom/emitter/off/offDown/readme.md delete mode 100644 dom/emitter/off/offDrag/index.js delete mode 100644 dom/emitter/off/offDrag/readme.md delete mode 100644 dom/emitter/off/offDragEnter/index.js delete mode 100644 dom/emitter/off/offDragEnter/readme.md delete mode 100644 dom/emitter/off/offDrop/index.js delete mode 100644 dom/emitter/off/offDrop/readme.md delete mode 100644 dom/emitter/off/offEnter/index.js delete mode 100644 dom/emitter/off/offEnter/readme.md delete mode 100644 dom/emitter/off/offError/index.js delete mode 100644 dom/emitter/off/offError/readme.md delete mode 100644 dom/emitter/off/offFileInput/index.js delete mode 100644 dom/emitter/off/offFileInput/readme.md delete mode 100644 dom/emitter/off/offFocus/index.js delete mode 100644 dom/emitter/off/offFocus/readme.md delete mode 100644 dom/emitter/off/offInput/index.js delete mode 100644 dom/emitter/off/offInput/readme.md delete mode 100644 dom/emitter/off/offLeft/index.js delete mode 100644 dom/emitter/off/offLeft/readme.md delete mode 100644 dom/emitter/off/offLoad/index.js delete mode 100644 dom/emitter/off/offLoad/readme.md delete mode 100644 dom/emitter/off/offMessage/index.js delete mode 100644 dom/emitter/off/offMessage/readme.md delete mode 100644 dom/emitter/off/offMouseOut/index.js delete mode 100644 dom/emitter/off/offMouseOut/readme.md delete mode 100644 dom/emitter/off/offMouseOver/index.js delete mode 100644 dom/emitter/off/offMouseOver/readme.md delete mode 100644 dom/emitter/off/offRight/index.js delete mode 100644 dom/emitter/off/offRight/readme.md delete mode 100644 dom/emitter/off/offSelectionChange/index.js delete mode 100644 dom/emitter/off/offSelectionChange/readme.md delete mode 100644 dom/emitter/off/offShiftEnter/index.js delete mode 100644 dom/emitter/off/offShiftEnter/readme.md delete mode 100644 dom/emitter/off/offSpace/index.js delete mode 100644 dom/emitter/off/offSpace/readme.md delete mode 100644 dom/emitter/off/offSubmit/index.js delete mode 100644 dom/emitter/off/offSubmit/readme.md delete mode 100644 dom/emitter/off/offUp/index.js delete mode 100644 dom/emitter/off/offUp/readme.md delete mode 100644 dom/emitter/off/readme.md delete mode 100644 dom/emitter/on/index.js delete mode 100644 dom/emitter/on/onBack/index.js delete mode 100644 dom/emitter/on/onBack/readme.md delete mode 100644 dom/emitter/on/onBlur/index.js delete mode 100644 dom/emitter/on/onBlur/readme.md delete mode 100644 dom/emitter/on/onChange/index.js delete mode 100644 dom/emitter/on/onChange/readme.md delete mode 100644 dom/emitter/on/onClick/index.js delete mode 100644 dom/emitter/on/onClick/readme.md delete mode 100644 dom/emitter/on/onDelete/index.js delete mode 100644 dom/emitter/on/onDelete/readme.md delete mode 100644 dom/emitter/on/onDown/index.js delete mode 100644 dom/emitter/on/onDown/readme.md delete mode 100644 dom/emitter/on/onDrag/index.js delete mode 100644 dom/emitter/on/onDrag/readme.md delete mode 100644 dom/emitter/on/onDragEnter/index.js delete mode 100644 dom/emitter/on/onDragEnter/readme.md delete mode 100644 dom/emitter/on/onDrop/index.js delete mode 100644 dom/emitter/on/onDrop/readme.md delete mode 100644 dom/emitter/on/onEnter/index.js delete mode 100644 dom/emitter/on/onEnter/readme.md delete mode 100644 dom/emitter/on/onError/index.js delete mode 100644 dom/emitter/on/onError/readme.md delete mode 100644 dom/emitter/on/onFileInput/index.js delete mode 100644 dom/emitter/on/onFileInput/readme.md delete mode 100644 dom/emitter/on/onFocus/index.js delete mode 100644 dom/emitter/on/onFocus/readme.md delete mode 100644 dom/emitter/on/onInput/index.js delete mode 100644 dom/emitter/on/onInput/readme.md delete mode 100644 dom/emitter/on/onLeft/index.js delete mode 100644 dom/emitter/on/onLeft/readme.md delete mode 100644 dom/emitter/on/onLoad/index.js delete mode 100644 dom/emitter/on/onLoad/readme.md delete mode 100644 dom/emitter/on/onMessage/index.js delete mode 100644 dom/emitter/on/onMessage/readme.md delete mode 100644 dom/emitter/on/onMouseOut/index.js delete mode 100644 dom/emitter/on/onMouseOut/readme.md delete mode 100644 dom/emitter/on/onMouseOver/index.js delete mode 100644 dom/emitter/on/onMouseOver/readme.md delete mode 100644 dom/emitter/on/onRight/index.js delete mode 100644 dom/emitter/on/onRight/readme.md delete mode 100644 dom/emitter/on/onSelectionChange/index.js delete mode 100644 dom/emitter/on/onSelectionChange/readme.md delete mode 100644 dom/emitter/on/onShiftEnter/index.js delete mode 100644 dom/emitter/on/onShiftEnter/readme.md delete mode 100644 dom/emitter/on/onSpace/index.js delete mode 100644 dom/emitter/on/onSpace/readme.md delete mode 100644 dom/emitter/on/onSubmit/index.js delete mode 100644 dom/emitter/on/onSubmit/readme.md delete mode 100644 dom/emitter/on/onUp/index.js delete mode 100644 dom/emitter/on/onUp/readme.md delete mode 100644 dom/emitter/on/readme.md delete mode 100644 dom/emitter/once/index.js delete mode 100644 dom/emitter/once/onceBack/index.js delete mode 100644 dom/emitter/once/onceBack/readme.md delete mode 100644 dom/emitter/once/onceBlur/index.js delete mode 100644 dom/emitter/once/onceBlur/readme.md delete mode 100644 dom/emitter/once/onceChange/index.js delete mode 100644 dom/emitter/once/onceChange/readme.md delete mode 100644 dom/emitter/once/onceClick/index.js delete mode 100644 dom/emitter/once/onceClick/readme.md delete mode 100644 dom/emitter/once/onceDelete/index.js delete mode 100644 dom/emitter/once/onceDelete/readme.md delete mode 100644 dom/emitter/once/onceDown/index.js delete mode 100644 dom/emitter/once/onceDown/readme.md delete mode 100644 dom/emitter/once/onceDrag/index.js delete mode 100644 dom/emitter/once/onceDrag/readme.md delete mode 100644 dom/emitter/once/onceDragEnter/index.js delete mode 100644 dom/emitter/once/onceDragEnter/readme.md delete mode 100644 dom/emitter/once/onceDrop/index.js delete mode 100644 dom/emitter/once/onceDrop/readme.md delete mode 100644 dom/emitter/once/onceEnter/index.js delete mode 100644 dom/emitter/once/onceEnter/readme.md delete mode 100644 dom/emitter/once/onceError/index.js delete mode 100644 dom/emitter/once/onceError/readme.md delete mode 100644 dom/emitter/once/onceFileInput/index.js delete mode 100644 dom/emitter/once/onceFileInput/readme.md delete mode 100644 dom/emitter/once/onceFocus/index.js delete mode 100644 dom/emitter/once/onceFocus/readme.md delete mode 100644 dom/emitter/once/onceInput/index.js delete mode 100644 dom/emitter/once/onceInput/readme.md delete mode 100644 dom/emitter/once/onceLeft/index.js delete mode 100644 dom/emitter/once/onceLeft/readme.md delete mode 100644 dom/emitter/once/onceLoad/index.js delete mode 100644 dom/emitter/once/onceLoad/readme.md delete mode 100644 dom/emitter/once/onceMessage/index.js delete mode 100644 dom/emitter/once/onceMessage/readme.md delete mode 100644 dom/emitter/once/onceMouseOut/index.js delete mode 100644 dom/emitter/once/onceMouseOut/readme.md delete mode 100644 dom/emitter/once/onceMouseOver/index.js delete mode 100644 dom/emitter/once/onceMouseOver/readme.md delete mode 100644 dom/emitter/once/onceRight/index.js delete mode 100644 dom/emitter/once/onceRight/readme.md delete mode 100644 dom/emitter/once/onceSelectionChange/index.js delete mode 100644 dom/emitter/once/onceSelectionChange/readme.md delete mode 100644 dom/emitter/once/onceShiftEnter/index.js delete mode 100644 dom/emitter/once/onceShiftEnter/readme.md delete mode 100644 dom/emitter/once/onceSpace/index.js delete mode 100644 dom/emitter/once/onceSpace/readme.md delete mode 100644 dom/emitter/once/onceSubmit/index.js delete mode 100644 dom/emitter/once/onceSubmit/readme.md delete mode 100644 dom/emitter/once/onceUp/index.js delete mode 100644 dom/emitter/once/onceUp/readme.md delete mode 100644 dom/emitter/once/readme.md delete mode 100644 dom/emitter/options/index.js delete mode 100644 dom/emitter/options/readme.md delete mode 100644 dom/emitter/prevent/index.js delete mode 100644 dom/emitter/prevent/readme.md delete mode 100644 dom/emitter/readme.md delete mode 100644 dom/emitter/stop/index.js delete mode 100644 dom/emitter/stop/readme.md delete mode 100644 dom/info/boundingRect/index.js delete mode 100644 dom/info/boundingRect/readme.md delete mode 100644 dom/info/contains/index.js delete mode 100644 dom/info/contains/readme.md delete mode 100644 dom/info/isCollection/index.js delete mode 100644 dom/info/isCollection/readme.md delete mode 100644 dom/info/isElement/index.js delete mode 100644 dom/info/isElement/readme.md delete mode 100644 dom/info/isEmpty/index.js delete mode 100644 dom/info/isEmpty/readme.md delete mode 100644 dom/info/isText/index.js delete mode 100644 dom/info/isText/readme.md delete mode 100644 dom/info/matches/index.js delete mode 100644 dom/info/matches/readme.md delete mode 100644 dom/info/nodeName/index.js delete mode 100644 dom/info/nodeName/readme.md delete mode 100644 dom/info/readme.md delete mode 100644 dom/info/rects/index.js delete mode 100644 dom/info/rects/readme.md delete mode 100644 dom/node/document/index.js delete mode 100644 dom/node/document/readme.md delete mode 100644 dom/node/element/index.js delete mode 100644 dom/node/element/readme.md delete mode 100644 dom/node/fragment/index.js delete mode 100644 dom/node/fragment/readme.md delete mode 100644 dom/node/readme.md delete mode 100644 dom/node/text/index.js delete mode 100644 dom/node/text/readme.md delete mode 100644 dom/query/all/index.js delete mode 100644 dom/query/all/readme.md delete mode 100644 dom/query/closest/index.js delete mode 100644 dom/query/closest/readme.md delete mode 100644 dom/query/closestOrSelf/index.js delete mode 100644 dom/query/closestOrSelf/readme.md delete mode 100644 dom/query/elements/index.js delete mode 100644 dom/query/elements/readme.md delete mode 100644 dom/query/firstElement/index.js delete mode 100644 dom/query/firstElement/readme.md delete mode 100644 dom/query/firstNode/index.js delete mode 100644 dom/query/firstNode/readme.md delete mode 100644 dom/query/firstOrSelf/index.js delete mode 100644 dom/query/firstOrSelf/readme.md delete mode 100644 dom/query/lastElement/index.js delete mode 100644 dom/query/lastElement/readme.md delete mode 100644 dom/query/lastNode/index.js delete mode 100644 dom/query/lastNode/readme.md delete mode 100644 dom/query/lastOrSelf/index.js delete mode 100644 dom/query/lastOrSelf/readme.md delete mode 100644 dom/query/nextElement/index.js delete mode 100644 dom/query/nextElement/readme.md delete mode 100644 dom/query/nextElements/index.js delete mode 100644 dom/query/nextElements/readme.md delete mode 100644 dom/query/nextNode/index.js delete mode 100644 dom/query/nextNode/readme.md delete mode 100644 dom/query/nextNodes/index.js delete mode 100644 dom/query/nextNodes/readme.md delete mode 100644 dom/query/nodes/index.js delete mode 100644 dom/query/nodes/readme.md delete mode 100644 dom/query/one/index.js delete mode 100644 dom/query/one/readme.md delete mode 100644 dom/query/parent/index.js delete mode 100644 dom/query/parent/readme.md delete mode 100644 dom/query/previousElement/index.js delete mode 100644 dom/query/previousElement/readme.md delete mode 100644 dom/query/previousElements/index.js delete mode 100644 dom/query/previousElements/readme.md delete mode 100644 dom/query/previousNode/index.js delete mode 100644 dom/query/previousNode/readme.md delete mode 100644 dom/query/previousNodes/index.js delete mode 100644 dom/query/previousNodes/readme.md delete mode 100644 dom/query/readme.md delete mode 100644 dom/readme.md delete mode 100644 dom/selection/anchor/index.js delete mode 100644 dom/selection/anchor/readme.md delete mode 100644 dom/selection/current/index.js delete mode 100644 dom/selection/current/readme.md delete mode 100644 dom/selection/end/index.js delete mode 100644 dom/selection/end/readme.md delete mode 100644 dom/selection/ends/index.js delete mode 100644 dom/selection/ends/readme.md delete mode 100644 dom/selection/focus/index.js delete mode 100644 dom/selection/focus/readme.md delete mode 100644 dom/selection/insert/index.js delete mode 100644 dom/selection/insert/readme.md delete mode 100644 dom/selection/isCollapsed/index.js delete mode 100644 dom/selection/isCollapsed/readme.md delete mode 100644 dom/selection/next/index.js delete mode 100644 dom/selection/next/readme.md delete mode 100644 dom/selection/previous/index.js delete mode 100644 dom/selection/previous/readme.md delete mode 100644 dom/selection/readme.md delete mode 100644 dom/selection/select/index.js delete mode 100644 dom/selection/select/readme.md delete mode 100644 dom/selection/start/index.js delete mode 100644 dom/selection/start/readme.md delete mode 100644 dom/selection/starts/index.js delete mode 100644 dom/selection/starts/readme.md delete mode 100644 dom/tree/after/index.js delete mode 100644 dom/tree/after/readme.md delete mode 100644 dom/tree/afterAll/index.js delete mode 100644 dom/tree/afterAll/readme.md delete mode 100644 dom/tree/append/index.js delete mode 100644 dom/tree/append/readme.md delete mode 100644 dom/tree/appendAll/index.js delete mode 100644 dom/tree/appendAll/readme.md delete mode 100644 dom/tree/attr/index.js delete mode 100644 dom/tree/attr/readme.md delete mode 100644 dom/tree/before/index.js delete mode 100644 dom/tree/before/readme.md delete mode 100644 dom/tree/beforeAll/index.js delete mode 100644 dom/tree/beforeAll/readme.md delete mode 100644 dom/tree/clone/index.js delete mode 100644 dom/tree/clone/readme.md delete mode 100644 dom/tree/data/index.js delete mode 100644 dom/tree/data/readme.md delete mode 100644 dom/tree/empty/index.js delete mode 100644 dom/tree/empty/readme.md delete mode 100644 dom/tree/html/index.js delete mode 100644 dom/tree/html/readme.md delete mode 100644 dom/tree/prepend/index.js delete mode 100644 dom/tree/prepend/readme.md delete mode 100644 dom/tree/prependAll/index.js delete mode 100644 dom/tree/prependAll/readme.md delete mode 100644 dom/tree/readme.md delete mode 100644 dom/tree/remove/index.js delete mode 100644 dom/tree/remove/readme.md delete mode 100644 dom/tree/removeAll/index.js delete mode 100644 dom/tree/removeAll/readme.md delete mode 100644 dom/tree/replace/index.js delete mode 100644 dom/tree/replace/readme.md delete mode 100644 dom/tree/sanitize/index.js delete mode 100644 dom/tree/sanitize/readme.md delete mode 100644 dom/tree/style/index.js delete mode 100644 dom/tree/style/readme.md delete mode 100644 dom/tree/text/index.js delete mode 100644 dom/tree/text/readme.md delete mode 100644 dom/tree/update/index.js delete mode 100644 dom/tree/update/readme.md delete mode 100644 dom/tree/updateAll/index.js delete mode 100644 dom/tree/updateAll/readme.md delete mode 100644 dom/tree/wrap/index.js delete mode 100644 dom/tree/wrap/readme.md delete mode 100644 dom/tree/wrapAll/index.js delete mode 100644 dom/tree/wrapAll/readme.md delete mode 100644 global/index.js delete mode 100644 global/readme.md delete mode 100644 middleware/main/mono/index.js delete mode 100644 middleware/main/mono/readme.md delete mode 100644 middleware/main/readme.md delete mode 100644 middleware/readme.md delete mode 100644 middleware/time/localizer/index.js delete mode 100644 middleware/time/localizer/readme.md delete mode 100644 middleware/time/readme.md delete mode 100644 primitive/array/every/index.js delete mode 100644 primitive/array/every/readme.md delete mode 100644 primitive/array/filter/index.js delete mode 100644 primitive/array/filter/readme.md delete mode 100644 primitive/array/forEach/index.js delete mode 100644 primitive/array/forEach/readme.md delete mode 100644 primitive/array/grep/index.js delete mode 100644 primitive/array/grep/readme.md delete mode 100644 primitive/array/indexOf/index.js delete mode 100644 primitive/array/indexOf/readme.md delete mode 100644 primitive/array/isArray/index.js delete mode 100644 primitive/array/isArray/readme.md delete mode 100644 primitive/array/map/index.js delete mode 100644 primitive/array/map/readme.md delete mode 100644 primitive/array/readme.md delete mode 100644 primitive/array/reverse/index.js delete mode 100644 primitive/array/reverse/readme.md delete mode 100644 primitive/array/slice/index.js delete mode 100644 primitive/array/slice/readme.md delete mode 100644 primitive/array/slot/index.js delete mode 100644 primitive/array/slot/readme.md delete mode 100644 primitive/boolean/isBoolean/index.js delete mode 100644 primitive/boolean/isBoolean/readme.md delete mode 100644 primitive/boolean/readme.md delete mode 100644 primitive/function/curry/index.js delete mode 100644 primitive/function/curry/readme.md delete mode 100644 primitive/function/demethodize/index.js delete mode 100644 primitive/function/demethodize/readme.md delete mode 100644 primitive/function/isFunction/index.js delete mode 100644 primitive/function/isFunction/readme.md delete mode 100644 primitive/function/promise/index.js delete mode 100644 primitive/function/promise/readme.md delete mode 100644 primitive/function/readme.md delete mode 100644 primitive/null/isNull/index.js delete mode 100644 primitive/null/isNull/readme.md delete mode 100644 primitive/null/readme.md delete mode 100644 primitive/number/isNumber/index.js delete mode 100644 primitive/number/isNumber/readme.md delete mode 100644 primitive/number/readme.md delete mode 100644 primitive/object/create/index.js delete mode 100644 primitive/object/create/readme.md delete mode 100644 primitive/object/getPrimitiveOf/index.js delete mode 100644 primitive/object/getPrimitiveOf/readme.md delete mode 100644 primitive/object/getTypeOf/index.js delete mode 100644 primitive/object/getTypeOf/readme.md delete mode 100644 primitive/object/isInstanceOf/index.js delete mode 100644 primitive/object/isInstanceOf/readme.md delete mode 100644 primitive/object/isObject/index.js delete mode 100644 primitive/object/isObject/readme.md delete mode 100644 primitive/object/keys/index.js delete mode 100644 primitive/object/keys/readme.md delete mode 100644 primitive/object/readme.md delete mode 100644 primitive/object/toString/index.js delete mode 100644 primitive/object/toString/readme.md delete mode 100644 primitive/readme.md delete mode 100644 primitive/string/camelToDash/index.js delete mode 100644 primitive/string/camelToDash/readme.md delete mode 100644 primitive/string/dashToCamel/index.js delete mode 100644 primitive/string/dashToCamel/readme.md delete mode 100644 primitive/string/isString/index.js delete mode 100644 primitive/string/isString/readme.md delete mode 100644 primitive/string/readme.md delete mode 100644 primitive/string/toDOM/index.js delete mode 100644 primitive/string/toDOM/readme.md delete mode 100644 primitive/string/toLowerCase/index.js delete mode 100644 primitive/string/toLowerCase/readme.md delete mode 100644 primitive/string/toUpperCase/index.js delete mode 100644 primitive/string/toUpperCase/readme.md delete mode 100644 primitive/symbol/isSymbol/index.js delete mode 100644 primitive/symbol/isSymbol/readme.md delete mode 100644 primitive/symbol/readme.md delete mode 100644 primitive/undefined/isUndefined/index.js delete mode 100644 primitive/undefined/isUndefined/readme.md delete mode 100644 primitive/undefined/readme.md delete mode 100644 request/.queue.js delete mode 100644 request/index.js delete mode 100644 request/readme.md create mode 100644 sse.js diff --git a/.gitignore b/.gitignore index 723ef36..2d2b47d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +node_modules \ No newline at end of file diff --git a/.npmignore b/.npmignore index 723ef36..2d2b47d 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +node_modules \ No newline at end of file diff --git a/anticore.md b/anticore.md deleted file mode 100644 index e999ffc..0000000 --- a/anticore.md +++ /dev/null @@ -1,147 +0,0 @@ -# [anticore](../../#reference)/anticore methods - - -## anticore.on - -## Usage - -```js -anticore.on(selector, middleware) -``` - -## anticore.defaults - -## Usage - -```js -/** - * Intercepts: - * a[href^="http"]:not([download]):not([target]), - * a[href^="http"][target=_self]:not([download]), - * a[href^="."]:not([download]):not([target]), - * a[href^="."][target=_self]:not([download]), - * a[href^="/"]:not([download]):not([target]), - * a[href^="/"][target=_self]:not([download]), - * form:not([target]), - * form[target=_self] - */ -anticore.defaults() -``` - -## anticore.populate - -## Usage - -```js -anticore.populate(document, loaded, url) -``` - -## anticore.trigger - -## Usage - -```js -anticore.trigger(request) -``` - -## anticore.request -## Usage - -```js -anticore.request(url, method, body, target) -``` - -## anticore.onTimeout - -## Usage - -```js -anticore.onTimeout(request) -``` - -## anticore.fetchFromEvent - -Can be prevented by `event.preventDefault()` - -## Usage - -```js -anticore.fetchFromEvent(event) -``` - -## anticore.sse - -## Usage - -To use the internal `toDom()` reviver - -```js -source = anticore.sse(url, config) -``` - -To use your own reviver - -```js -source = anticore.sse(url, config, reviver) -``` - -## anticore.onError - -## Usage - -```js -anticore.onError(error) -``` - -## anticore.fetcher - -## Usage - -```js -anticore.fetcher(element) -``` - -## anticore.fetchers.a - -## Usage - -```js -anticore.fetchers.a(a) -``` - -## anticore.fetchers.form - -## Usage - -```js -anticore.fetchers.form(form) -``` - -## anticore.debug.onMiddleware - -## Usage - -```js -anticore.debug.onMiddleware = function (selector, listener) { - console.log({ - listener: listener, - selector: selector - }) -} -``` - -## anticore.debug.onMatch - -## Usage - -```js -anticore.debug.onMatch = function (selector, listener, element, loaded, url) { - console.log({ - element: element, - listener: listener, - loaded: loaded, - selector: selector, - url: url - }) -} -``` \ No newline at end of file diff --git a/api/blob/blobToBuffer/index.js b/api/blob/blobToBuffer/index.js deleted file mode 100644 index f691e9f..0000000 --- a/api/blob/blobToBuffer/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { getTarget } from '../../../dom/emitter/getTarget' -import { onceError } from '../../../dom/emitter/once/onceError' -import { onceLoad } from '../../../dom/emitter/once/onceLoad' -import { global } from '../../../global' -import { promise } from '../../../primitive/function/promise' - -const window = global() -const FileReader = window.FileReader - -export function blobToBuffer (blob) { - return promise(read, blob).then(getTarget) -} - -function read (blob, resolve, reject) { - const reader = new FileReader() - - reader.readAsArrayBuffer(blob) - onceLoad(reader, resolve) - onceError(reader, reject) -} diff --git a/api/blob/blobToBuffer/readme.md b/api/blob/blobToBuffer/readme.md deleted file mode 100644 index 2c6dd16..0000000 --- a/api/blob/blobToBuffer/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[blob](../#reference)/blobToBuffer - -## Usage - -```js -blobToBuffer(blob) -``` \ No newline at end of file diff --git a/api/blob/blobToDataURL/index.js b/api/blob/blobToDataURL/index.js deleted file mode 100644 index 758f20c..0000000 --- a/api/blob/blobToDataURL/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import { global } from '../../../global' -import { curry } from '../../../primitive/function/curry' -import { promise } from '../../../primitive/function/promise' - -const window = global() -const FileReader = window.FileReader - -export function blobToDataURL (blob) { - return promise(read, blob) -} - -function read (blob, resolve) { - const reader = new FileReader() - - reader.addEventListener('load', curry(onLoad, resolve)) - reader.readAsDataURL(blob) -} - -function onLoad (resolve, event) { - resolve(event.target.result) -} diff --git a/api/blob/blobToDataURL/readme.md b/api/blob/blobToDataURL/readme.md deleted file mode 100644 index 27cc2b6..0000000 --- a/api/blob/blobToDataURL/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[blob](../#reference)/blobToDataURL - -## Usage - -```js -blobToDataURL(blob) -``` \ No newline at end of file diff --git a/api/blob/blobToImage/index.js b/api/blob/blobToImage/index.js deleted file mode 100644 index e0d0931..0000000 --- a/api/blob/blobToImage/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import { global } from '../../../global' -import { dataURLToImage } from '../../dataURL/dataURLToImage' -import { blobToDataURL } from '../blobToDataURL' - -const window = global() -const revokeObjectURL = window.URL.revokeObjectURL - -export function blobToImage (blob) { - return blobToDataURL(blob).then(dataURLToImage).then(revoke) -} - -function revoke (target) { - revokeObjectURL(target.src) - - return target -} diff --git a/api/blob/blobToImage/readme.md b/api/blob/blobToImage/readme.md deleted file mode 100644 index affb5a2..0000000 --- a/api/blob/blobToImage/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[blob](../#reference)/blobToImage - -## Usage - -```js -blobToImage(blob) -``` \ No newline at end of file diff --git a/api/blob/blobToText/index.js b/api/blob/blobToText/index.js deleted file mode 100644 index 83ceb3f..0000000 --- a/api/blob/blobToText/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { getTarget } from '../../../dom/emitter/getTarget' -import { onceError } from '../../../dom/emitter/once/onceError' -import { onceLoad } from '../../../dom/emitter/once/onceLoad' -import { global } from '../../../global' -import { promise } from '../../../primitive/function/promise' - -const window = global() -const FileReader = window.FileReader - -export function blobToText (blob) { - return promise(read, blob).then(getTarget) -} - -function read (blob, resolve, reject) { - const reader = new FileReader() - - reader.readAsText(blob) - onceLoad(reader, resolve) - onceError(reader, reject) -} diff --git a/api/blob/blobToText/readme.md b/api/blob/blobToText/readme.md deleted file mode 100644 index ad8bcd1..0000000 --- a/api/blob/blobToText/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[blob](../#reference)/blobToText - -## Usage - -```js -blobToText(blob) -``` \ No newline at end of file diff --git a/api/blob/readme.md b/api/blob/readme.md deleted file mode 100644 index 4408b0b..0000000 --- a/api/blob/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# [anticore](../../../../#reference)/[api](../#reference)/blob - -* [blobToBuffer](./blobToBuffer/#reference) -* [blobToDataURL](./blobToDataURL/#reference) -* [blobToImage](./blobToImage/#reference) -* [blobToText](./blobToText/#reference) \ No newline at end of file diff --git a/api/canvas/canvasToBlob/index.js b/api/canvas/canvasToBlob/index.js deleted file mode 100644 index a0b5acf..0000000 --- a/api/canvas/canvasToBlob/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { promise } from '../../../primitive/function/promise' - -export function canvasToBlob (options, canvas) { - return promise(toBlob, options, canvas) -} - -function toBlob (options, canvas, resolve) { - canvas.toBlob(resolve, options.mime, options.quality || 1) -} diff --git a/api/canvas/canvasToBlob/readme.md b/api/canvas/canvasToBlob/readme.md deleted file mode 100644 index 54a3221..0000000 --- a/api/canvas/canvasToBlob/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[canvas](../#reference)/canvasToBlob - -## Usage - -```js -canvasToBlob(options, canvas) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/canvas/canvasToBuffer/index.js b/api/canvas/canvasToBuffer/index.js deleted file mode 100644 index 4870262..0000000 --- a/api/canvas/canvasToBuffer/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToBuffer } from '../../blob/blobToBuffer' -import { canvasToBlob } from '../canvasToBlob' - -export function canvasToBuffer (options, canvas) { - return canvasToBlob(options, canvas).then(blobToBuffer) -} diff --git a/api/canvas/canvasToBuffer/readme.md b/api/canvas/canvasToBuffer/readme.md deleted file mode 100644 index e205401..0000000 --- a/api/canvas/canvasToBuffer/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[canvas](../#reference)/canvasToBuffer - -## Usage - -```js -canvasToBuffer(options, canvas) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/canvas/canvasToDataURL/index.js b/api/canvas/canvasToDataURL/index.js deleted file mode 100644 index ce5f0ff..0000000 --- a/api/canvas/canvasToDataURL/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToDataURL } from '../../blob/blobToDataURL' -import { canvasToBlob } from '../canvasToBlob' - -export function canvasToDataURL (options, canvas) { - return canvasToBlob(options, canvas).then(blobToDataURL) -} diff --git a/api/canvas/canvasToDataURL/readme.md b/api/canvas/canvasToDataURL/readme.md deleted file mode 100644 index ba591fc..0000000 --- a/api/canvas/canvasToDataURL/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[canvas](../#reference)/canvasToDataURL - -## Usage - -```js -canvasToDataURL(options, canvas) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/canvas/canvasToImage/index.js b/api/canvas/canvasToImage/index.js deleted file mode 100644 index 632e5f1..0000000 --- a/api/canvas/canvasToImage/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToImage } from '../../blob/blobToImage' -import { canvasToBlob } from '../canvasToBlob' - -export function canvasToImage (options, canvas) { - return canvasToBlob(options, canvas).then(blobToImage) -} diff --git a/api/canvas/canvasToImage/readme.md b/api/canvas/canvasToImage/readme.md deleted file mode 100644 index 021eaa4..0000000 --- a/api/canvas/canvasToImage/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[canvas](../#reference)/canvasToImage - -## Usage - -```js -canvasToImage(options, canvas) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/canvas/canvasToText/index.js b/api/canvas/canvasToText/index.js deleted file mode 100644 index cafb8e5..0000000 --- a/api/canvas/canvasToText/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToText } from '../../blob/blobToText' -import { canvasToBlob } from '../canvasToBlob' - -export function canvasToText (options, canvas) { - return canvasToBlob(options, canvas).then(blobToText) -} diff --git a/api/canvas/canvasToText/readme.md b/api/canvas/canvasToText/readme.md deleted file mode 100644 index 037f1e0..0000000 --- a/api/canvas/canvasToText/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[canvas](../#reference)/canvasToText - -## Usage - -```js -canvasToText(options, canvas) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/canvas/readme.md b/api/canvas/readme.md deleted file mode 100644 index d29ceb4..0000000 --- a/api/canvas/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../#reference)/[api](../#reference)/canvas - -* [canvasToBlob](./canvasToBlob/#reference) -* [canvasToBuffer](./canvasToBuffer/#reference) -* [canvasToDataURL](./canvasToDataURL/#reference) -* [canvasToImage](./canvasToImage/#reference) -* [canvasToText](./canvasToText/#reference) \ No newline at end of file diff --git a/api/dataURL/dataURLToImage/index.js b/api/dataURL/dataURLToImage/index.js deleted file mode 100644 index b7ec195..0000000 --- a/api/dataURL/dataURLToImage/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { getTarget } from '../../../dom/emitter/getTarget' -import { onceError } from '../../../dom/emitter/once/onceError' -import { onceLoad } from '../../../dom/emitter/once/onceLoad' -import { global } from '../../../global' -import { promise } from '../../../primitive/function/promise' - -const window = global() -const Image = window.Image - -export function dataURLToImage (url) { - return promise(read, url).then(getTarget) -} - -function read (url, resolve, reject) { - const img = new Image() - - img.src = url - onceLoad(img, resolve) - onceError(img, reject) -} diff --git a/api/dataURL/dataURLToImage/readme.md b/api/dataURL/dataURLToImage/readme.md deleted file mode 100644 index bccf31a..0000000 --- a/api/dataURL/dataURLToImage/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[dataURL](../#reference)/dataURLToImage - -## Usage - -```js -dataURLToImage(url) -``` \ No newline at end of file diff --git a/api/dataURL/readme.md b/api/dataURL/readme.md deleted file mode 100644 index edb488f..0000000 --- a/api/dataURL/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[api](../#reference)/dataURL - -* [dataURLToImage](./dataURLToImage/#reference) \ No newline at end of file diff --git a/api/image/compressImage/index.js b/api/image/compressImage/index.js deleted file mode 100644 index 779853b..0000000 --- a/api/image/compressImage/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import { indexOf } from '../../../primitive/array/indexOf' -import { curry } from '../../../primitive/function/curry' -import { canvasToBlob } from '../../canvas/canvasToBlob' -import { canvasToImage } from '../../canvas/canvasToImage' -import { imageToCanvas } from '../imageToCanvas' - -const mimes = ['image/jpeg', 'image/webp'] - -export function compressImage (options, img) { - if (indexOf(mimes, options.mime) === -1) { - return img - } - - return imageToCanvas(img).then(curry(compress, options)).then( - curry(canvasToImage, options)) -} - -function compress (options, canvas) { - return canvasToBlob(options, canvas).then(curry(read, options, canvas)) -} - -function read (options, canvas, blob) { - if (!options.maxSize || blob.size < options.maxSize) { - return canvas - } - - options.quality = 1 - options.maxSize / blob.size - - return compress(options, canvas) -} diff --git a/api/image/compressImage/readme.md b/api/image/compressImage/readme.md deleted file mode 100644 index ee78b0a..0000000 --- a/api/image/compressImage/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/compressImage - -## Usage - -```js -compressImage(options, img) -``` - -## Options - -* maxSize -* mime -* quality \ No newline at end of file diff --git a/api/image/imageFromInput/index.js b/api/image/imageFromInput/index.js deleted file mode 100644 index 8daf47f..0000000 --- a/api/image/imageFromInput/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import { onFileInput } from '../../../dom/emitter/on/onFileInput' -import { curry } from '../../../primitive/function/curry' -import { blobToImage } from '../../blob/blobToImage' - -export function imageFromInput (input, callback) { - onFileInput(input, curry(read, callback)) -} - -function read (callback, event) { - const file = (event.dataTransfer || event.target).files[0] - - callback(blobToImage(file)) -} diff --git a/api/image/imageFromInput/readme.md b/api/image/imageFromInput/readme.md deleted file mode 100644 index 539a311..0000000 --- a/api/image/imageFromInput/readme.md +++ /dev/null @@ -1,9 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageFromInput - -## Usage - -```js -imageFromInput(input, function (promise) { - // do something -}) -``` \ No newline at end of file diff --git a/api/image/imageToBlob/index.js b/api/image/imageToBlob/index.js deleted file mode 100644 index 68b6c1d..0000000 --- a/api/image/imageToBlob/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { curry } from '../../../primitive/function/curry' -import { canvasToBlob } from '../../canvas/canvasToBlob' -import { imageToCanvas } from '../imageToCanvas' - -export function imageToBlob (options, img) { - return imageToCanvas(img).then(curry(canvasToBlob, options)) -} diff --git a/api/image/imageToBlob/readme.md b/api/image/imageToBlob/readme.md deleted file mode 100644 index ac68408..0000000 --- a/api/image/imageToBlob/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageToBlob - -## Usage - -```js -imageToBlob(options, img) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/image/imageToBuffer/index.js b/api/image/imageToBuffer/index.js deleted file mode 100644 index a532ec3..0000000 --- a/api/image/imageToBuffer/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToBuffer } from '../../blob/blobToBuffer' -import { imageToBlob } from '../imageToBlob' - -export function imageToBuffer (options, img) { - return imageToBlob(options, img).then(blobToBuffer) -} diff --git a/api/image/imageToBuffer/readme.md b/api/image/imageToBuffer/readme.md deleted file mode 100644 index fce7044..0000000 --- a/api/image/imageToBuffer/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageToBuffer - -## Usage - -```js -imageToBuffer(options, img) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/image/imageToCanvas/index.js b/api/image/imageToCanvas/index.js deleted file mode 100644 index 8ab1195..0000000 --- a/api/image/imageToCanvas/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import { element } from '../../../dom/node/element' -import { update } from '../../../dom/tree/update' -import { promise } from '../../../primitive/function/promise' - -export function imageToCanvas (img) { - return promise(toCanvas, img) -} - -function toCanvas (img, resolve) { - const canvas = update(element('canvas'), { - width: img.naturalWidth, - height: img.naturalHeight - }) - const context = canvas.getContext('2d') - - context.fillStyle = 'transparent' - context.fillRect(0, 0, img.naturalWidth, img.naturalHeight) - context.save() - context.drawImage(img, 0, 0) - resolve(canvas) -} diff --git a/api/image/imageToCanvas/readme.md b/api/image/imageToCanvas/readme.md deleted file mode 100644 index 61a0446..0000000 --- a/api/image/imageToCanvas/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageToCanvas - -## Usage - -```js -imageToCanvas(options, img) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/image/imageToDataURL/index.js b/api/image/imageToDataURL/index.js deleted file mode 100644 index 574d12b..0000000 --- a/api/image/imageToDataURL/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToDataURL } from '../../blob/blobToDataURL' -import { imageToBlob } from '../imageToBlob' - -export function imageToDataURL (options, img) { - return imageToBlob(options, img).then(blobToDataURL) -} diff --git a/api/image/imageToDataURL/readme.md b/api/image/imageToDataURL/readme.md deleted file mode 100644 index 7d94dc8..0000000 --- a/api/image/imageToDataURL/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageToDataURL - -## Usage - -```js -imageToDataURL(options, img) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/image/imageToText/index.js b/api/image/imageToText/index.js deleted file mode 100644 index 794df5c..0000000 --- a/api/image/imageToText/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blobToText } from '../../blob/blobToText' -import { imageToBlob } from '../imageToBlob' - -export function imageToText (options, img) { - return imageToBlob(options, img).then(blobToText) -} diff --git a/api/image/imageToText/readme.md b/api/image/imageToText/readme.md deleted file mode 100644 index f5b68a0..0000000 --- a/api/image/imageToText/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/imageToText - -## Usage - -```js -imageToText(options, img) -``` - -## Options - -* mime -* quality \ No newline at end of file diff --git a/api/image/readme.md b/api/image/readme.md deleted file mode 100644 index 745d1b5..0000000 --- a/api/image/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# [anticore](../../../../#reference)/[api](../#reference)/image - -* [compressImage](./compressImage/#reference) -* [imageFromInput](./imageFromInput/#reference) -* [imageToBlob](./imageToBlob/#reference) -* [imageToBuffer](imageToBuffer/#reference) -* [imageToCanvas](imageToCanvas/#reference) -* [imageToDataURL](imageToDataURL/#reference) -* [imageToText](imageToText/#reference) -* [resizeImage](resizeImage/#reference) \ No newline at end of file diff --git a/api/image/resizeImage/index.js b/api/image/resizeImage/index.js deleted file mode 100644 index f576f89..0000000 --- a/api/image/resizeImage/index.js +++ /dev/null @@ -1,76 +0,0 @@ -import { element } from '../../../dom/node/element' -import { curry } from '../../../primitive/function/curry' -import { promise } from '../../../primitive/function/promise' -import { create } from '../../../primitive/object/create' -import { canvasToImage } from '../../canvas/canvasToImage' - -const min = Math.min -const max = Math.max - -export function resizeImage (options, img) { - options = parse(img.naturalWidth, img.naturalHeight, options) - - return promise(toCanvas, options, img).then(curry(canvasToImage, options)) -} - -function toCanvas (options, img, resolve) { - const canvas = element('canvas') - - canvas.width = options.width - canvas.height = options.height - draw(options, img, canvas) - - resolve(canvas) -} - -function draw (options, img, canvas) { - const context = canvas.getContext('2d') - - context.fillStyle = 'transparent' - context.fillRect(0, 0, options.width, options.height) - context.save() - context.drawImage(img, 0, 0, img.width, img.height, 0, 0, options.width, - options.height) -} - -function parse (width, height, options) { - const result = create() - const ratio = width / height - - result.natural = normalize(width, height, ratio) - result.max = normalize(options.maxWidth, options.maxHeight, ratio, Infinity) - result.min = normalize(options.minWidth, options.minHeight, ratio, 0) - result.fixed = normalize(options.width, options.height, ratio, Infinity) - - minMax('width', result) - minMax('height', result) - - return result -} - -function normalize (width, height, ratio, defaultValue) { - const config = create() - - config.width = width || defaultValue - config.height = height || defaultValue - - if (width && height) { - if (height * ratio > width) { - config.height = width / ratio - } else { - config.width = height * ratio - } - } else if (width) { - config.height = width / ratio - } else if (height) { - config.width = height * ratio - } - - return config -} - -function minMax (key, config) { - config[key] = ~~min(config.max[key], - max(config.fixed[key], config.min[key])) || - config.natural[key] -} diff --git a/api/image/resizeImage/readme.md b/api/image/resizeImage/readme.md deleted file mode 100644 index ee2fb36..0000000 --- a/api/image/resizeImage/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# [anticore](../../../../../#reference)/[api](../../#reference)/[image](../#reference)/resizeImage - -## Usage - -```js -resizeImage(options, img) -``` - -## Options - -* height -* width -* minHeight -* minWidth -* maxHeight -* maxWidth -* mime -* quality \ No newline at end of file diff --git a/api/readme.md b/api/readme.md deleted file mode 100644 index 8e87e04..0000000 --- a/api/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# [anticore](../../../#reference)/api - -* [blob](./blob/#reference) -* [canvas](./canvas/#reference) -* [dataURL](./dataURL/#reference) -* [image](./image/#reference) \ No newline at end of file diff --git a/dom/emitter/.call.js b/dom/emitter/.call.js deleted file mode 100644 index 5a73dd1..0000000 --- a/dom/emitter/.call.js +++ /dev/null @@ -1,5 +0,0 @@ -export function call (method, event, element, listener, useCapture) { - if ('on'.concat(event) in element) { - method.call(element, event, listener, useCapture) - } -} diff --git a/dom/emitter/.callEach.js b/dom/emitter/.callEach.js deleted file mode 100644 index b942cfc..0000000 --- a/dom/emitter/.callEach.js +++ /dev/null @@ -1,46 +0,0 @@ -import { global } from '../../global' -import { create } from '../../primitive/object/create' -import { call } from './.call' - -const window = global() -const events = create() -const listen = window.Element.prototype.addEventListener - -events.blur = ['blur', 'touchcancel', 'touchleave'] -events.blur.listener = function (listener, event) { - return listener.call(this, event) -} - -events.click = ['click', 'touchend'] -events.click.listener = function (listener, event) { - if (!event.touches || event.touches.length === 1) { - return listener.call(this, event) - } -} - -events.focus = ['focus', 'touchstart'] -events.focus.listener = events.blur.listener - -export function callEach (method, event, element, listener, useCapture) { - let realListener = listener - let key = 0 - - if (event in events) { - const names = events[event] - const length = names.length - - if (method === listen) { - realListener = names.listener.bind(element, realListener) - } - - for (key; key < length; key += 1) { - call(method, names[key], element, realListener, useCapture) - } - - return realListener - } - - call(method, event, element, realListener, useCapture) - - return realListener -} diff --git a/dom/emitter/.matches.js b/dom/emitter/.matches.js deleted file mode 100644 index efb0965..0000000 --- a/dom/emitter/.matches.js +++ /dev/null @@ -1,12 +0,0 @@ -import { indexOf } from '../../primitive/array/indexOf' - -export function matches (e, ctrl, alt, shift, keys, code) { - if (e.ctrlKey !== ctrl || e.altKey !== alt || e.shiftKey !== shift) { - return false - } - - return !keys || - indexOf(keys, e.key) > -1 || - e.which === code || - e.keyCode === code -} diff --git a/dom/emitter/getTarget/index.js b/dom/emitter/getTarget/index.js deleted file mode 100644 index 7f1ec5c..0000000 --- a/dom/emitter/getTarget/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function getTarget (event) { - return event.target -} diff --git a/dom/emitter/getTarget/readme.md b/dom/emitter/getTarget/readme.md deleted file mode 100644 index 733823e..0000000 --- a/dom/emitter/getTarget/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/getTarget - -## Usage - -```js -getTarget(event) -``` \ No newline at end of file diff --git a/dom/emitter/off/index.js b/dom/emitter/off/index.js deleted file mode 100644 index 2060597..0000000 --- a/dom/emitter/off/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { global } from '../../../global' -import { callEach } from '../.callEach' - -const window = global() - -/** - * Forgets a listener of an event on an element (touch or not) - * @param {String} event - * @param {Element} element - * @param {Function} listener - * @param {Boolean} useCapture - * @returns {Function} listener - */ -export const off = callEach.bind(null, - window.Element.prototype.removeEventListener) diff --git a/dom/emitter/off/offBack/index.js b/dom/emitter/off/offBack/index.js deleted file mode 100644 index 4fff936..0000000 --- a/dom/emitter/off/offBack/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offBack (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offBack/readme.md b/dom/emitter/off/offBack/readme.md deleted file mode 100644 index 55d9067..0000000 --- a/dom/emitter/off/offBack/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offBack - -## Usage - -```js -offBack(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offBlur/index.js b/dom/emitter/off/offBlur/index.js deleted file mode 100644 index 8f765dd..0000000 --- a/dom/emitter/off/offBlur/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offBlur (element, listener, useCapture) { - return off('blur', element, listener, useCapture) -} diff --git a/dom/emitter/off/offBlur/readme.md b/dom/emitter/off/offBlur/readme.md deleted file mode 100644 index 10b3a83..0000000 --- a/dom/emitter/off/offBlur/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offBlur - -## Usage - -```js -offBlur(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offChange/index.js b/dom/emitter/off/offChange/index.js deleted file mode 100644 index 912ee0c..0000000 --- a/dom/emitter/off/offChange/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offChange (element, listener, useCapture) { - return off('change', element, listener, useCapture) -} diff --git a/dom/emitter/off/offChange/readme.md b/dom/emitter/off/offChange/readme.md deleted file mode 100644 index 9f3559b..0000000 --- a/dom/emitter/off/offChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offChange - -## Usage - -```js -offChange(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offClick/index.js b/dom/emitter/off/offClick/index.js deleted file mode 100644 index a7fd83b..0000000 --- a/dom/emitter/off/offClick/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offClick (element, listener, useCapture) { - return off('click', element, listener, useCapture) -} diff --git a/dom/emitter/off/offClick/readme.md b/dom/emitter/off/offClick/readme.md deleted file mode 100644 index 660dac7..0000000 --- a/dom/emitter/off/offClick/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offClick - -## Usage - -```js -offClick(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offDelete/index.js b/dom/emitter/off/offDelete/index.js deleted file mode 100644 index 32c5444..0000000 --- a/dom/emitter/off/offDelete/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offDelete (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offDelete/readme.md b/dom/emitter/off/offDelete/readme.md deleted file mode 100644 index 560613c..0000000 --- a/dom/emitter/off/offDelete/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offDelete - -## Usage - -```js -offDelete(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offDown/index.js b/dom/emitter/off/offDown/index.js deleted file mode 100644 index 892f9ab..0000000 --- a/dom/emitter/off/offDown/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offDown (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offDown/readme.md b/dom/emitter/off/offDown/readme.md deleted file mode 100644 index 9d75e98..0000000 --- a/dom/emitter/off/offDown/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offDown - -## Usage - -```js -offDown(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offDrag/index.js b/dom/emitter/off/offDrag/index.js deleted file mode 100644 index 2f94dd8..0000000 --- a/dom/emitter/off/offDrag/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offDrag (element, listener, useCapture) { - return off('drag', element, listener, useCapture) -} diff --git a/dom/emitter/off/offDrag/readme.md b/dom/emitter/off/offDrag/readme.md deleted file mode 100644 index 5de5a8a..0000000 --- a/dom/emitter/off/offDrag/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offDrag - -## Usage - -```js -offDrag(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offDragEnter/index.js b/dom/emitter/off/offDragEnter/index.js deleted file mode 100644 index 4dc6ca6..0000000 --- a/dom/emitter/off/offDragEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offDragEnter (element, listener, useCapture) { - return off('dragenter', element, listener, useCapture) -} diff --git a/dom/emitter/off/offDragEnter/readme.md b/dom/emitter/off/offDragEnter/readme.md deleted file mode 100644 index 718ca5c..0000000 --- a/dom/emitter/off/offDragEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offDragEnter - -## Usage - -```js -offDragEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offDrop/index.js b/dom/emitter/off/offDrop/index.js deleted file mode 100644 index bed1c3d..0000000 --- a/dom/emitter/off/offDrop/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offDrop (element, listener, useCapture) { - return off('drop', element, listener, useCapture) -} diff --git a/dom/emitter/off/offDrop/readme.md b/dom/emitter/off/offDrop/readme.md deleted file mode 100644 index 878fc37..0000000 --- a/dom/emitter/off/offDrop/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offDrop - -## Usage - -```js -offDrop(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offEnter/index.js b/dom/emitter/off/offEnter/index.js deleted file mode 100644 index 76ba6cd..0000000 --- a/dom/emitter/off/offEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offEnter (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offEnter/readme.md b/dom/emitter/off/offEnter/readme.md deleted file mode 100644 index c5cdb22..0000000 --- a/dom/emitter/off/offEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offEnter - -## Usage - -```js -offEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offError/index.js b/dom/emitter/off/offError/index.js deleted file mode 100644 index 4819466..0000000 --- a/dom/emitter/off/offError/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offError (element, listener, useCapture) { - return off('error', element, listener, useCapture) -} diff --git a/dom/emitter/off/offError/readme.md b/dom/emitter/off/offError/readme.md deleted file mode 100644 index 52b89bc..0000000 --- a/dom/emitter/off/offError/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offError - -## Usage - -```js -offError(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offFileInput/index.js b/dom/emitter/off/offFileInput/index.js deleted file mode 100644 index 31a05fe..0000000 --- a/dom/emitter/off/offFileInput/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { nodeName } from '../../../info/nodeName' -import { offChange } from '../offChange' -import { offDrop } from '../offDrop' - -export function offFileInput (element, listener, useCapture) { - if (nodeName(element) === 'input' && element.type === 'file') { - offChange(element, listener, useCapture) - offDrop(element, listener, useCapture) - - return listener - } -} diff --git a/dom/emitter/off/offFileInput/readme.md b/dom/emitter/off/offFileInput/readme.md deleted file mode 100644 index c541752..0000000 --- a/dom/emitter/off/offFileInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offFileInput - -## Usage - -```js -offFileInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offFocus/index.js b/dom/emitter/off/offFocus/index.js deleted file mode 100644 index cf08d14..0000000 --- a/dom/emitter/off/offFocus/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offFocus (element, listener, useCapture) { - return off('focus', element, listener, useCapture) -} diff --git a/dom/emitter/off/offFocus/readme.md b/dom/emitter/off/offFocus/readme.md deleted file mode 100644 index a099511..0000000 --- a/dom/emitter/off/offFocus/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offFocus - -## Usage - -```js -offFocus(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offInput/index.js b/dom/emitter/off/offInput/index.js deleted file mode 100644 index 1f17d55..0000000 --- a/dom/emitter/off/offInput/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offInput (element, listener, useCapture) { - return off('input', element, listener, useCapture) -} diff --git a/dom/emitter/off/offInput/readme.md b/dom/emitter/off/offInput/readme.md deleted file mode 100644 index e5d83b1..0000000 --- a/dom/emitter/off/offInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offInput - -## Usage - -```js -offInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offLeft/index.js b/dom/emitter/off/offLeft/index.js deleted file mode 100644 index 0b7fda2..0000000 --- a/dom/emitter/off/offLeft/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offLeft (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offLeft/readme.md b/dom/emitter/off/offLeft/readme.md deleted file mode 100644 index 80540e1..0000000 --- a/dom/emitter/off/offLeft/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offLeft - -## Usage - -```js -offLeft(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offLoad/index.js b/dom/emitter/off/offLoad/index.js deleted file mode 100644 index b94b898..0000000 --- a/dom/emitter/off/offLoad/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offLoad (element, listener, useCapture) { - return off('load', element, listener, useCapture) -} diff --git a/dom/emitter/off/offLoad/readme.md b/dom/emitter/off/offLoad/readme.md deleted file mode 100644 index 76e2a72..0000000 --- a/dom/emitter/off/offLoad/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offLoad - -## Usage - -```js -offLoad(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offMessage/index.js b/dom/emitter/off/offMessage/index.js deleted file mode 100644 index 4fd47da..0000000 --- a/dom/emitter/off/offMessage/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offMessage (element, listener, useCapture) { - return off('message', element, listener, useCapture) -} diff --git a/dom/emitter/off/offMessage/readme.md b/dom/emitter/off/offMessage/readme.md deleted file mode 100644 index f69f324..0000000 --- a/dom/emitter/off/offMessage/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offMessage - -## Usage - -```js -offMessage(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offMouseOut/index.js b/dom/emitter/off/offMouseOut/index.js deleted file mode 100644 index 3608a44..0000000 --- a/dom/emitter/off/offMouseOut/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offMouseOut (element, listener, useCapture) { - return off('mouseout', element, listener, useCapture) -} diff --git a/dom/emitter/off/offMouseOut/readme.md b/dom/emitter/off/offMouseOut/readme.md deleted file mode 100644 index f8b2dae..0000000 --- a/dom/emitter/off/offMouseOut/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offMouseOut - -## Usage - -```js -offMouseOut(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offMouseOver/index.js b/dom/emitter/off/offMouseOver/index.js deleted file mode 100644 index 0fd10bf..0000000 --- a/dom/emitter/off/offMouseOver/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offMouseOver (element, listener, useCapture) { - return off('mouseover', element, listener, useCapture) -} diff --git a/dom/emitter/off/offMouseOver/readme.md b/dom/emitter/off/offMouseOver/readme.md deleted file mode 100644 index dbd7cd5..0000000 --- a/dom/emitter/off/offMouseOver/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offMouseOver - -## Usage - -```js -offMouseOver(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offRight/index.js b/dom/emitter/off/offRight/index.js deleted file mode 100644 index ec2b2b2..0000000 --- a/dom/emitter/off/offRight/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offRight (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offRight/readme.md b/dom/emitter/off/offRight/readme.md deleted file mode 100644 index 651ddc0..0000000 --- a/dom/emitter/off/offRight/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offRight - -## Usage - -```js -offRight(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offSelectionChange/index.js b/dom/emitter/off/offSelectionChange/index.js deleted file mode 100644 index 2ff807e..0000000 --- a/dom/emitter/off/offSelectionChange/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { off } from '..' -import { document } from '../../../node/document' - -export function offSelectionChange (listener, useCapture) { - return off('selectionchange', document(), listener, useCapture) -} diff --git a/dom/emitter/off/offSelectionChange/readme.md b/dom/emitter/off/offSelectionChange/readme.md deleted file mode 100644 index bc4ac1b..0000000 --- a/dom/emitter/off/offSelectionChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/onSelectionChange - -## Usage - -```js -offSelectionChange(listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offShiftEnter/index.js b/dom/emitter/off/offShiftEnter/index.js deleted file mode 100644 index f90fff0..0000000 --- a/dom/emitter/off/offShiftEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offShiftEnter (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offShiftEnter/readme.md b/dom/emitter/off/offShiftEnter/readme.md deleted file mode 100644 index 2add5a9..0000000 --- a/dom/emitter/off/offShiftEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offShiftEnter - -## Usage - -```js -offShiftEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offSpace/index.js b/dom/emitter/off/offSpace/index.js deleted file mode 100644 index e20a41f..0000000 --- a/dom/emitter/off/offSpace/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offSpace (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offSpace/readme.md b/dom/emitter/off/offSpace/readme.md deleted file mode 100644 index 5b4a2bb..0000000 --- a/dom/emitter/off/offSpace/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offSpace - -## Usage - -```js -offSpace(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offSubmit/index.js b/dom/emitter/off/offSubmit/index.js deleted file mode 100644 index d0b3a99..0000000 --- a/dom/emitter/off/offSubmit/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offSubmit (element, listener, useCapture) { - return off('submit', element, listener, useCapture) -} diff --git a/dom/emitter/off/offSubmit/readme.md b/dom/emitter/off/offSubmit/readme.md deleted file mode 100644 index ebccff5..0000000 --- a/dom/emitter/off/offSubmit/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offSubmit - -## Usage - -```js -offSubmit(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/offUp/index.js b/dom/emitter/off/offUp/index.js deleted file mode 100644 index d45faba..0000000 --- a/dom/emitter/off/offUp/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { off } from '..' - -export function offUp (element, listener, useCapture) { - return off('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/off/offUp/readme.md b/dom/emitter/off/offUp/readme.md deleted file mode 100644 index a55e63c..0000000 --- a/dom/emitter/off/offUp/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[off](../#reference)/offUp - -## Usage - -```js -offUp(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/off/readme.md b/dom/emitter/off/readme.md deleted file mode 100644 index 1ee0e1d..0000000 --- a/dom/emitter/off/readme.md +++ /dev/null @@ -1,31 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/off - -## Usage - -```js -off(event, node, listener, useCapture) -``` - -* [offBack](./offBack/#reference) -* [offBlur](./offBlur/#reference) -* [offChange](./offChange/#reference) -* [offClick](./offClick/#reference) -* [offDelete](./offDelete/#reference) -* [offDown](./offDown/#reference) -* [offDrag](./offDrag/#reference) -* [offDragEnter](./offDragEnter/#reference) -* [offDrop](./offDrop/#reference) -* [offEnter](./offEnter/#reference) -* [offFocus](./offFocus/#reference) -* [offInput](./offInput/#reference) -* [offLeft](./offLeft/#reference) -* [offLoad](./offLoad/#reference) -* [offMessage](./offMessage/#reference) -* [offMouseOut](./offMouseOut/#reference) -* [offMouseOver](./offMouseOver/#reference) -* [offRight](./offRight/#reference) -* [offSelectionChange](./offSelectionChange/#reference) -* [offShiftEnter](./offShiftEnter/#reference) -* [offSpace](./offSpace/#reference) -* [offSubmit](./offSubmit/#reference) -* [offUp](./offUp/#reference) \ No newline at end of file diff --git a/dom/emitter/on/index.js b/dom/emitter/on/index.js deleted file mode 100644 index 1813b46..0000000 --- a/dom/emitter/on/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { global } from '../../../global' -import { callEach } from '../.callEach' - -const window = global() - -/** - * Listens an event on an element (touch or not) - * @param {String} event - * @param {Element} element - * @param {Function} listener - * @param {Boolean} useCapture - * @returns {Function} realListener - */ -export const on = callEach.bind(null, - window.Element.prototype.addEventListener) diff --git a/dom/emitter/on/onBack/index.js b/dom/emitter/on/onBack/index.js deleted file mode 100644 index 7b19068..0000000 --- a/dom/emitter/on/onBack/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onBack (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, ['Backspace'], 8)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onBack/readme.md b/dom/emitter/on/onBack/readme.md deleted file mode 100644 index 0ed4418..0000000 --- a/dom/emitter/on/onBack/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onBack - -## Usage - -```js -onBack(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onBlur/index.js b/dom/emitter/on/onBlur/index.js deleted file mode 100644 index 6f0be11..0000000 --- a/dom/emitter/on/onBlur/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onBlur (element, listener, useCapture) { - return on('blur', element, listener, useCapture) -} diff --git a/dom/emitter/on/onBlur/readme.md b/dom/emitter/on/onBlur/readme.md deleted file mode 100644 index 54bad61..0000000 --- a/dom/emitter/on/onBlur/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onBlur - -## Usage - -```js -onBlur(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onChange/index.js b/dom/emitter/on/onChange/index.js deleted file mode 100644 index b713e6e..0000000 --- a/dom/emitter/on/onChange/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onChange (element, listener, useCapture) { - return on('change', element, listener, useCapture) -} diff --git a/dom/emitter/on/onChange/readme.md b/dom/emitter/on/onChange/readme.md deleted file mode 100644 index 2d223d7..0000000 --- a/dom/emitter/on/onChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onChange - -## Usage - -```js -onChange(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onClick/index.js b/dom/emitter/on/onClick/index.js deleted file mode 100644 index 37e23d4..0000000 --- a/dom/emitter/on/onClick/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onClick (element, listener, useCapture) { - return on('click', element, function (event) { - if (matches(event, false, false, false)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onClick/readme.md b/dom/emitter/on/onClick/readme.md deleted file mode 100644 index 6427d15..0000000 --- a/dom/emitter/on/onClick/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/ onClick - -## Usage - -```js -onClick(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onDelete/index.js b/dom/emitter/on/onDelete/index.js deleted file mode 100644 index 45e1e1d..0000000 --- a/dom/emitter/on/onDelete/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onDelete (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, ['Delete', 'Del'], 46)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onDelete/readme.md b/dom/emitter/on/onDelete/readme.md deleted file mode 100644 index 4c0df63..0000000 --- a/dom/emitter/on/onDelete/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onDelete - -## Usage - -```js -onDelete(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onDown/index.js b/dom/emitter/on/onDown/index.js deleted file mode 100644 index f1873d5..0000000 --- a/dom/emitter/on/onDown/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onDown (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, ['ArrowDown', 'Down'], 47)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onDown/readme.md b/dom/emitter/on/onDown/readme.md deleted file mode 100644 index f86d40b..0000000 --- a/dom/emitter/on/onDown/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onDown - -## Usage - -```js -onDown(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onDrag/index.js b/dom/emitter/on/onDrag/index.js deleted file mode 100644 index c5e9275..0000000 --- a/dom/emitter/on/onDrag/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onDrag (element, listener, useCapture) { - return on('drag', element, listener, useCapture) -} diff --git a/dom/emitter/on/onDrag/readme.md b/dom/emitter/on/onDrag/readme.md deleted file mode 100644 index 9abd97b..0000000 --- a/dom/emitter/on/onDrag/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onDrag - -## Usage - -```js -onDrag(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onDragEnter/index.js b/dom/emitter/on/onDragEnter/index.js deleted file mode 100644 index 645ac73..0000000 --- a/dom/emitter/on/onDragEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onDragEnter (element, listener, useCapture) { - return on('dragenter', element, listener, useCapture) -} diff --git a/dom/emitter/on/onDragEnter/readme.md b/dom/emitter/on/onDragEnter/readme.md deleted file mode 100644 index 64bc90b..0000000 --- a/dom/emitter/on/onDragEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onDragEnter - -## Usage - -```js -onDragEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onDrop/index.js b/dom/emitter/on/onDrop/index.js deleted file mode 100644 index eaf1baf..0000000 --- a/dom/emitter/on/onDrop/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onDrop (element, listener, useCapture) { - return on('drop', element, listener, useCapture) -} diff --git a/dom/emitter/on/onDrop/readme.md b/dom/emitter/on/onDrop/readme.md deleted file mode 100644 index a9c14b0..0000000 --- a/dom/emitter/on/onDrop/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onDrop - -## Usage - -```js -onDrop(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onEnter/index.js b/dom/emitter/on/onEnter/index.js deleted file mode 100644 index 19c9c1a..0000000 --- a/dom/emitter/on/onEnter/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onEnter (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, ['Enter'], 13)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onEnter/readme.md b/dom/emitter/on/onEnter/readme.md deleted file mode 100644 index 730eaf6..0000000 --- a/dom/emitter/on/onEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onEnter - -## Usage - -```js -onEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onError/index.js b/dom/emitter/on/onError/index.js deleted file mode 100644 index f7630e8..0000000 --- a/dom/emitter/on/onError/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onError (element, listener, useCapture) { - return on('error', element, listener, useCapture) -} diff --git a/dom/emitter/on/onError/readme.md b/dom/emitter/on/onError/readme.md deleted file mode 100644 index 381797d..0000000 --- a/dom/emitter/on/onError/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onError - -## Usage - -```js -onError(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onFileInput/index.js b/dom/emitter/on/onFileInput/index.js deleted file mode 100644 index 3a2bcc4..0000000 --- a/dom/emitter/on/onFileInput/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import { nodeName } from '../../../info/nodeName' -import { prevent } from '../../prevent' -import { onChange } from '../onChange' -import { onDrop } from '../onDrop' - -function trueListener (listener, event) { - if (event.type === 'drop') { - prevent(event) - } - - listener.call(this, event) -} - -export function onFileInput (element, listener, useCapture) { - if (nodeName(element) === 'input' && element.type === 'file') { - listener = trueListener.bind(element, listener) - - onChange(element, listener, useCapture) - onDrop(element, listener, useCapture) - - return listener - } -} diff --git a/dom/emitter/on/onFileInput/readme.md b/dom/emitter/on/onFileInput/readme.md deleted file mode 100644 index ccefdb0..0000000 --- a/dom/emitter/on/onFileInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onFileInput - -## Usage - -```js -onFileInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onFocus/index.js b/dom/emitter/on/onFocus/index.js deleted file mode 100644 index 87b341a..0000000 --- a/dom/emitter/on/onFocus/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onFocus (element, listener, useCapture) { - return on('focus', element, listener, useCapture) -} diff --git a/dom/emitter/on/onFocus/readme.md b/dom/emitter/on/onFocus/readme.md deleted file mode 100644 index a1a01bb..0000000 --- a/dom/emitter/on/onFocus/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onFocus - -## Usage - -```js -onFocus(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onInput/index.js b/dom/emitter/on/onInput/index.js deleted file mode 100644 index 13f1375..0000000 --- a/dom/emitter/on/onInput/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onInput (element, listener, useCapture) { - return on('input', element, listener, useCapture) -} diff --git a/dom/emitter/on/onInput/readme.md b/dom/emitter/on/onInput/readme.md deleted file mode 100644 index 07affb6..0000000 --- a/dom/emitter/on/onInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onInput - -## Usage - -```js -onInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onLeft/index.js b/dom/emitter/on/onLeft/index.js deleted file mode 100644 index cc70fc5..0000000 --- a/dom/emitter/on/onLeft/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onLeft (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, ['ArrowLeft', 'Left'], 37) && !event.shiftKey && !event.ctrlKey) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onLeft/readme.md b/dom/emitter/on/onLeft/readme.md deleted file mode 100644 index 58c51de..0000000 --- a/dom/emitter/on/onLeft/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onLeft - -## Usage - -```js -onLeft(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onLoad/index.js b/dom/emitter/on/onLoad/index.js deleted file mode 100644 index cb7a6f3..0000000 --- a/dom/emitter/on/onLoad/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onLoad (element, listener, useCapture) { - return on('load', element, listener, useCapture) -} diff --git a/dom/emitter/on/onLoad/readme.md b/dom/emitter/on/onLoad/readme.md deleted file mode 100644 index 8a19ac0..0000000 --- a/dom/emitter/on/onLoad/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onLoad - -## Usage - -```js -onLoad(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onMessage/index.js b/dom/emitter/on/onMessage/index.js deleted file mode 100644 index 14c60da..0000000 --- a/dom/emitter/on/onMessage/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onMessage (element, listener, useCapture) { - return on('message', element, listener, useCapture) -} diff --git a/dom/emitter/on/onMessage/readme.md b/dom/emitter/on/onMessage/readme.md deleted file mode 100644 index 32e679d..0000000 --- a/dom/emitter/on/onMessage/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onMessage - -## Usage - -```js -onMessage(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onMouseOut/index.js b/dom/emitter/on/onMouseOut/index.js deleted file mode 100644 index 0bbfda6..0000000 --- a/dom/emitter/on/onMouseOut/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onMouseOut (element, listener, useCapture) { - return on('mouseout', element, listener, useCapture) -} diff --git a/dom/emitter/on/onMouseOut/readme.md b/dom/emitter/on/onMouseOut/readme.md deleted file mode 100644 index d47820c..0000000 --- a/dom/emitter/on/onMouseOut/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onMouseOut - -## Usage - -```js -onMouseOut(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onMouseOver/index.js b/dom/emitter/on/onMouseOver/index.js deleted file mode 100644 index 0c819bf..0000000 --- a/dom/emitter/on/onMouseOver/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onMouseOver (element, listener, useCapture) { - return on('mouseover', element, listener, useCapture) -} diff --git a/dom/emitter/on/onMouseOver/readme.md b/dom/emitter/on/onMouseOver/readme.md deleted file mode 100644 index d466d78..0000000 --- a/dom/emitter/on/onMouseOver/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onMouseOver - -## Usage - -```js -onMouseOver(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onRight/index.js b/dom/emitter/on/onRight/index.js deleted file mode 100644 index cd9f0f8..0000000 --- a/dom/emitter/on/onRight/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onRight (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, ['ArrowRight', 'Right'], 39) && !event.shiftKey && !event.ctrlKey) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onRight/readme.md b/dom/emitter/on/onRight/readme.md deleted file mode 100644 index b0c3fa5..0000000 --- a/dom/emitter/on/onRight/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onRight - -## Usage - -```js -onRight(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onSelectionChange/index.js b/dom/emitter/on/onSelectionChange/index.js deleted file mode 100644 index 5ebefbb..0000000 --- a/dom/emitter/on/onSelectionChange/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { on } from '..' -import { document } from '../../../node/document' - -export function onSelectionChange (listener, useCapture) { - return on('selectionchange', document(), listener, useCapture) -} diff --git a/dom/emitter/on/onSelectionChange/readme.md b/dom/emitter/on/onSelectionChange/readme.md deleted file mode 100644 index 860a708..0000000 --- a/dom/emitter/on/onSelectionChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onSelectionChange - -## Usage - -```js -onSelectionChange(listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onShiftEnter/index.js b/dom/emitter/on/onShiftEnter/index.js deleted file mode 100644 index 73586a1..0000000 --- a/dom/emitter/on/onShiftEnter/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onShiftEnter (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, true, ['Enter'], 13)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onShiftEnter/readme.md b/dom/emitter/on/onShiftEnter/readme.md deleted file mode 100644 index d1ec3fa..0000000 --- a/dom/emitter/on/onShiftEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onShiftEnter - -## Usage - -```js -onShiftEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onSpace/index.js b/dom/emitter/on/onSpace/index.js deleted file mode 100644 index 713572d..0000000 --- a/dom/emitter/on/onSpace/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onSpace (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, [' ', 'Spacebar'], 32)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onSpace/readme.md b/dom/emitter/on/onSpace/readme.md deleted file mode 100644 index 2a62e23..0000000 --- a/dom/emitter/on/onSpace/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onSpace - -## Usage - -```js -onSpace(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onSubmit/index.js b/dom/emitter/on/onSubmit/index.js deleted file mode 100644 index 0ce6f8d..0000000 --- a/dom/emitter/on/onSubmit/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { on } from '..' - -export function onSubmit (element, listener, useCapture) { - return on('submit', element, listener, useCapture) -} diff --git a/dom/emitter/on/onSubmit/readme.md b/dom/emitter/on/onSubmit/readme.md deleted file mode 100644 index 1e406f1..0000000 --- a/dom/emitter/on/onSubmit/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onSubmit - -## Usage - -```js -onSubmit(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/onUp/index.js b/dom/emitter/on/onUp/index.js deleted file mode 100644 index 55f1671..0000000 --- a/dom/emitter/on/onUp/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { on } from '..' -import { matches } from '../../.matches' - -export function onUp (element, listener, useCapture) { - return on('keydown', element, function (event) { - if (matches(event, false, false, false, false, ['ArrowUp', 'Up'], 39)) { - return listener.call(this, event) - } - }, useCapture) -} diff --git a/dom/emitter/on/onUp/readme.md b/dom/emitter/on/onUp/readme.md deleted file mode 100644 index cdfcb26..0000000 --- a/dom/emitter/on/onUp/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[on](../#reference)/onUp - -## Usage - -```js -onUp(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/on/readme.md b/dom/emitter/on/readme.md deleted file mode 100644 index db84b67..0000000 --- a/dom/emitter/on/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/on - -## Usage - -```js -on(event, node, listener, useCapture) -``` - -* [onBack](./onBack/#reference) -* [onBlur](./onBlur/#reference) -* [onChange](./onChange/#reference) -* [onClick](./onClick/#reference) -* [onDelete](./onDelete/#reference) -* [onDown](./onDown/#reference) -* [onDrag](./onDrag/#reference) -* [onDragEnter](./onDragEnter/#reference) -* [onDrop](./onDrop/#reference) -* [onEnter](./onEnter/#reference) -* [onError](./onError/#reference) -* [onFileInput](./onFileInput/#reference) -* [onFocus](./onFocus/#reference) -* [onInput](./onInput/#reference) -* [onLeft](./onLeft/#reference) -* [onLoad](./onLoad/#reference) -* [onMessage](./onMessage/#reference) -* [onMouseOut](./onMouseOut/#reference) -* [onMouseOver](./onMouseOver/#reference) -* [onRight](./onRight/#reference) -* [onSelectionChange](./onSelectionChange/#reference) -* [onShiftEnter](./onShiftEnter/#reference) -* [onSpace](./onSpace/#reference) -* [onSubmit](./onSubmit/#reference) -* [onUp](./onUp/#reference) \ No newline at end of file diff --git a/dom/emitter/once/index.js b/dom/emitter/once/index.js deleted file mode 100644 index 8f92528..0000000 --- a/dom/emitter/once/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { off } from '../off' -import { on } from '../on' - -/** - * Listens once an event on an element (touch or not) - * @param {String} event - * @param {Element} element - * @param {Function} listener - * @param {Boolean} useCapture - * @returns {Function} listener - */ -export function once (event, element, listener, useCapture) { - let realListener = on(event, element, function (event) { - off(event.type, element, realListener, useCapture) - - return listener.call(this, event) - }, useCapture) - - return realListener -} diff --git a/dom/emitter/once/onceBack/index.js b/dom/emitter/once/onceBack/index.js deleted file mode 100644 index 643411c..0000000 --- a/dom/emitter/once/onceBack/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceBack (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceBack/readme.md b/dom/emitter/once/onceBack/readme.md deleted file mode 100644 index fe70d6a..0000000 --- a/dom/emitter/once/onceBack/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onBack - -## Usage - -```js -onceBack(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceBlur/index.js b/dom/emitter/once/onceBlur/index.js deleted file mode 100644 index 1e3f982..0000000 --- a/dom/emitter/once/onceBlur/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceBlur (element, listener, useCapture) { - return once('blur', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceBlur/readme.md b/dom/emitter/once/onceBlur/readme.md deleted file mode 100644 index 25a5b22..0000000 --- a/dom/emitter/once/onceBlur/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onBlur - -## Usage - -```js -onceBlur(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceChange/index.js b/dom/emitter/once/onceChange/index.js deleted file mode 100644 index a33fe4a..0000000 --- a/dom/emitter/once/onceChange/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceChange (element, listener, useCapture) { - return once('change', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceChange/readme.md b/dom/emitter/once/onceChange/readme.md deleted file mode 100644 index 98a9d5e..0000000 --- a/dom/emitter/once/onceChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceChange - -## Usage - -```js -onceChange(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceClick/index.js b/dom/emitter/once/onceClick/index.js deleted file mode 100644 index bbdb10f..0000000 --- a/dom/emitter/once/onceClick/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceClick (element, listener, useCapture) { - return once('click', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceClick/readme.md b/dom/emitter/once/onceClick/readme.md deleted file mode 100644 index 1feeab9..0000000 --- a/dom/emitter/once/onceClick/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceClick - -## Usage - -```js -onceClick(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceDelete/index.js b/dom/emitter/once/onceDelete/index.js deleted file mode 100644 index 9f23ec9..0000000 --- a/dom/emitter/once/onceDelete/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceDelete (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceDelete/readme.md b/dom/emitter/once/onceDelete/readme.md deleted file mode 100644 index 13e357c..0000000 --- a/dom/emitter/once/onceDelete/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceDelete - -## Usage - -```js -onceDelete(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceDown/index.js b/dom/emitter/once/onceDown/index.js deleted file mode 100644 index e4a10d0..0000000 --- a/dom/emitter/once/onceDown/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceDown (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceDown/readme.md b/dom/emitter/once/onceDown/readme.md deleted file mode 100644 index 096b974..0000000 --- a/dom/emitter/once/onceDown/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onDown - -## Usage - -```js -onceDown(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceDrag/index.js b/dom/emitter/once/onceDrag/index.js deleted file mode 100644 index 2d6eb04..0000000 --- a/dom/emitter/once/onceDrag/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceDrag (element, listener, useCapture) { - return once('drag', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceDrag/readme.md b/dom/emitter/once/onceDrag/readme.md deleted file mode 100644 index f8b3224..0000000 --- a/dom/emitter/once/onceDrag/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onDrag - -## Usage - -```js -onceDrag(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceDragEnter/index.js b/dom/emitter/once/onceDragEnter/index.js deleted file mode 100644 index ac09ef2..0000000 --- a/dom/emitter/once/onceDragEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceDragEnter (element, listener, useCapture) { - return once('dragenter', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceDragEnter/readme.md b/dom/emitter/once/onceDragEnter/readme.md deleted file mode 100644 index 2e91c5f..0000000 --- a/dom/emitter/once/onceDragEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceDragEnter - -## Usage - -```js -onceDragEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceDrop/index.js b/dom/emitter/once/onceDrop/index.js deleted file mode 100644 index 14a1638..0000000 --- a/dom/emitter/once/onceDrop/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceDrop (element, listener, useCapture) { - return once('drop', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceDrop/readme.md b/dom/emitter/once/onceDrop/readme.md deleted file mode 100644 index e48e617..0000000 --- a/dom/emitter/once/onceDrop/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceDrop - -## Usage - -```js -onceDrop(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceEnter/index.js b/dom/emitter/once/onceEnter/index.js deleted file mode 100644 index 1d57090..0000000 --- a/dom/emitter/once/onceEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceEnter (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceEnter/readme.md b/dom/emitter/once/onceEnter/readme.md deleted file mode 100644 index 95b9c9f..0000000 --- a/dom/emitter/once/onceEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceEnter - -## Usage - -```js -onceEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceError/index.js b/dom/emitter/once/onceError/index.js deleted file mode 100644 index 44db3f0..0000000 --- a/dom/emitter/once/onceError/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceError (element, listener, useCapture) { - return once('error', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceError/readme.md b/dom/emitter/once/onceError/readme.md deleted file mode 100644 index d37e7de..0000000 --- a/dom/emitter/once/onceError/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceError - -## Usage - -```js -onceError(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceFileInput/index.js b/dom/emitter/once/onceFileInput/index.js deleted file mode 100644 index 1c1377b..0000000 --- a/dom/emitter/once/onceFileInput/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { nodeName } from '../../../info/nodeName' -import { onceChange } from '../onceChange' -import { onceDrop } from '../onceDrop' - -export function onceFileInput (element, listener, useCapture) { - if (nodeName(element) === 'input' && element.type === 'file') { - onceChange(element, listener, useCapture) - onceDrop(element, listener, useCapture) - - return listener - } -} diff --git a/dom/emitter/once/onceFileInput/readme.md b/dom/emitter/once/onceFileInput/readme.md deleted file mode 100644 index e532e98..0000000 --- a/dom/emitter/once/onceFileInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceFileInput - -## Usage - -```js -onceFileInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceFocus/index.js b/dom/emitter/once/onceFocus/index.js deleted file mode 100644 index 35d7886..0000000 --- a/dom/emitter/once/onceFocus/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceFocus (element, listener, useCapture) { - return once('focus', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceFocus/readme.md b/dom/emitter/once/onceFocus/readme.md deleted file mode 100644 index 0ed5822..0000000 --- a/dom/emitter/once/onceFocus/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceFocus - -## Usage - -```js -onceFocus(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceInput/index.js b/dom/emitter/once/onceInput/index.js deleted file mode 100644 index e2a8614..0000000 --- a/dom/emitter/once/onceInput/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceInput (element, listener, useCapture) { - return once('input', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceInput/readme.md b/dom/emitter/once/onceInput/readme.md deleted file mode 100644 index 54159ca..0000000 --- a/dom/emitter/once/onceInput/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceInput - -## Usage - -```js -onceInput(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceLeft/index.js b/dom/emitter/once/onceLeft/index.js deleted file mode 100644 index 4a8b217..0000000 --- a/dom/emitter/once/onceLeft/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceLeft (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceLeft/readme.md b/dom/emitter/once/onceLeft/readme.md deleted file mode 100644 index de88716..0000000 --- a/dom/emitter/once/onceLeft/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceLeft - -## Usage - -```js -onceLeft(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceLoad/index.js b/dom/emitter/once/onceLoad/index.js deleted file mode 100644 index 4ba7b2d..0000000 --- a/dom/emitter/once/onceLoad/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceLoad (element, listener, useCapture) { - return once('load', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceLoad/readme.md b/dom/emitter/once/onceLoad/readme.md deleted file mode 100644 index 9d00d8a..0000000 --- a/dom/emitter/once/onceLoad/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceLoad - -## Usage - -```js -onceLoad(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceMessage/index.js b/dom/emitter/once/onceMessage/index.js deleted file mode 100644 index aa9eeef..0000000 --- a/dom/emitter/once/onceMessage/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceMessage (element, listener, useCapture) { - return once('message', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceMessage/readme.md b/dom/emitter/once/onceMessage/readme.md deleted file mode 100644 index 85bd778..0000000 --- a/dom/emitter/once/onceMessage/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceMessage - -## Usage - -```js -onceMessage(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceMouseOut/index.js b/dom/emitter/once/onceMouseOut/index.js deleted file mode 100644 index 8a5f04d..0000000 --- a/dom/emitter/once/onceMouseOut/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceMouseOut (element, listener, useCapture) { - return once('mouseout', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceMouseOut/readme.md b/dom/emitter/once/onceMouseOut/readme.md deleted file mode 100644 index 78de74a..0000000 --- a/dom/emitter/once/onceMouseOut/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceMouseOut - -## Usage - -```js -onceMouseOut(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceMouseOver/index.js b/dom/emitter/once/onceMouseOver/index.js deleted file mode 100644 index f6688c4..0000000 --- a/dom/emitter/once/onceMouseOver/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceMouseOver (element, listener, useCapture) { - return once('mouseover', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceMouseOver/readme.md b/dom/emitter/once/onceMouseOver/readme.md deleted file mode 100644 index cff6bf0..0000000 --- a/dom/emitter/once/onceMouseOver/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceMouseOver - -## Usage - -```js -onceMouseOver(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceRight/index.js b/dom/emitter/once/onceRight/index.js deleted file mode 100644 index cd3177d..0000000 --- a/dom/emitter/once/onceRight/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceRight (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceRight/readme.md b/dom/emitter/once/onceRight/readme.md deleted file mode 100644 index c0a3db9..0000000 --- a/dom/emitter/once/onceRight/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceRight - -## Usage - -```js -onceRight(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceSelectionChange/index.js b/dom/emitter/once/onceSelectionChange/index.js deleted file mode 100644 index cae6870..0000000 --- a/dom/emitter/once/onceSelectionChange/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { once } from '..' -import { document } from '../../../node/document' - -export function onceSelectionChange (listener, useCapture) { - return once('selectionchange', document(), listener, useCapture) -} diff --git a/dom/emitter/once/onceSelectionChange/readme.md b/dom/emitter/once/onceSelectionChange/readme.md deleted file mode 100644 index 7fba8c4..0000000 --- a/dom/emitter/once/onceSelectionChange/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceSelectionChange - -## Usage - -```js -onceSelectionChange(listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceShiftEnter/index.js b/dom/emitter/once/onceShiftEnter/index.js deleted file mode 100644 index ed23b60..0000000 --- a/dom/emitter/once/onceShiftEnter/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceShiftEnter (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceShiftEnter/readme.md b/dom/emitter/once/onceShiftEnter/readme.md deleted file mode 100644 index 5cf575f..0000000 --- a/dom/emitter/once/onceShiftEnter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceShiftEnter - -## Usage - -```js -onceShiftEnter(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceSpace/index.js b/dom/emitter/once/onceSpace/index.js deleted file mode 100644 index 91d633b..0000000 --- a/dom/emitter/once/onceSpace/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceSpace (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceSpace/readme.md b/dom/emitter/once/onceSpace/readme.md deleted file mode 100644 index 235f8b3..0000000 --- a/dom/emitter/once/onceSpace/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceSpace - -## Usage - -```js -onceSpace(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceSubmit/index.js b/dom/emitter/once/onceSubmit/index.js deleted file mode 100644 index 37c500e..0000000 --- a/dom/emitter/once/onceSubmit/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceSubmit (element, listener, useCapture) { - return once('submit', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceSubmit/readme.md b/dom/emitter/once/onceSubmit/readme.md deleted file mode 100644 index 149fe29..0000000 --- a/dom/emitter/once/onceSubmit/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onceSubmit - -## Usage - -```js -onceSubmit(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/onceUp/index.js b/dom/emitter/once/onceUp/index.js deleted file mode 100644 index 1ace388..0000000 --- a/dom/emitter/once/onceUp/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { once } from '..' - -export function onceUp (element, listener, useCapture) { - return once('keydown', element, listener, useCapture) -} diff --git a/dom/emitter/once/onceUp/readme.md b/dom/emitter/once/onceUp/readme.md deleted file mode 100644 index 6e26964..0000000 --- a/dom/emitter/once/onceUp/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../../#reference)/[dom](../../../#reference)/[emitter](../../#reference)/[once](../#reference)/onUp - -## Usage - -```js -onceUp(node, listener, useCapture) -``` \ No newline at end of file diff --git a/dom/emitter/once/readme.md b/dom/emitter/once/readme.md deleted file mode 100644 index 014b463..0000000 --- a/dom/emitter/once/readme.md +++ /dev/null @@ -1,31 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/once - -## Usage - -```js -once(event, node, listener, useCapture) -``` - -* [onceBack](./onceBack/#reference) -* [onceBlur](./onceBlur/#reference) -* [onceChange](./onceChange/#reference) -* [onceClick](./onceClick/#reference) -* [onceDelete](./onceDelete/#reference) -* [onceDown](./onceDown/#reference) -* [onceDrag](./onceDrag/#reference) -* [onceDragEnter](./onceDragEnter/#reference) -* [onceDrop](./onceDrop/#reference) -* [onceEnter](./onceEnter/#reference) -* [onceFocus](./onceFocus/#reference) -* [onceInput](./onceInput/#reference) -* [onceLeft](./onceLeft/#reference) -* [onceLoad](./onceLoad/#reference) -* [onceMessage](./onceMessage/#reference) -* [onceMouseOut](./onceMouseOut/#reference) -* [onceMouseOver](./onceMouseOver/#reference) -* [onceRight](./onceRight/#reference) -* [onceSelectionChange](./onceSelectionChange/#reference) -* [onceShiftEnter](./onceShiftEnter/#reference) -* [onceSpace](./onceSpace/#reference) -* [onceSubmit](./onceSubmit/#reference) -* [onceUp](./onceUp/#reference) \ No newline at end of file diff --git a/dom/emitter/options/index.js b/dom/emitter/options/index.js deleted file mode 100644 index 2b89ec4..0000000 --- a/dom/emitter/options/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export const capture = true -export const once = true -export const passive = true diff --git a/dom/emitter/options/readme.md b/dom/emitter/options/readme.md deleted file mode 100644 index b3a33ad..0000000 --- a/dom/emitter/options/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/options - -## Usage - -```js -import {capture, once, passive} from 'anticore/dom/emitter/options' -``` \ No newline at end of file diff --git a/dom/emitter/prevent/index.js b/dom/emitter/prevent/index.js deleted file mode 100644 index 231568e..0000000 --- a/dom/emitter/prevent/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export function prevent (event) { - event.preventDefault() - - return event -} diff --git a/dom/emitter/prevent/readme.md b/dom/emitter/prevent/readme.md deleted file mode 100644 index 631b33f..0000000 --- a/dom/emitter/prevent/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/prevent - -## Usage - -```js -prevent(event) -``` \ No newline at end of file diff --git a/dom/emitter/readme.md b/dom/emitter/readme.md deleted file mode 100644 index a0e2ed1..0000000 --- a/dom/emitter/readme.md +++ /dev/null @@ -1,9 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/emitter - -* [getTarget](./getTarget/#reference) -* [off](./off/#reference) -* [on](./on/#reference) -* [once](./one/#reference) -* [options](./options/#reference) -* [prevent](./prevent/#reference) -* [stop](./stop/#reference) \ No newline at end of file diff --git a/dom/emitter/stop/index.js b/dom/emitter/stop/index.js deleted file mode 100644 index 978e613..0000000 --- a/dom/emitter/stop/index.js +++ /dev/null @@ -1,9 +0,0 @@ -export function stop (event, immediate) { - if (immediate) { - event.stopImmediatePropagation() - } else { - event.stopPropagation() - } - - return event -} diff --git a/dom/emitter/stop/readme.md b/dom/emitter/stop/readme.md deleted file mode 100644 index 9c5601e..0000000 --- a/dom/emitter/stop/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[emitter](../#reference)/stop - -## Usage - -```js -stop(event, immediate) -``` \ No newline at end of file diff --git a/dom/info/boundingRect/index.js b/dom/info/boundingRect/index.js deleted file mode 100644 index 789db16..0000000 --- a/dom/info/boundingRect/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function boundingRect (node) { - return node.getBoundingClientRect() -} diff --git a/dom/info/boundingRect/readme.md b/dom/info/boundingRect/readme.md deleted file mode 100644 index 7f2788f..0000000 --- a/dom/info/boundingRect/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/boundingRect - -## Usage - -```js -boundingRect(node) -``` \ No newline at end of file diff --git a/dom/info/contains/index.js b/dom/info/contains/index.js deleted file mode 100644 index ac68999..0000000 --- a/dom/info/contains/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function contains (value, node) { - return node.contains(value) -} diff --git a/dom/info/contains/readme.md b/dom/info/contains/readme.md deleted file mode 100644 index 98b11b3..0000000 --- a/dom/info/contains/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/contains - -## Usage - -```js -contains(value, node) -``` \ No newline at end of file diff --git a/dom/info/isCollection/index.js b/dom/info/isCollection/index.js deleted file mode 100644 index 3e61653..0000000 --- a/dom/info/isCollection/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { global } from '../../../global' -import { isInstanceOf } from '../../../primitive/object/isInstanceOf' - -const window = global() -const HTMLCollection = window.HTMLCollection -const NodeList = window.NodeList - -export function isCollection (contents) { - return isInstanceOf(HTMLCollection, contents) || - isInstanceOf(NodeList, contents) -} diff --git a/dom/info/isCollection/readme.md b/dom/info/isCollection/readme.md deleted file mode 100644 index e9a7517..0000000 --- a/dom/info/isCollection/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/isCollection - -## Usage - -```js -isCollection(contents) -``` \ No newline at end of file diff --git a/dom/info/isElement/index.js b/dom/info/isElement/index.js deleted file mode 100644 index 852f491..0000000 --- a/dom/info/isElement/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { isObject } from '../../../primitive/object/isObject' - -export function isElement (node) { - return isObject(node) && node.nodeType === 1 -} diff --git a/dom/info/isElement/readme.md b/dom/info/isElement/readme.md deleted file mode 100644 index 22785af..0000000 --- a/dom/info/isElement/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/isElement - -## Usage - -```js -isElement(node) -``` \ No newline at end of file diff --git a/dom/info/isEmpty/index.js b/dom/info/isEmpty/index.js deleted file mode 100644 index 263e65a..0000000 --- a/dom/info/isEmpty/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import { one } from '../../query/one' -import { text } from '../../tree/text' -import { isElement } from '../isElement' - -export function isEmpty (node) { - return (!isElement(node) || !one('*', node)) && - !(text(node) || '').trim().length -} diff --git a/dom/info/isEmpty/readme.md b/dom/info/isEmpty/readme.md deleted file mode 100644 index 594c3e2..0000000 --- a/dom/info/isEmpty/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/isEmpty - -## Usage - -```js -isEmpty(node) -``` \ No newline at end of file diff --git a/dom/info/isText/index.js b/dom/info/isText/index.js deleted file mode 100644 index 4274c4a..0000000 --- a/dom/info/isText/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { isObject } from '../../../primitive/object/isObject' - -export function isText (node) { - return isObject(node) && node.nodeType === 3 -} diff --git a/dom/info/isText/readme.md b/dom/info/isText/readme.md deleted file mode 100644 index ca00ffe..0000000 --- a/dom/info/isText/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/isText - -## Usage - -```js -isText(node) -``` \ No newline at end of file diff --git a/dom/info/matches/index.js b/dom/info/matches/index.js deleted file mode 100644 index 741def7..0000000 --- a/dom/info/matches/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import { isText } from '../../info/isText' -import { all } from '../../query/all' -import { parent } from '../../query/parent' - -export function matches (selector, node) { - const results = all(selector, node.document || node.ownerDocument) - let i = results.length - - if (isText(node)) { - node = parent(node) - } - - while (--i >= 0 && results.item(i) !== node) {} - - return i > -1 -} diff --git a/dom/info/matches/readme.md b/dom/info/matches/readme.md deleted file mode 100644 index 42bf002..0000000 --- a/dom/info/matches/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/matches - -## Usage - -```js -matches(selector, node) -``` \ No newline at end of file diff --git a/dom/info/nodeName/index.js b/dom/info/nodeName/index.js deleted file mode 100644 index d5b9b3f..0000000 --- a/dom/info/nodeName/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { toLowerCase } from '../../../primitive/string/toLowerCase' - -export function nodeName (node) { - if (!node) { - return null - } - - return toLowerCase(node.nodeName) -} diff --git a/dom/info/nodeName/readme.md b/dom/info/nodeName/readme.md deleted file mode 100644 index ed5cf38..0000000 --- a/dom/info/nodeName/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/nodeName - -## Usage - -```js -nodeName(node) -``` \ No newline at end of file diff --git a/dom/info/readme.md b/dom/info/readme.md deleted file mode 100644 index 0e6f07b..0000000 --- a/dom/info/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/info - -* [boundingRect](./boundingRect/#reference) -* [isCollection](./isCollection/#reference) -* [isElement](./isElement/#reference) -* [isEmpty](./isEmpty/#reference) -* [isText](./isText/#reference) -* [matches](./matches/#reference) -* [nodeName](./nodeName/#reference) -* [rects](./rects/#reference) \ No newline at end of file diff --git a/dom/info/rects/index.js b/dom/info/rects/index.js deleted file mode 100644 index e1041a5..0000000 --- a/dom/info/rects/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function rects (node) { - return node.getClientRects() -} diff --git a/dom/info/rects/readme.md b/dom/info/rects/readme.md deleted file mode 100644 index deca16f..0000000 --- a/dom/info/rects/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[info](../#reference)/rects - -## Usage - -```js -rects(node) -``` \ No newline at end of file diff --git a/dom/node/document/index.js b/dom/node/document/index.js deleted file mode 100644 index 24a3e25..0000000 --- a/dom/node/document/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { global } from '../../../global' - -export function document () { - return global().document -} diff --git a/dom/node/document/readme.md b/dom/node/document/readme.md deleted file mode 100644 index e6c16c0..0000000 --- a/dom/node/document/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[node](../#reference)/document - -## Usage - -```js -document() -``` \ No newline at end of file diff --git a/dom/node/element/index.js b/dom/node/element/index.js deleted file mode 100644 index dd97e21..0000000 --- a/dom/node/element/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { document } from '../document' - -export function element (tag) { - return document().createElement(tag) -} diff --git a/dom/node/element/readme.md b/dom/node/element/readme.md deleted file mode 100644 index 12f700f..0000000 --- a/dom/node/element/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[node](../#reference)/element - -## Usage - -```js -element(tag) -``` \ No newline at end of file diff --git a/dom/node/fragment/index.js b/dom/node/fragment/index.js deleted file mode 100644 index 158a205..0000000 --- a/dom/node/fragment/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { isCollection } from '../../info/isCollection' -import { wrap } from '../../tree/wrap' -import { wrapAll } from '../../tree/wrapAll' -import { document } from '../document' - -export function fragment (contents) { - let node = document().createDocumentFragment() - - if (!contents) { - return node - } - - if (isCollection(contents)) { - return wrapAll(contents, node) - } - - return wrap(contents, node) -} diff --git a/dom/node/fragment/readme.md b/dom/node/fragment/readme.md deleted file mode 100644 index b6c71d2..0000000 --- a/dom/node/fragment/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[node](../#reference)/fragment - -## Usage - -```js -fragment(contents) -``` \ No newline at end of file diff --git a/dom/node/readme.md b/dom/node/readme.md deleted file mode 100644 index 1bcc10c..0000000 --- a/dom/node/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/node - -* [document](./document/#reference) -* [element](./element/#reference) -* [fragment](./fragment/#reference) -* [text](./text/#reference) \ No newline at end of file diff --git a/dom/node/text/index.js b/dom/node/text/index.js deleted file mode 100644 index 6da5f47..0000000 --- a/dom/node/text/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { document } from '../document' - -export function text (data) { - return document().createTextNode(data) -} diff --git a/dom/node/text/readme.md b/dom/node/text/readme.md deleted file mode 100644 index a9a5c2a..0000000 --- a/dom/node/text/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[node](../#reference)/element - -## Usage - -```js -element(tag, config) -``` \ No newline at end of file diff --git a/dom/query/all/index.js b/dom/query/all/index.js deleted file mode 100644 index 0096694..0000000 --- a/dom/query/all/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { document } from '../../node/document' - -export function all (selector, refNode) { - return (refNode || document()).querySelectorAll(selector) -} diff --git a/dom/query/all/readme.md b/dom/query/all/readme.md deleted file mode 100644 index 417cdcb..0000000 --- a/dom/query/all/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/all - -## Usage - -```js -all(selector, node) -``` \ No newline at end of file diff --git a/dom/query/closest/index.js b/dom/query/closest/index.js deleted file mode 100644 index 9db5eb2..0000000 --- a/dom/query/closest/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { matches } from '../../info/matches' -import { parent } from '../parent' - -export function closest (selector, node) { - let last = node - let current = parent(last) - - while (current) { - if (matches(selector, current)) { - return current - } - - last = current - current = parent(last) - } - - return null -} diff --git a/dom/query/closest/readme.md b/dom/query/closest/readme.md deleted file mode 100644 index e4b51f2..0000000 --- a/dom/query/closest/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/closest - -## Usage - -```js -closest(selector, node) -``` \ No newline at end of file diff --git a/dom/query/closestOrSelf/index.js b/dom/query/closestOrSelf/index.js deleted file mode 100644 index 89045cf..0000000 --- a/dom/query/closestOrSelf/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { isElement } from '../../info/isElement' -import { matches } from '../../info/matches' -import { closest } from '../closest' - -export function closestOrSelf (selector, node) { - return isElement(node) && matches(selector, node) - ? node - : closest(selector, node) -} diff --git a/dom/query/closestOrSelf/readme.md b/dom/query/closestOrSelf/readme.md deleted file mode 100644 index 8a0bd5f..0000000 --- a/dom/query/closestOrSelf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/closestOrSelf - -## Usage - -```js -closestOrSelf(selector, node) -``` \ No newline at end of file diff --git a/dom/query/elements/index.js b/dom/query/elements/index.js deleted file mode 100644 index 533e220..0000000 --- a/dom/query/elements/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function elements (node) { - return node.children -} diff --git a/dom/query/elements/readme.md b/dom/query/elements/readme.md deleted file mode 100644 index c009bf4..0000000 --- a/dom/query/elements/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/elements - -## Usage - -```js -elements(node) -``` \ No newline at end of file diff --git a/dom/query/firstElement/index.js b/dom/query/firstElement/index.js deleted file mode 100644 index 49172b1..0000000 --- a/dom/query/firstElement/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function firstElement (node) { - return node.firstElementChild -} diff --git a/dom/query/firstElement/readme.md b/dom/query/firstElement/readme.md deleted file mode 100644 index 73f5e3a..0000000 --- a/dom/query/firstElement/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/firstElement - -## Usage - -```js -firstElement(node) -``` \ No newline at end of file diff --git a/dom/query/firstNode/index.js b/dom/query/firstNode/index.js deleted file mode 100644 index d2fa050..0000000 --- a/dom/query/firstNode/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function firstNode (node) { - return node.firstChild -} diff --git a/dom/query/firstNode/readme.md b/dom/query/firstNode/readme.md deleted file mode 100644 index d053229..0000000 --- a/dom/query/firstNode/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/firstNode - -## Usage - -```js -firstNode(node) -``` \ No newline at end of file diff --git a/dom/query/firstOrSelf/index.js b/dom/query/firstOrSelf/index.js deleted file mode 100644 index 3b46ec0..0000000 --- a/dom/query/firstOrSelf/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { firstNode } from '../firstNode' - -export function firstOrSelf (node) { - return firstNode(node) - ? firstOrSelf(firstNode(node)) - : node -} diff --git a/dom/query/firstOrSelf/readme.md b/dom/query/firstOrSelf/readme.md deleted file mode 100644 index 8e1f88d..0000000 --- a/dom/query/firstOrSelf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/firstOrSelf - -## Usage - -```js -firstOrSelf(node) -``` \ No newline at end of file diff --git a/dom/query/lastElement/index.js b/dom/query/lastElement/index.js deleted file mode 100644 index 943f404..0000000 --- a/dom/query/lastElement/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function lastElement (node) { - return node.lastElementChild -} diff --git a/dom/query/lastElement/readme.md b/dom/query/lastElement/readme.md deleted file mode 100644 index 96070e0..0000000 --- a/dom/query/lastElement/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/lastElement - -## Usage - -```js -lastElement(node) -``` \ No newline at end of file diff --git a/dom/query/lastNode/index.js b/dom/query/lastNode/index.js deleted file mode 100644 index 9935374..0000000 --- a/dom/query/lastNode/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function lastNode (node) { - return node.lastChild -} diff --git a/dom/query/lastNode/readme.md b/dom/query/lastNode/readme.md deleted file mode 100644 index 0278bc1..0000000 --- a/dom/query/lastNode/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/lastNode - -## Usage - -```js -lastNode(node) -``` \ No newline at end of file diff --git a/dom/query/lastOrSelf/index.js b/dom/query/lastOrSelf/index.js deleted file mode 100644 index 11b722d..0000000 --- a/dom/query/lastOrSelf/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { lastNode } from '../lastNode' - -export function lastOrSelf (node) { - return lastNode(node) - ? lastOrSelf(lastNode(node)) - : node -} diff --git a/dom/query/lastOrSelf/readme.md b/dom/query/lastOrSelf/readme.md deleted file mode 100644 index 0d6eda1..0000000 --- a/dom/query/lastOrSelf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/lastOrSelf - -## Usage - -```js -lastOrSelf(node) -``` \ No newline at end of file diff --git a/dom/query/nextElement/index.js b/dom/query/nextElement/index.js deleted file mode 100644 index 40a31b4..0000000 --- a/dom/query/nextElement/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function nextElement (node) { - return node.nextElementSibling -} diff --git a/dom/query/nextElement/readme.md b/dom/query/nextElement/readme.md deleted file mode 100644 index 4642aab..0000000 --- a/dom/query/nextElement/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/nextElement - -## Usage - -```js -nextElement(node) -``` \ No newline at end of file diff --git a/dom/query/nextElements/index.js b/dom/query/nextElements/index.js deleted file mode 100644 index d1bda55..0000000 --- a/dom/query/nextElements/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { filter } from '../../../primitive/array/filter' -import { isElement } from '../../info/isElement' -import { nextNodes } from '../nextNodes' - -export function nextElements (node) { - return filter(nextNodes(node), isElement) -} diff --git a/dom/query/nextElements/readme.md b/dom/query/nextElements/readme.md deleted file mode 100644 index b4484c0..0000000 --- a/dom/query/nextElements/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/nextElements - -## Usage - -```js -nextElements(node) -``` \ No newline at end of file diff --git a/dom/query/nextNode/index.js b/dom/query/nextNode/index.js deleted file mode 100644 index 6341560..0000000 --- a/dom/query/nextNode/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function nextNode (node) { - return node.nextSibling -} diff --git a/dom/query/nextNode/readme.md b/dom/query/nextNode/readme.md deleted file mode 100644 index 02c270f..0000000 --- a/dom/query/nextNode/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/nextNode - -## Usage - -```js -nextNode(node) -``` \ No newline at end of file diff --git a/dom/query/nextNodes/index.js b/dom/query/nextNodes/index.js deleted file mode 100644 index 917d2e0..0000000 --- a/dom/query/nextNodes/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { indexOf } from '../../../primitive/array/indexOf' -import { slice } from '../../../primitive/array/slice' -import { nodes } from '../nodes' -import { parent } from '../parent' - -export function nextNodes (node) { - let siblings = nodes(parent(node)) - - return slice(siblings, indexOf(siblings, node) + 1) -} diff --git a/dom/query/nextNodes/readme.md b/dom/query/nextNodes/readme.md deleted file mode 100644 index 031c365..0000000 --- a/dom/query/nextNodes/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/nextNodes - -## Usage - -```js -nextNodes(node) -``` \ No newline at end of file diff --git a/dom/query/nodes/index.js b/dom/query/nodes/index.js deleted file mode 100644 index 1839c8a..0000000 --- a/dom/query/nodes/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function nodes (node) { - return node.childNodes -} diff --git a/dom/query/nodes/readme.md b/dom/query/nodes/readme.md deleted file mode 100644 index 25692e9..0000000 --- a/dom/query/nodes/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/nodes - -## Usage - -```js -nodes(node) -``` \ No newline at end of file diff --git a/dom/query/one/index.js b/dom/query/one/index.js deleted file mode 100644 index d708820..0000000 --- a/dom/query/one/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { document } from '../../node/document' - -export function one (selector, refNode) { - return (refNode || document()).querySelector(selector) -} diff --git a/dom/query/one/readme.md b/dom/query/one/readme.md deleted file mode 100644 index e4456d3..0000000 --- a/dom/query/one/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/one - -## Usage - -```js -one(selector, node) -``` \ No newline at end of file diff --git a/dom/query/parent/index.js b/dom/query/parent/index.js deleted file mode 100644 index 130ff89..0000000 --- a/dom/query/parent/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function parent (node) { - return node.parentNode -} diff --git a/dom/query/parent/readme.md b/dom/query/parent/readme.md deleted file mode 100644 index d8c10aa..0000000 --- a/dom/query/parent/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/parent - -## Usage - -```js -parent(node) -``` \ No newline at end of file diff --git a/dom/query/previousElement/index.js b/dom/query/previousElement/index.js deleted file mode 100644 index 5825127..0000000 --- a/dom/query/previousElement/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function previousElement (node) { - return node.previousElementSibling -} diff --git a/dom/query/previousElement/readme.md b/dom/query/previousElement/readme.md deleted file mode 100644 index 679c3b8..0000000 --- a/dom/query/previousElement/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/previousElement - -## Usage - -```js -previousElement(node) -``` \ No newline at end of file diff --git a/dom/query/previousElements/index.js b/dom/query/previousElements/index.js deleted file mode 100644 index f04961c..0000000 --- a/dom/query/previousElements/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { filter } from '../../../primitive/array/filter' -import { isElement } from '../../info/isElement' -import { previousNodes } from '../previousNodes' - -export function previousElements (node) { - return filter(previousNodes(node), isElement) -} diff --git a/dom/query/previousElements/readme.md b/dom/query/previousElements/readme.md deleted file mode 100644 index 7850e9a..0000000 --- a/dom/query/previousElements/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/previousElements - -## Usage - -```js -previousElements(node) -``` \ No newline at end of file diff --git a/dom/query/previousNode/index.js b/dom/query/previousNode/index.js deleted file mode 100644 index d671d04..0000000 --- a/dom/query/previousNode/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function previousNode (node) { - return node.previousSibling -} diff --git a/dom/query/previousNode/readme.md b/dom/query/previousNode/readme.md deleted file mode 100644 index 2f01569..0000000 --- a/dom/query/previousNode/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/previousNode - -## Usage - -```js -previousNode(node) -``` \ No newline at end of file diff --git a/dom/query/previousNodes/index.js b/dom/query/previousNodes/index.js deleted file mode 100644 index c208026..0000000 --- a/dom/query/previousNodes/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { indexOf } from '../../../primitive/array/indexOf' -import { slice } from '../../../primitive/array/slice' -import { nodes } from '../nodes' -import { parent } from '../parent' - -export function previousNodes (node) { - let siblings = nodes(parent(node)) - - return slice(siblings, 0, indexOf(siblings, node)) -} diff --git a/dom/query/previousNodes/readme.md b/dom/query/previousNodes/readme.md deleted file mode 100644 index e524082..0000000 --- a/dom/query/previousNodes/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[query](../#reference)/previousNodes - -## Usage - -```js -previousNodes(node) -``` \ No newline at end of file diff --git a/dom/query/readme.md b/dom/query/readme.md deleted file mode 100644 index 818cab7..0000000 --- a/dom/query/readme.md +++ /dev/null @@ -1,23 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/query - -* [all](./all/#reference) -* [closest](./closest/#reference) -* [closestOrSelf](./closestOrSelf/#reference) -* [elements](./elements/#reference) -* [firstElement](./firstElement/#reference) -* [firstNode](./firstNode/#reference) -* [firstOrSelf](./firstOrSelf/#reference) -* [lastElement](./lastElement/#reference) -* [lastNode](./lastNode/#reference) -* [lastOrSelf](./lastOrSelf/#reference) -* [nextElement](./nextElement/#reference) -* [nextElements](./nextElements/#reference) -* [nextNode](./nextNode/#reference) -* [nextNodes](./nextNodes/#reference) -* [nodes](./nodes/#reference) -* [one](./one/#reference) -* [parent](./parent/#reference) -* [previousElement](./previousElement/#reference) -* [previousElements](./previousElements/#reference) -* [previousNode](./previousNode/#reference) -* [previousNodes](./previousNodes/#reference) \ No newline at end of file diff --git a/dom/readme.md b/dom/readme.md deleted file mode 100644 index 2236cf3..0000000 --- a/dom/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -# [anticore](../../../#reference)/dom - -* [emitter](./emitter/#reference) -* [info](./info/#reference) -* [node](./node/#reference) -* [query](./query/#reference) -* [selection](./selection/#reference) -* [tree](tree/#reference) \ No newline at end of file diff --git a/dom/selection/anchor/index.js b/dom/selection/anchor/index.js deleted file mode 100644 index aa7582b..0000000 --- a/dom/selection/anchor/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { create } from '../../../primitive/object/create' -import { current } from '../current' - -export const anchor = create() - -anchor.node = function () { - return current().anchorNode -} - -anchor.offset = function () { - return current().anchorOffset -} diff --git a/dom/selection/anchor/readme.md b/dom/selection/anchor/readme.md deleted file mode 100644 index bf31ecf..0000000 --- a/dom/selection/anchor/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/anchor - -## Usage - -```js -anchor.node() -``` - -## Usage - -```js -anchor.offset() -``` \ No newline at end of file diff --git a/dom/selection/current/index.js b/dom/selection/current/index.js deleted file mode 100644 index be71852..0000000 --- a/dom/selection/current/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { global } from '../../../global' - -export const current = global().getSelection diff --git a/dom/selection/current/readme.md b/dom/selection/current/readme.md deleted file mode 100644 index 168f4fd..0000000 --- a/dom/selection/current/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/current - -## Usage - -```js -current() -``` \ No newline at end of file diff --git a/dom/selection/end/index.js b/dom/selection/end/index.js deleted file mode 100644 index 7ef2a5e..0000000 --- a/dom/selection/end/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { lastOrSelf } from '../../query/lastOrSelf' -import { text } from '../../tree/text' -import { select } from '../select' - -export function end (node) { - let last = lastOrSelf(node) - - select(last, text(last).length) - - return last -} diff --git a/dom/selection/end/readme.md b/dom/selection/end/readme.md deleted file mode 100644 index 95fc525..0000000 --- a/dom/selection/end/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/end - -## Usage - -```js -end(node) -``` \ No newline at end of file diff --git a/dom/selection/ends/index.js b/dom/selection/ends/index.js deleted file mode 100644 index 6370249..0000000 --- a/dom/selection/ends/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import { all } from '../../query/all' -import { lastNode } from '../../query/lastNode' -import { current } from '../current' - -export function ends (node) { - const selection = current() - const anchor = selection.anchorNode - const offset = selection.anchorOffset - const elements = all('*', node) - const last = lastNode(elements[elements.length - 1]) - - return anchor === last && - last.nodeValue.length - 1 === offset -} diff --git a/dom/selection/ends/readme.md b/dom/selection/ends/readme.md deleted file mode 100644 index 5c9c01b..0000000 --- a/dom/selection/ends/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/ends - -## Usage - -```js -ends(node) -``` \ No newline at end of file diff --git a/dom/selection/focus/index.js b/dom/selection/focus/index.js deleted file mode 100644 index 5611e93..0000000 --- a/dom/selection/focus/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import { current } from '../current' - -export function focus (node) { - node.focus() -} - -focus.node = function () { - return current().focusNode -} - -focus.offset = function () { - return current().focusOffset -} diff --git a/dom/selection/focus/readme.md b/dom/selection/focus/readme.md deleted file mode 100644 index cf55da4..0000000 --- a/dom/selection/focus/readme.md +++ /dev/null @@ -1,17 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/focus - -## Usage - -```js -focus(node) -``` - -```js -focus.node() -``` - -## Usage - -```js -focus.offset() -``` \ No newline at end of file diff --git a/dom/selection/insert/index.js b/dom/selection/insert/index.js deleted file mode 100644 index d40d4d0..0000000 --- a/dom/selection/insert/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { isBoolean } from '../../../primitive/boolean/isBoolean' -import { isNumber } from '../../../primitive/number/isNumber' -import { isString } from '../../../primitive/string/isString' -import { text } from '../../node/text' -import { current } from '../current' - -export function insert (node) { - const selection = current() - const range = selection.getRangeAt(0) - - if (isString(node) || isNumber(node) || isBoolean(node)) { - node = text(node) - } - - range.deleteContents() - range.insertNode(node) - selection.collapseToEnd() - - return selection -} diff --git a/dom/selection/insert/readme.md b/dom/selection/insert/readme.md deleted file mode 100644 index 60c30d3..0000000 --- a/dom/selection/insert/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/insert - -## Usage - -```js -insert(node) -``` \ No newline at end of file diff --git a/dom/selection/isCollapsed/index.js b/dom/selection/isCollapsed/index.js deleted file mode 100644 index 867d158..0000000 --- a/dom/selection/isCollapsed/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { current } from '../current' - -export function isCollapsed () { - return current().isCollapsed -} diff --git a/dom/selection/isCollapsed/readme.md b/dom/selection/isCollapsed/readme.md deleted file mode 100644 index 6b01eeb..0000000 --- a/dom/selection/isCollapsed/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/isCollapsed - -## Usage - -```js -isCollapsed() -``` \ No newline at end of file diff --git a/dom/selection/next/index.js b/dom/selection/next/index.js deleted file mode 100644 index fd8349a..0000000 --- a/dom/selection/next/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import { indexOf } from '../../../primitive/array/indexOf' -import { parent } from '../../query/parent' -import { start } from '../start' - -export function next (node, targets) { - let key = indexOf(targets, node) - - node = targets[key += 1] - - while (node) { - if (parent(node)) { - return start(node) - } - - node = targets[key += 1] - } -} diff --git a/dom/selection/next/readme.md b/dom/selection/next/readme.md deleted file mode 100644 index b9273f1..0000000 --- a/dom/selection/next/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/next - -## Usage - -```js -next(node, targets) -``` \ No newline at end of file diff --git a/dom/selection/previous/index.js b/dom/selection/previous/index.js deleted file mode 100644 index b5d3b2d..0000000 --- a/dom/selection/previous/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import { indexOf } from '../../../primitive/array/indexOf' -import { parent } from '../../query/parent' -import { end } from '../end' - -export function previous (node, targets) { - let key = indexOf(targets, node) - - node = targets[key -= 1] - - while (node) { - if (parent(node)) { - return end(node) - } - - node = targets[key -= 1] - } -} diff --git a/dom/selection/previous/readme.md b/dom/selection/previous/readme.md deleted file mode 100644 index 7de1f07..0000000 --- a/dom/selection/previous/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/previous - -## Usage - -```js -previous(node, targets) -``` \ No newline at end of file diff --git a/dom/selection/readme.md b/dom/selection/readme.md deleted file mode 100644 index 98dc18c..0000000 --- a/dom/selection/readme.md +++ /dev/null @@ -1,14 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/selection - -* [anchor](./anchor/#reference) -* [current](./current/#reference) -* [end](./end/#reference) -* [ends](./ends/#reference) -* [focus](./focus/#reference) -* [insert](./insert/#reference) -* [isCollapsed](./isCollapsed/#reference) -* [next](./next/#reference) -* [previous](./previous/#reference) -* [select](./select/#reference) -* [start](./start/#reference) -* [starts](./starts/#reference) \ No newline at end of file diff --git a/dom/selection/select/index.js b/dom/selection/select/index.js deleted file mode 100644 index 7e05c59..0000000 --- a/dom/selection/select/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import { document } from '../../node/document' -import { current } from '../current' - -export function select (node, begin, end) { - const range = document().createRange() - const selection = current() - - range.selectNodeContents(node) - - if (Number.isInteger(begin)) { - range.setStart(node, begin) - } - - if (Number.isInteger(end)) { - range.setEnd(node, end) - } - - selection.removeAllRanges() - selection.addRange(range) - - if (!Number.isInteger(begin)) { - selection.collapseToEnd() - } - - if (!Number.isInteger(end)) { - selection.collapseToStart() - } - - return node -} diff --git a/dom/selection/select/readme.md b/dom/selection/select/readme.md deleted file mode 100644 index 1099222..0000000 --- a/dom/selection/select/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/select - -## Usage - -```js -select(node, targets) -``` \ No newline at end of file diff --git a/dom/selection/start/index.js b/dom/selection/start/index.js deleted file mode 100644 index 904ca4e..0000000 --- a/dom/selection/start/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { firstOrSelf } from '../../query/firstOrSelf' -import { select } from '../select' - -export function start (node) { - let first = firstOrSelf(node) - - select(first, 0) - - return first -} diff --git a/dom/selection/start/readme.md b/dom/selection/start/readme.md deleted file mode 100644 index b3a6c98..0000000 --- a/dom/selection/start/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/start - -## Usage - -```js -start(node) -``` \ No newline at end of file diff --git a/dom/selection/starts/index.js b/dom/selection/starts/index.js deleted file mode 100644 index b6b398b..0000000 --- a/dom/selection/starts/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import { contains } from '../../info/contains' -import { firstNode } from '../../query/firstNode' -import { parent } from '../../query/parent' -import { current } from '../current' - -export function starts (node) { - const selection = current() - const offset = selection.anchorOffset - let anchor = selection.anchorNode - - if (offset || !contains(anchor, node)) { - return false - } - - while (anchor) { - if (firstNode(parent(anchor)) !== anchor) { - return false - } - - if (anchor === node || anchor === firstNode(node)) { - return true - } - - anchor = parent(anchor) - } - - return false -} diff --git a/dom/selection/starts/readme.md b/dom/selection/starts/readme.md deleted file mode 100644 index 0cc3498..0000000 --- a/dom/selection/starts/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[selection](../#reference)/starts - -## Usage - -```js -starts(node) -``` \ No newline at end of file diff --git a/dom/tree/after/index.js b/dom/tree/after/index.js deleted file mode 100644 index 3082beb..0000000 --- a/dom/tree/after/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { nextNode } from '../../query/nextNode' -import { parent } from '../../query/parent' -import { before } from '../before' - -export function after (node, refNode) { - return before(node, nextNode(refNode), parent(refNode)) -} diff --git a/dom/tree/after/readme.md b/dom/tree/after/readme.md deleted file mode 100644 index 1a3161f..0000000 --- a/dom/tree/after/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/after - -## Usage - -```js -after(node, refNode) -``` \ No newline at end of file diff --git a/dom/tree/afterAll/index.js b/dom/tree/afterAll/index.js deleted file mode 100644 index 090e023..0000000 --- a/dom/tree/afterAll/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { slice } from '../../../primitive/array/slice' -import { after } from '../after' - -export function afterAll (nodes, refNode) { - const items = slice(nodes, 0) - - if (items.length) { - return - } - - let last = after(items.shift(), refNode) - - forEach(items, function (item) { - last = after(item, last) - }) - - return nodes -} diff --git a/dom/tree/afterAll/readme.md b/dom/tree/afterAll/readme.md deleted file mode 100644 index bd70da0..0000000 --- a/dom/tree/afterAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/afterAll - -## Usage - -```js -afterAll(nodes, refNode) -``` \ No newline at end of file diff --git a/dom/tree/append/index.js b/dom/tree/append/index.js deleted file mode 100644 index 41f4b6d..0000000 --- a/dom/tree/append/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { before } from '../before' - -export function append (node, parent) { - return before(node, null, parent) -} diff --git a/dom/tree/append/readme.md b/dom/tree/append/readme.md deleted file mode 100644 index e6aba06..0000000 --- a/dom/tree/append/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/append - -## Usage - -```js -append(node, parent) -``` \ No newline at end of file diff --git a/dom/tree/appendAll/index.js b/dom/tree/appendAll/index.js deleted file mode 100644 index 6303d9a..0000000 --- a/dom/tree/appendAll/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { slice } from '../../../primitive/array/slice' -import { append } from '../append' - -export function appendAll (nodes, parent) { - forEach(slice(nodes, 0), function (node) { - append(node, parent) - }) - - return nodes -} diff --git a/dom/tree/appendAll/readme.md b/dom/tree/appendAll/readme.md deleted file mode 100644 index f7972e5..0000000 --- a/dom/tree/appendAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/appendAll - -## Usage - -```js -appendAll(nodes, parent) -``` \ No newline at end of file diff --git a/dom/tree/attr/index.js b/dom/tree/attr/index.js deleted file mode 100644 index b39d2ae..0000000 --- a/dom/tree/attr/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import { isBoolean } from '../../../primitive/boolean/isBoolean' -import { isNull } from '../../../primitive/null/isNull' -import { isNumber } from '../../../primitive/number/isNumber' -import { camelToDash } from '../../../primitive/string/camelToDash' -import { isString } from '../../../primitive/string/isString' - -export function attr (element, name, value) { - name = camelToDash(name) - - if (isString(value) || isNumber(value) || isBoolean(value)) { - element.setAttribute(name, value) - - return element - } - - if (isNull(value)) { - element.removeAttribute(name) - - return element - } - - return element.getAttribute(name) -} diff --git a/dom/tree/attr/readme.md b/dom/tree/attr/readme.md deleted file mode 100644 index 7a287cb..0000000 --- a/dom/tree/attr/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/attr - -## Usage - -```js -attr(element, name, value) -``` \ No newline at end of file diff --git a/dom/tree/before/index.js b/dom/tree/before/index.js deleted file mode 100644 index 41ddc42..0000000 --- a/dom/tree/before/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { parent } from '../../query/parent' - -export function before (node, refNode, parentNode) { - if (refNode) { - parent(refNode).insertBefore(node, refNode) - } else { - parentNode.appendChild(node) - } - - return node -} diff --git a/dom/tree/before/readme.md b/dom/tree/before/readme.md deleted file mode 100644 index ce0632e..0000000 --- a/dom/tree/before/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/before - -## Usage - -```js -before(node, refNode, parentNode) -``` \ No newline at end of file diff --git a/dom/tree/beforeAll/index.js b/dom/tree/beforeAll/index.js deleted file mode 100644 index 71c8155..0000000 --- a/dom/tree/beforeAll/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { slice } from '../../../primitive/array/slice' -import { before } from '../before' - -export function beforeAll (nodes, refNode, parent) { - forEach(slice(nodes, 0), function (node) { - before(node, refNode, parent) - }) - - return nodes -} diff --git a/dom/tree/beforeAll/readme.md b/dom/tree/beforeAll/readme.md deleted file mode 100644 index 2d49710..0000000 --- a/dom/tree/beforeAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/beforeAll - -## Usage - -```js -beforeAll(nodes, refNode, parent) -``` \ No newline at end of file diff --git a/dom/tree/clone/index.js b/dom/tree/clone/index.js deleted file mode 100644 index f91dba8..0000000 --- a/dom/tree/clone/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function clone (node, deep) { - return node.cloneNode(deep) -} diff --git a/dom/tree/clone/readme.md b/dom/tree/clone/readme.md deleted file mode 100644 index 0dbf8fc..0000000 --- a/dom/tree/clone/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/clone - -## Usage - -```js -clone(node) -``` \ No newline at end of file diff --git a/dom/tree/data/index.js b/dom/tree/data/index.js deleted file mode 100644 index 15e3dc8..0000000 --- a/dom/tree/data/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import { isNull } from '../../../primitive/null/isNull' -import { isNumber } from '../../../primitive/number/isNumber' -import { dashToCamel } from '../../../primitive/string/dashToCamel' -import { isString } from '../../../primitive/string/isString' - -export function data (element, name, value) { - name = dashToCamel(name) - - if (isString(value) || isNumber(value)) { - element.dataset[name] = value - - return element - } - - if (isNull(value)) { - delete element.dataset[name] - - return element - } - - return element.dataset[name] -} diff --git a/dom/tree/data/readme.md b/dom/tree/data/readme.md deleted file mode 100644 index fb1d175..0000000 --- a/dom/tree/data/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/data - -## Usage - -```js -data(element, name, value) -``` \ No newline at end of file diff --git a/dom/tree/empty/index.js b/dom/tree/empty/index.js deleted file mode 100644 index 205229e..0000000 --- a/dom/tree/empty/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import { isElement } from '../../info/isElement' -import { html } from '../html' -import { text } from '../text' - -export function empty (node) { - if (isElement(node)) { - html(node, '') - } else { - text(node, '') - } - - return node -} diff --git a/dom/tree/empty/readme.md b/dom/tree/empty/readme.md deleted file mode 100644 index bc827f1..0000000 --- a/dom/tree/empty/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/empty - -## Usage - -```js -empty(node) -``` \ No newline at end of file diff --git a/dom/tree/html/index.js b/dom/tree/html/index.js deleted file mode 100644 index 9f22555..0000000 --- a/dom/tree/html/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { isUndefined } from '../../../primitive/undefined/isUndefined' -import { isElement } from '../../info/isElement' -import { elements } from '../../query/elements' -import { sanitize } from '../sanitize' - -export function html (element, data) { - if (isElement(element)) { - if (!isUndefined(data)) { - element.innerHTML = data - forEach(elements(element), sanitize) - - return element - } - - return element.innerHTML - } -} diff --git a/dom/tree/html/readme.md b/dom/tree/html/readme.md deleted file mode 100644 index 86e9f7b..0000000 --- a/dom/tree/html/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/html - -## Usage - -```js -html(element, data) -``` \ No newline at end of file diff --git a/dom/tree/prepend/index.js b/dom/tree/prepend/index.js deleted file mode 100644 index cbb04d5..0000000 --- a/dom/tree/prepend/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { firstNode } from '../../query/firstNode' -import { before } from '../before' - -export function prepend (node, parent) { - return before(node, firstNode(parent), parent) -} diff --git a/dom/tree/prepend/readme.md b/dom/tree/prepend/readme.md deleted file mode 100644 index 6e5ec56..0000000 --- a/dom/tree/prepend/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/prepend - -## Usage - -```js -prepend(node, parent) -``` \ No newline at end of file diff --git a/dom/tree/prependAll/index.js b/dom/tree/prependAll/index.js deleted file mode 100644 index 6154330..0000000 --- a/dom/tree/prependAll/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { slice } from '../../../primitive/array/slice' -import { afterAll } from '../afterAll' -import { prepend } from '../prepend' - -export function prependAll (nodes, parent) { - let items = slice(nodes, 0) - - if (items.length) { - return - } - - afterAll(items, prepend(items.shift(), parent)) - - return nodes -} diff --git a/dom/tree/prependAll/readme.md b/dom/tree/prependAll/readme.md deleted file mode 100644 index ca182d7..0000000 --- a/dom/tree/prependAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/prependAll - -## Usage - -```js -prependAll(nodes, parent) -``` \ No newline at end of file diff --git a/dom/tree/readme.md b/dom/tree/readme.md deleted file mode 100644 index 047cecb..0000000 --- a/dom/tree/readme.md +++ /dev/null @@ -1,24 +0,0 @@ -# [anticore](../../../../#reference)/[dom](../#reference)/tree - -* [after](./after/#reference) -* [afterAll](./afterAll/#reference) -* [append](./append/#reference) -* [appendAll](./appendAll/#reference) -* [before](./before/#reference) -* [beforeAll](./beforeAll/#reference) -* [style](./style/#reference) -* [clone](./clone/#reference) -* [data](./data/#reference) -* [empty](./empty/#reference) -* [html](./html/#reference) -* [prepend](./prepend/#reference) -* [prependAll](./prependAll/#reference) -* [remove](./remove/#reference) -* [removeAll](./removeAll/#reference) -* [replace](./replace/#reference) -* [sanitize](./sanitize/#reference) -* [text](./text/#reference) -* [update](./update/#reference) -* [updateAll](./updateAll/#reference) -* [wrap](./wrap/#reference) -* [wrapAll](./wrapAll/#reference) \ No newline at end of file diff --git a/dom/tree/remove/index.js b/dom/tree/remove/index.js deleted file mode 100644 index 16f674a..0000000 --- a/dom/tree/remove/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { parent } from '../../query/parent' - -export function remove (node) { - if (parent(node)) { - parent(node).removeChild(node) - } - - return node -} diff --git a/dom/tree/remove/readme.md b/dom/tree/remove/readme.md deleted file mode 100644 index fe01500..0000000 --- a/dom/tree/remove/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/remove - -## Usage - -```js -remove(node) -``` \ No newline at end of file diff --git a/dom/tree/removeAll/index.js b/dom/tree/removeAll/index.js deleted file mode 100644 index f956674..0000000 --- a/dom/tree/removeAll/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { slice } from '../../../primitive/array/slice' -import { remove } from '../remove' - -export function removeAll (nodes) { - forEach(slice(nodes, 0), remove) - - return nodes -} diff --git a/dom/tree/removeAll/readme.md b/dom/tree/removeAll/readme.md deleted file mode 100644 index a7f8c2b..0000000 --- a/dom/tree/removeAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/removeAll - -## Usage - -```js -removeAll(nodes) -``` \ No newline at end of file diff --git a/dom/tree/replace/index.js b/dom/tree/replace/index.js deleted file mode 100644 index 9cfa444..0000000 --- a/dom/tree/replace/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { parent } from '../../query/parent' - -export function replace (node, refNode) { - parent(refNode).replaceChild(node, refNode) - - return node -} diff --git a/dom/tree/replace/readme.md b/dom/tree/replace/readme.md deleted file mode 100644 index eb4419a..0000000 --- a/dom/tree/replace/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/replace - -## Usage - -```js -replace(node, refNode) -``` \ No newline at end of file diff --git a/dom/tree/sanitize/index.js b/dom/tree/sanitize/index.js deleted file mode 100644 index 784fe25..0000000 --- a/dom/tree/sanitize/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { toLowerCase } from '../../../primitive/string/toLowerCase' -import { isElement } from '../../info/isElement' -import { elements } from '../../query/elements' - -export function sanitize (node) { - if (isElement(node)) { - if (node.hasAttributes()) { - forEach(node.attributes, unlistener) - } - - forEach(elements(node), sanitize) - } - - return node -} - -function unlistener (attribute) { - if (toLowerCase(attribute.name.substr(0, 2)) === 'on') { - attribute.ownerElement.removeAttribute(attribute.name) - } -} diff --git a/dom/tree/sanitize/readme.md b/dom/tree/sanitize/readme.md deleted file mode 100644 index 3381600..0000000 --- a/dom/tree/sanitize/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/sanitize - -## Usage - -```js -sanitize(element) -``` \ No newline at end of file diff --git a/dom/tree/style/index.js b/dom/tree/style/index.js deleted file mode 100644 index 2d18bc0..0000000 --- a/dom/tree/style/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import { global } from '../../../global' -import { demethodize } from '../../../primitive/function/demethodize' -import { isNull } from '../../../primitive/null/isNull' -import { isNumber } from '../../../primitive/number/isNumber' -import { camelToDash } from '../../../primitive/string/camelToDash' -import { dashToCamel } from '../../../primitive/string/dashToCamel' -import { isString } from '../../../primitive/string/isString' - -const getStyle = demethodize(global().getComputedStyle) - -export function style (element, name, value) { - if (isString(value) || isNumber(value) || isNull(value)) { - element.style[dashToCamel(name)] = value - - return element - } - - return getStyle(element)[camelToDash(name)] -} diff --git a/dom/tree/style/readme.md b/dom/tree/style/readme.md deleted file mode 100644 index f7850ee..0000000 --- a/dom/tree/style/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/style - -## Usage - -```js -style(element, name, value) -``` \ No newline at end of file diff --git a/dom/tree/text/index.js b/dom/tree/text/index.js deleted file mode 100644 index 6a6d81f..0000000 --- a/dom/tree/text/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { isUndefined } from '../../../primitive/undefined/isUndefined' -import { isElement } from '../../info/isElement' - -export function text (node, data) { - if (isElement(node)) { - if (!isUndefined(data)) { - node.textContent = data - } - - return node.textContent - } - - if (!isUndefined(data)) { - node.nodeValue = data - } - - return node.nodeValue -} diff --git a/dom/tree/text/readme.md b/dom/tree/text/readme.md deleted file mode 100644 index 9743159..0000000 --- a/dom/tree/text/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/text - -## Usage - -```js -text(node, data) -``` \ No newline at end of file diff --git a/dom/tree/update/index.js b/dom/tree/update/index.js deleted file mode 100644 index c688466..0000000 --- a/dom/tree/update/index.js +++ /dev/null @@ -1,44 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { isObject } from '../../../primitive/object/isObject' -import { keys } from '../../../primitive/object/keys' -import { toLowerCase } from '../../../primitive/string/toLowerCase' -import { on } from '../../emitter/on' -import { after } from '../after' -import { append } from '../append' -import { attr } from '../attr' -import { before } from '../before' -import { data } from '../data' -import { style } from '../style' -import { text } from '../text' - -export function update (element, config) { - if (isObject(config)) { - forEach(keys(config), function (name) { - let value = config[name] - - if (name.substr(0, 2) === 'on') { - on(toLowerCase(name.substr(2)), element, value) - } else if (name === 'style' && isObject(value)) { - forEach(keys(value), function (name) { - style(element, name, value[name]) - }) - } else if (name === 'dataset' && isObject(value)) { - forEach(keys(value), function (name) { - data(element, name, value[name]) - }) - } else if (name === 'text') { - text(element, value) - } else if (name === 'parent') { - append(element, value) - } else if (name === 'next') { - before(element, value) - } else if (name === 'prev') { - after(element, value) - } else { - attr(element, name, value) - } - }) - } - - return element -} diff --git a/dom/tree/update/readme.md b/dom/tree/update/readme.md deleted file mode 100644 index 385f954..0000000 --- a/dom/tree/update/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/update - -## Usage - -```js -update(element, config) -``` - -## Valid config properties - -* `text`: text content of the element -* `parent`: parent node, useful to modify the node and to append it at once -* `next`: next node, useful to modify the node and to insert it before the next node at once -* `prev`: previous node, useful to modify the node and to insert it after the previous node at once -* `dataset`: object to declare `data-*` attributes -* `style`: object to declare the style properties -* `*`: declare any attribute... or declare a listener if the property is prefixed by `on`, like `onClick` - -## Example -```js -update(element, { - text: 'this is the text content', - next: one('main'), - dataset: { - id: 123 - }, - style: { - color: 'red' - }, - title: 'this is the title attribute content', - onClick: function (event) { - console.log('click on', event.target); - } -}) -``` diff --git a/dom/tree/updateAll/index.js b/dom/tree/updateAll/index.js deleted file mode 100644 index 031bc2a..0000000 --- a/dom/tree/updateAll/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { update } from '../update' - -export function updateAll (elements, config) { - forEach(elements, function (element) { - update(element, config) - }) - - return elements -} diff --git a/dom/tree/updateAll/readme.md b/dom/tree/updateAll/readme.md deleted file mode 100644 index 79be281..0000000 --- a/dom/tree/updateAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/updateAll - -## Usage - -```js -updateAll(nodes, config) -``` \ No newline at end of file diff --git a/dom/tree/wrap/index.js b/dom/tree/wrap/index.js deleted file mode 100644 index 0a171ef..0000000 --- a/dom/tree/wrap/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { before } from '../before' - -export function wrap (node, wrapper) { - before(node, null, wrapper) - - return wrapper -} diff --git a/dom/tree/wrap/readme.md b/dom/tree/wrap/readme.md deleted file mode 100644 index 9a2d6a3..0000000 --- a/dom/tree/wrap/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/wrap - -## Usage - -```js -wrap(node, wrapper) -``` \ No newline at end of file diff --git a/dom/tree/wrapAll/index.js b/dom/tree/wrapAll/index.js deleted file mode 100644 index 1b51235..0000000 --- a/dom/tree/wrapAll/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { forEach } from '../../../primitive/array/forEach' -import { slice } from '../../../primitive/array/slice' -import { wrap } from '../wrap' - -export function wrapAll (nodes, wrapper) { - forEach(slice(nodes, 0), function (node) { - wrap(node, wrapper) - }) - - return wrapper -} diff --git a/dom/tree/wrapAll/readme.md b/dom/tree/wrapAll/readme.md deleted file mode 100644 index 630709f..0000000 --- a/dom/tree/wrapAll/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[dom](../../#reference)/[tree](../#reference)/wrapAll - -## Usage - -```js -wrapAll(nodes, wrapper) -``` \ No newline at end of file diff --git a/global/index.js b/global/index.js deleted file mode 100644 index ff5cba2..0000000 --- a/global/index.js +++ /dev/null @@ -1 +0,0 @@ -export const global = (x => x).constructor('return this').bind(null) diff --git a/global/readme.md b/global/readme.md deleted file mode 100644 index 8774af7..0000000 --- a/global/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../#reference)/global - -## Usage - -```js -global() -``` \ No newline at end of file diff --git a/index.js b/index.js index fdb3f04..5f10df9 100644 --- a/index.js +++ b/index.js @@ -1,365 +1,150 @@ -/* - Copyright MIT 2017 Lcf.vs - https://github.com/Lcfvs/anticore - */ - -import { getTarget } from './dom/emitter/getTarget' -import { onClick } from './dom/emitter/on/onClick' -import { onError } from './dom/emitter/on/onError' -import { onMessage } from './dom/emitter/on/onMessage' -import { onSubmit } from './dom/emitter/on/onSubmit' -import { prevent } from './dom/emitter/prevent' -import { nodeName } from './dom/info/nodeName' -import { rects } from './dom/info/rects' -import { document } from './dom/node/document' -import { all } from './dom/query/all' -import { one } from './dom/query/one' -import { parent } from './dom/query/parent' -import { remove } from './dom/tree/remove' -import { global } from './global' -import { forEach } from './primitive/array/forEach' -import { indexOf } from './primitive/array/indexOf' -import { create } from './primitive/object/create' -import { keys } from './primitive/object/keys' -import { toDOM } from './primitive/string/toDOM' -import { request } from './request' -import { queue } from './request/.queue' - -export const anticore = create() - -const window = global() -const console = window.console -const encodeURIComponent = window.encodeURIComponent -const URL = window.URL -const FormData = window.FormData -const EventSource = window.EventSource -const registry = create() -const types = ['html', 'svg', 'xml'] -const selector = 'input[type=submit]:focus,' + - 'button[type=submit]:focus,' + - 'button:not([type]):focus,' + - 'input[type=submit]:hover,' + - 'button[type=submit]:hover,' + - 'button:not([type]):hover,' + - 'input[name]:not([type=file]):not([type=reset]):not([type=submit]):not([type=checkbox]):not([type=radio]):not(:disabled),' + - 'input[name][type=checkbox]:checked:not(:disabled),' + - 'input[name][type=radio]:checked:not(:disabled),' + - 'textarea[name]:not(:disabled),' + - 'select[name]:not(:disabled) [selected=selected]' - -anticore.fetchers = create() -anticore.request = request - -function noop () {} - -/** - * Builds a request based on an anchor - * @param {HTMLAnchorElement} a - * @returns {Object} request - */ -anticore.fetchers.a = function (a) { - return request(a.href, 'get', null, a) -} - -/** - * Builds a request based on a form - * @param {HTMLFormElement} form - * @returns {Object} request - */ -anticore.fetchers.form = function (form) { - const action = new URL(form.action || form.ownerDocument.location.href) - const method = form.method - let data - - if (method === 'post') { - data = new FormData(form) - } else { - action.search += indexOf(action.search, '?') > -1 ? '' : '?' - forEach(all(selector, form), stringify, action) +import globalFetch from 'anticore-core/apis/fetch/index' +import clone from 'anticore-core/apis/Request/clone' +import bind from 'anticore-core/Function/bind' +import curry from 'anticore-core/Function/curry' +import promise from 'anticore-core/Function/promise' +import forEach from 'anticore-core/Array/forEach' +import map from 'anticore-core/Array/map' +import empty from 'anticore-core/Object/empty' +import prevent from 'anticore-dom/emitter/prevent' +import document from 'anticore-dom/node/document' +import all from 'anticore-dom/query/all' +import one from 'anticore-dom/query/one' +import fromString from 'anticore-dom/tree/fromString' +import error from 'anticore-utils/console/error' +import log from 'anticore-utils/console/log' +import noop from 'anticore-utils/noop' +import pool from 'anticore-utils/pool' + +const fetching = 'fetching' +const contracts = [] +const requests = pool() +const selector = ` +a:focus, +[type=submit]:focus, +button:not([type]):focus, +a:hover, +[type=submit]:hover, +button:not([type]):hover +[type=submit], +button:not([type])` +const defaults = empty({ + interval: 1000, + retries: Infinity +}) + +function attempt (current = requests.current() || requests.next()) { + if (current && !current.pending) { + current.pending = true + + globalFetch(clone(current.request)) + .then(parse) + .then(fromString) + .then(triggerContracts) + .then(current.notify) + .then(requests.next) + .then(attempt) + .catch(retry) } - - return request(action.toString(), method, data, form) -} - -/** - * Builds a request based on an element - * (form or anchor, for more, extend anticore fetchers) - * @param {HTMLElement} element - * @returns {Object} request - */ -anticore.fetcher = function (element) { - return anticore.fetchers[nodeName(element)](element) } -/** - * Populates the request response - * @param {Object} request - * @returns {Object} anticore - */ -anticore.trigger = function (request) { - if (anticore.onTimeout(request)) { - return anticore - } - - populate(request.response.result, true, request.url).then(request.resolve) - .then(function () { - return request - }) +function parse (response) { + requests.current().response = response - return anticore + return response.text() } -/** - * Adds a listener, based on a querySelectorAll - * @param {String} selector - * @param {Function} middleware - * @returns {Object} anticore - */ -anticore.on = function (selector, middleware) { - registry[selector] = registry[selector] || [] - - if (indexOf(registry[selector], middleware) < 0) { - anticore.debug.onMiddleware(selector, middleware) - registry[selector].push(middleware) - } +function triggerContracts (fragment) { + const url = requests.current().response.url - return anticore + return promise(dispatch, matchAll(fragment), url) } -/** - * Handles any requests timeout & retry if any - * @param {Object} request - * @returns {Boolean} - */ -anticore.onTimeout = function (request) { - if (request.response.status === 408) { - request.retry() - - return true - } - - return false -} - -/** - * Launches the selectors tests to find the related listeners, - * takes the scoped document if not passed as argument - * @param {Document|HTMLElement|DocumentFragment} [container=global.document) - * @param {boolean} [loaded] - * @param {string} [url] - * @returns {Object} anticore - */ -anticore.populate = function (container, loaded, url) { - return populate(container || document(), loaded, url) +function notify (target, method = 'remove') { + target.classList[method](fetching) } -/** - * Builds a request - * @param {String} url - * @param {String} method (get or post) - * @param {Object} [body] (the post request body) - * @param {Element} [target] (the event target) - * @return {Object} - */ -anticore.request = function (url, method, body, target) { - const instance = request(url, method, body, target) +function retry (error) { + const current = requests.current() - instance.fetchRequest = fetchRequest + debug.onError(error) - return instance -} + if (!current.retries) { + requests.next() -/** - * Default fetcher listener - * @param {Event} event - */ -anticore.fetchFromEvent = function (event) { - if (event.defaultPrevented || event.cancelBubble) { - return false + return attempt() } - const target = getTarget(event) - const request = anticore.fetcher(target) - - request.target = target - request.originalTarget = one(selector, target.ownerDocument) - request.fetchRequest = fetchRequest - prevent(event) - - request.fetch(anticore.trigger)['catch'](anticore.onError) - - return false -} - -/** - * Listens an event source - * turns the contents to DOM, except if a reviver is provided - * @param {string} url - * @param {object} config - * @param {function} reviver - * @returns {EventSource} source - */ -anticore.sse = function (url, config, reviver) { - const source = new EventSource(url, config) - - onMessage(source, function (event) { - populate((reviver || toDOM)(event.data), true, url) - }) - - onError(source, anticore.onError) - - return source + current.pending = false + current.retries -= 1 + log(`Retrying in ${current.interval / 1000}s`) + setTimeout(attempt, current.interval) } -anticore.onError = console.error.bind(console) - -/** - * Intercepts: - * a[href^="http"]:not([download]):not([target]), - * a[href^="http"][target=_self]:not([download]), - * a[href^="."]:not([download]):not([target]), - * a[href^="."][target=_self]:not([download]), - * a[href^="/"]:not([download]):not([target]), - * a[href^="/"][target=_self]:not([download]), - * form:not([target]), - * form[target=_self] - * @returns {Object} anticore - */ -anticore.defaults = function () { - anticore.on( - 'a[href^="http"]:not([download]):not([target]),a[href^="http"][target=_self]:not([download]),' + - 'a[href^="."]:not([download]):not([target]),a[href^="."][target=_self]:not([download]),' + - 'a[href^="/"]:not([download]):not([target]),a[href^="/"][target=_self]:not([download])', - function (element, next) { - onClick(element, anticore.fetchFromEvent) - next() - }) - - anticore.on('form:not([target]),form[target=_self]', - function (element, next) { - onSubmit(element, cleanAndFetch) - next() - }) +function dispatch (matches, url, callback = noop) { + const match = matches.next() + const listener = match.value - return anticore -} - -function stringify (item) { - if (!item.offsetWidth && !item.offsetHeight && !rects(item).length) { - return + if (match.done) { + return callback() } - this.search += '&' + encodeURIComponent((nodeName(item) === 'option' - ? parent(item) - : item).name) + '=' + encodeURIComponent(item.value).replace(/%20/g, '+') + listener(bind(next, empty(), matches, url, callback), url) } -function notify (response) { - const request = queue[0].request - const target = request.originalTarget || request.target - - if (target) { - target.classList.toggle('fetching') +function next (matches, url, callback) { + if (!this.called) { + this.called = true + dispatch(matches, url, callback) } - - return response } -function fetchRequest () { - const item = queue[0] - - if (queue[1]) { - return - } - - notify() +function matchAll (fragment) { + const elements = [] - const url = item.request.url - const fetch = item.request.negotiate(url) + forEach(map(contracts, match, fragment), flat, elements) - return fetch(url, item.request.options).then(onResponse).then(notify).then( - onFragment).then(item.trigger || item.request.resolve).then( - queue.next)['catch'](item.reject) + return elements.values() } -function onResponse (response) { - const item = queue[0] - const type = ((response.headers.get('content-type') || - 'application/octet-stream').match(/json|html|svg|xml|text(?=\/plain)/) || - ['blob'])[0] - - item.type = type - item.request.response = response - - return response[indexOf(types, type) > -1 ? 'text' : type]() +function match (contract) { + return map([...all(contract.selector, this)], prepare, contract) } -function cleanAndFetch (event) { - forEach(all('.error', getTarget(event)), remove) - anticore.fetchFromEvent(event) +function prepare (element) { + return curry(this.listener, element) } -function onFragment (data) { - let item = queue[0] - - if (indexOf(types, item.type) > -1) { - item.request.response.result = toDOM(data) - } else { - item.request.response.result = data - } - - return item.request +function flat (values) { + this.push(...values) } -function nextRecord (resolve) { - const record = this.shift() - - if (!record) { - return resolve && resolve() +export function fetch (event, target, request, options) { + if (event.defaultPrevented || event.cancelBubble) { + return } - record[0](record[1], this.next, this.loaded, this.url) -} - -function onSelector (selector) { - const queue = this - const nodes = all(selector, queue.container) - - queue.selector = selector - forEach(nodes, onElement, queue) -} - -function onElement (element) { - const queue = this + const entry = empty(defaults, options, { + request, + notify: curry(notify, one(selector, target.parentNode)) + }) - queue.element = element - forEach(registry[queue.selector], onListener, queue) + prevent(event) + requests.push(entry) + entry.notify('add') + attempt() } -function onListener (listener) { - const queue = this - const element = queue.element - const loaded = queue.loaded || false - const selector = queue.selector - const url = queue.url - - anticore.debug.onMatch(selector, listener, element, loaded, url) - queue.push([listener, element, loaded, url]) +export function on (selector, listener) { + contracts.push(empty({selector, listener})) } -function populate (container, loaded, url) { - return new Promise(function (resolve) { - const queue = [] - - queue.container = container - queue.loaded = loaded - queue.url = url - forEach(keys(registry), onSelector, queue) - queue.next = nextRecord.bind(queue, resolve) - queue.next() - }) +export function trigger (node, url) { + dispatch(matchAll(node || document()), url) } -anticore.debug = create() -anticore.debug.onMiddleware = noop -anticore.debug.onMatch = noop +export const debug = empty({ + onError: error, + onMiddleware: noop, + onMatch: noop +}) diff --git a/middleware/main/mono/index.js b/middleware/main/mono/index.js deleted file mode 100644 index 88bdb10..0000000 --- a/middleware/main/mono/index.js +++ /dev/null @@ -1,85 +0,0 @@ -import {anticore} from '../../../index' -import {global} from '../../../global' -import {all} from '../../../dom/query/all' -import {closest} from '../../../dom/query/closest' -import {one} from '../../../dom/query/one' -import {replace} from '../../../dom/tree/replace' -import {text} from '../../../dom/tree/text' -import {every} from '../../../primitive/array/every' -import {curry} from '../../../primitive/function/curry' -import {create} from '../../../primitive/object/create' - -const window = global() -const history = create() -history.entries = create() - -function cleanHref (href) { - return href.toString().split('#')[0] -} - -function getTitle (element) { - return text(one('h1', element)).trim() -} - -function updateTitle (element) { - const title = history.branding.replace('$1', getTitle(element)) - - window.document.title = title - - return title -} - -function listen () { - const main = one('main') - - register(main, cleanHref(window.location.href)) - window.addEventListener('popstate', onPopState) - history.branding = window.document.title.trim() - .replace(getTitle(main), '$1') -} - -function onPopState (event) { - const registered = history.entries[cleanHref(event.target.location.href)] - const current = one('main') - - if (registered && registered !== current) { - updateTitle(registered) - replace(registered, current) - } -} - -function register (element, url) { - if (url) { - history.entries[url] = element - } -} - -function tagCurrent (url, current, candidate) { - if (cleanHref(candidate.href) === url) { - current.classList.remove('current') - candidate.classList.add('current') - - return false - } - - return true -} - -anticore.on('main', function (element, next, loaded, url) { - if (loaded && one('h1', element)) { - register(element, url) - window.history.pushState(null, updateTitle(element), url) - replace(element, one('main')) - } - - const current = url && one('body nav a.current') - const anchors = current && all('a', closest('ol, ul', current)) - - if (anchors) { - every(anchors, curry(tagCurrent, cleanHref(url), current)) - } - - next() -}) - -listen() diff --git a/middleware/main/mono/readme.md b/middleware/main/mono/readme.md deleted file mode 100644 index 1270979..0000000 --- a/middleware/main/mono/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[middleware](../../#reference)/[main](../#reference)/mono - -## Usage - -```js -import 'anticore/middleware/main/mono' -``` \ No newline at end of file diff --git a/middleware/main/readme.md b/middleware/main/readme.md deleted file mode 100644 index 55d2ac7..0000000 --- a/middleware/main/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[middleware](../#reference)/main - -* [mono](./mono/#reference) \ No newline at end of file diff --git a/middleware/readme.md b/middleware/readme.md deleted file mode 100644 index c877b4f..0000000 --- a/middleware/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# [anticore](../../../#reference)/middleware - -* [main](./main/#reference) -* [time](./time/#reference) \ No newline at end of file diff --git a/middleware/time/localizer/index.js b/middleware/time/localizer/index.js deleted file mode 100644 index b5377db..0000000 --- a/middleware/time/localizer/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import { anticore } from '../../../index' - -const localizer = { - locale: { - pattern: /^[a-z]{2}-[A-Z]{2}$/, - parse: function (element) { - return (element.lang || '').match(this.pattern) || - (element.parentNode && this.parse(element.parentNode)) || - navigator.language.match(this.pattern) || - undefined - } - }, - patterns: { - toLocaleString: /^\d+-\d+-\d+T\d+:\d+:\d+/, - toLocaleDateString: /^\d+-\d+-\d$/, - toLocaleTimeString: /^\d+:\d+:\d+/ - }, - format: function (element) { - const time = element.getAttribute('datetime') - const date = new Date(time) - const locale = this.locale.parse(element) - const methods = Object.keys(this.patterns) - - do { - let method = methods.shift() - - if (time.match(this.patterns[method])) { - element.innerHTML = date[method](locale) - - return - } - } while (methods.length) - } -} - -anticore.on('time:not([datetime=""])', function (element, next) { - localizer.format(element) - next() -}) diff --git a/middleware/time/localizer/readme.md b/middleware/time/localizer/readme.md deleted file mode 100644 index 4cdfb20..0000000 --- a/middleware/time/localizer/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[middleware](../../#reference)/[time](../#reference)/localizer - -## Usage - -```js -import 'anticore/middleware/time/localizer' -``` \ No newline at end of file diff --git a/middleware/time/readme.md b/middleware/time/readme.md deleted file mode 100644 index 1833643..0000000 --- a/middleware/time/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[middleware](../#reference)/time - -* [localizer](./localizer/#reference) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d3c1802..8eef1a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,29 @@ { "name": "anticore", - "version": "2.25.0", - "lockfileVersion": 1 + "version": "3.0.6", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "anticore-core": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/anticore-core/-/anticore-core-1.0.0.tgz", + "integrity": "sha512-63GPpTQ5wjpbOunx2l1MO2SkhZIO9zKnRAWX/aA52/58W5jEaR5F3I7FIcStKIljTD7AaB4J2PUndXUiddacBA==" + }, + "anticore-dom": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/anticore-dom/-/anticore-dom-1.0.1.tgz", + "integrity": "sha512-1ilinhuA634dR3WNLAcGdz5MiEX93YYUPeb7aQOYzks5H+z4SgliMOynfBjJ/OuY+pM3UKkhmX1Utx+6T5o8JQ==", + "requires": { + "anticore-core": "1.0.0" + } + }, + "anticore-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/anticore-utils/-/anticore-utils-1.0.0.tgz", + "integrity": "sha512-ydlKFKRn708O6Im6vD+LK+K02JLJQ60NsTUj1DDNl3iRyuLso8Mkexq6v1CXivRvzSsVG5ZzUyIyZe6BxaSKvg==", + "requires": { + "anticore-core": "1.0.0" + } + } + } } diff --git a/package.json b/package.json index 9440332..0ddd174 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anticore", - "version": "2.25.0", + "version": "3.0.6", "description": "A generic living DOM library to simplify your client code, like with its easiest middleware manager for AJAX requests.", "main": "index.js", "module": "index.js", @@ -21,6 +21,10 @@ "url": "https://github.com/Lcfvs/anticore/issues" }, "homepage": "https://github.com/Lcfvs/anticore#readme", - "dependencies": {}, + "dependencies": { + "anticore-core": "^1.0.0", + "anticore-dom": "^1.0.1", + "anticore-utils": "^1.0.0" + }, "devDependencies": {} } diff --git a/primitive/array/every/index.js b/primitive/array/every/index.js deleted file mode 100644 index 8dc781f..0000000 --- a/primitive/array/every/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const every = demethodize(Array.prototype.every) diff --git a/primitive/array/every/readme.md b/primitive/array/every/readme.md deleted file mode 100644 index f0ff726..0000000 --- a/primitive/array/every/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/every - -## Usage - -```js -every(values, callback, thisArg) -``` \ No newline at end of file diff --git a/primitive/array/filter/index.js b/primitive/array/filter/index.js deleted file mode 100644 index e26aa73..0000000 --- a/primitive/array/filter/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const filter = demethodize(Array.prototype.filter) diff --git a/primitive/array/filter/readme.md b/primitive/array/filter/readme.md deleted file mode 100644 index 5dfbc42..0000000 --- a/primitive/array/filter/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/filter - -## Usage - -```js -filter(values, callback, thisArg) -``` \ No newline at end of file diff --git a/primitive/array/forEach/index.js b/primitive/array/forEach/index.js deleted file mode 100644 index ab60380..0000000 --- a/primitive/array/forEach/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const forEach = demethodize(Array.prototype.forEach) diff --git a/primitive/array/forEach/readme.md b/primitive/array/forEach/readme.md deleted file mode 100644 index 0fb5fd1..0000000 --- a/primitive/array/forEach/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/forEach - -## Usage - -```js -forEach(values, callback, thisArg) -``` \ No newline at end of file diff --git a/primitive/array/grep/index.js b/primitive/array/grep/index.js deleted file mode 100644 index 77d107e..0000000 --- a/primitive/array/grep/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { filter } from '../filter' -import { reverse } from '../reverse' - -export function grep (values, callback, invert, thisArg) { - return filter(invert ? reverse(values) : values, callback, thisArg) -} diff --git a/primitive/array/grep/readme.md b/primitive/array/grep/readme.md deleted file mode 100644 index 3aeb3ff..0000000 --- a/primitive/array/grep/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/grep - -## Usage - -```js -grep(values, callback, invert, thisArg) -``` \ No newline at end of file diff --git a/primitive/array/indexOf/index.js b/primitive/array/indexOf/index.js deleted file mode 100644 index 9453cc5..0000000 --- a/primitive/array/indexOf/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const indexOf = demethodize(Array.prototype.indexOf) diff --git a/primitive/array/indexOf/readme.md b/primitive/array/indexOf/readme.md deleted file mode 100644 index 028c8e2..0000000 --- a/primitive/array/indexOf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/indexOf - -## Usage - -```js -indexOf(values, value) -``` \ No newline at end of file diff --git a/primitive/array/isArray/index.js b/primitive/array/isArray/index.js deleted file mode 100644 index cc6a2c9..0000000 --- a/primitive/array/isArray/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { global } from '../../../global' -import { isInstanceOf } from '../../object/isInstanceOf' - -const window = global() -const Array = window.Array - -export function isArray (value) { - return isInstanceOf(Array, value) -} diff --git a/primitive/array/isArray/readme.md b/primitive/array/isArray/readme.md deleted file mode 100644 index 1b826eb..0000000 --- a/primitive/array/isArray/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[function](../#reference)/isArray - -## Usage - -```js -isArray(value) -``` \ No newline at end of file diff --git a/primitive/array/map/index.js b/primitive/array/map/index.js deleted file mode 100644 index ff1b794..0000000 --- a/primitive/array/map/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const map = demethodize(Array.prototype.map) diff --git a/primitive/array/map/readme.md b/primitive/array/map/readme.md deleted file mode 100644 index 96c8c06..0000000 --- a/primitive/array/map/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/map - -## Usage - -```js -map(values, callback, thisArg) -``` \ No newline at end of file diff --git a/primitive/array/readme.md b/primitive/array/readme.md deleted file mode 100644 index 4ea2d1e..0000000 --- a/primitive/array/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/array - -* [every](./every/#reference) -* [filter](./filter/#reference) -* [forEach](./forEach/#reference) -* [grep](./grep/#reference) -* [indexOf](./indexOf/#reference) -* [isArray](./isArray/#reference) -* [map](./map/#reference) -* [reverse](./reverse/#reference) -* [slice](./slice/#reference) -* [slot](./slot/#reference) \ No newline at end of file diff --git a/primitive/array/reverse/index.js b/primitive/array/reverse/index.js deleted file mode 100644 index e5dd2c9..0000000 --- a/primitive/array/reverse/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import { slice } from '../slice' - -export function reverse (values) { - values = slice(values) - values.reverse() - - return values -} diff --git a/primitive/array/reverse/readme.md b/primitive/array/reverse/readme.md deleted file mode 100644 index 7027d16..0000000 --- a/primitive/array/reverse/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/reverse - -## Usage - -```js -reverse(values) -``` \ No newline at end of file diff --git a/primitive/array/slice/index.js b/primitive/array/slice/index.js deleted file mode 100644 index a9dbfba..0000000 --- a/primitive/array/slice/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const slice = demethodize(Array.prototype.slice) diff --git a/primitive/array/slice/readme.md b/primitive/array/slice/readme.md deleted file mode 100644 index d1272df..0000000 --- a/primitive/array/slice/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/slice - -## Usage - -```js -slice(values, begin, end) -``` \ No newline at end of file diff --git a/primitive/array/slot/index.js b/primitive/array/slot/index.js deleted file mode 100644 index 4f348d3..0000000 --- a/primitive/array/slot/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -const apply = demethodize(Array.apply, Array, null) - -export function slot (length) { - return apply({ - length - }) -} diff --git a/primitive/array/slot/readme.md b/primitive/array/slot/readme.md deleted file mode 100644 index 352d9ce..0000000 --- a/primitive/array/slot/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[array](../#reference)/slot - -## Usage - -```js -slot(length) -``` \ No newline at end of file diff --git a/primitive/boolean/isBoolean/index.js b/primitive/boolean/isBoolean/index.js deleted file mode 100644 index 329a63f..0000000 --- a/primitive/boolean/isBoolean/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getPrimitiveOf } from '../../object/getPrimitiveOf' -import { getTypeOf } from '../../object/getTypeOf' - -const type = 'boolean' - -export function isBoolean (value) { - return getTypeOf(value) === type || - getPrimitiveOf(value) === type -} diff --git a/primitive/boolean/isBoolean/readme.md b/primitive/boolean/isBoolean/readme.md deleted file mode 100644 index 258c715..0000000 --- a/primitive/boolean/isBoolean/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[number](../#reference)/isBoolean - -## Usage - -```js -isBoolean(value) -``` \ No newline at end of file diff --git a/primitive/boolean/readme.md b/primitive/boolean/readme.md deleted file mode 100644 index 2eb70ca..0000000 --- a/primitive/boolean/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/boolean - -* [isNumber](isBoolean/#reference) \ No newline at end of file diff --git a/primitive/function/curry/index.js b/primitive/function/curry/index.js deleted file mode 100644 index 2fd2cf8..0000000 --- a/primitive/function/curry/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function curry (fn, ...args) { - return fn.bind(this, ...args) -} diff --git a/primitive/function/curry/readme.md b/primitive/function/curry/readme.md deleted file mode 100644 index 313507a..0000000 --- a/primitive/function/curry/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[function](../#reference)/curry - -## Usage - -```js -curry(fn, ...args) -``` \ No newline at end of file diff --git a/primitive/function/demethodize/index.js b/primitive/function/demethodize/index.js deleted file mode 100644 index 245cae7..0000000 --- a/primitive/function/demethodize/index.js +++ /dev/null @@ -1 +0,0 @@ -export const demethodize = Function.bind.bind(Function.call) diff --git a/primitive/function/demethodize/readme.md b/primitive/function/demethodize/readme.md deleted file mode 100644 index cd5fd64..0000000 --- a/primitive/function/demethodize/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[function](../#reference)/demethodize - -## Usage - -```js -demethodize(method, thisArg, ...args) -``` \ No newline at end of file diff --git a/primitive/function/isFunction/index.js b/primitive/function/isFunction/index.js deleted file mode 100644 index 5ce4de8..0000000 --- a/primitive/function/isFunction/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { getTypeOf } from '../../object/getTypeOf' - -const type = 'function' - -export function isFunction (value) { - return getTypeOf(value) === type -} diff --git a/primitive/function/isFunction/readme.md b/primitive/function/isFunction/readme.md deleted file mode 100644 index ba72a8e..0000000 --- a/primitive/function/isFunction/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[function](../#reference)/isFunction - -## Usage - -```js -isFunction(fn) -``` \ No newline at end of file diff --git a/primitive/function/promise/index.js b/primitive/function/promise/index.js deleted file mode 100644 index 8c13068..0000000 --- a/primitive/function/promise/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import { curry } from '../curry' -import { demethodize } from '../demethodize' - -const demethodizedCurry = demethodize(curry) - -export function promise (fn, ...args) { - return new Promise(demethodizedCurry(this, fn, ...args)) -} diff --git a/primitive/function/promise/readme.md b/primitive/function/promise/readme.md deleted file mode 100644 index d8b0fbb..0000000 --- a/primitive/function/promise/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[function](../#reference)/promise - -## Usage - -```js -promise(fn, ...args) -``` \ No newline at end of file diff --git a/primitive/function/readme.md b/primitive/function/readme.md deleted file mode 100644 index e566a55..0000000 --- a/primitive/function/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/function - -* [curry](./curry/#reference) -* [demethodize](./demethodize/#reference) -* [isFunction](./isFunction/#reference) -* [promise](./promise/#reference) \ No newline at end of file diff --git a/primitive/null/isNull/index.js b/primitive/null/isNull/index.js deleted file mode 100644 index 2eacde2..0000000 --- a/primitive/null/isNull/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function isNull (value) { - return value === null -} diff --git a/primitive/null/isNull/readme.md b/primitive/null/isNull/readme.md deleted file mode 100644 index 17175c9..0000000 --- a/primitive/null/isNull/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[null](../#reference)/isNull - -## Usage - -```js -isNull(value) -``` \ No newline at end of file diff --git a/primitive/null/readme.md b/primitive/null/readme.md deleted file mode 100644 index a7c56cc..0000000 --- a/primitive/null/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/null - -* [isNull](isNull/#reference) \ No newline at end of file diff --git a/primitive/number/isNumber/index.js b/primitive/number/isNumber/index.js deleted file mode 100644 index 9a213c1..0000000 --- a/primitive/number/isNumber/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getPrimitiveOf } from '../../object/getPrimitiveOf' -import { getTypeOf } from '../../object/getTypeOf' - -const type = 'number' - -export function isNumber (value) { - return getTypeOf(value) === type || - getPrimitiveOf(value) === type -} diff --git a/primitive/number/isNumber/readme.md b/primitive/number/isNumber/readme.md deleted file mode 100644 index 9ec2165..0000000 --- a/primitive/number/isNumber/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[number](../#reference)/isNumber - -## Usage - -```js -isNumber(value) -``` \ No newline at end of file diff --git a/primitive/number/readme.md b/primitive/number/readme.md deleted file mode 100644 index 3589396..0000000 --- a/primitive/number/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/number - -* [isNumber](isNumber/#reference) \ No newline at end of file diff --git a/primitive/object/create/index.js b/primitive/object/create/index.js deleted file mode 100644 index 4b974ea..0000000 --- a/primitive/object/create/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export const create = function (method, prototype, descriptors) { - return method(prototype || null, descriptors) -}.bind(null, Object.create) diff --git a/primitive/object/create/readme.md b/primitive/object/create/readme.md deleted file mode 100644 index f582908..0000000 --- a/primitive/object/create/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/create - -## Usage - -```js -create(prototype, descriptors) -``` \ No newline at end of file diff --git a/primitive/object/getPrimitiveOf/index.js b/primitive/object/getPrimitiveOf/index.js deleted file mode 100644 index 8d5326a..0000000 --- a/primitive/object/getPrimitiveOf/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import { global } from '../../../global' -import { indexOf } from '../../array/indexOf' -import { isNull } from '../../null/isNull' -import { toLowerCase } from '../../string/toLowerCase' -import { getTypeOf } from '../getTypeOf' - -const window = global() -const getPrototypeOf = Object.getPrototypeOf -const constructors = [ - window.Boolean, - window.Function, - window.Number, - window.String, - window.Symbol -] - -export function getPrimitiveOf (value) { - if (isNull(value)) { - return 'null' - } - - const type = getTypeOf(value) - - if (type !== 'object') { - return type - } - - const prototype = getPrototypeOf(value) - - if (isNull(prototype)) { - return type - } - - const constructor = prototype.constructor - - if (indexOf(constructors, constructor) > -1) { - return toLowerCase(constructor.name) - } - - return getPrimitiveOf(prototype) -} diff --git a/primitive/object/getPrimitiveOf/readme.md b/primitive/object/getPrimitiveOf/readme.md deleted file mode 100644 index 7d9105f..0000000 --- a/primitive/object/getPrimitiveOf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/getPrimitiveOf - -## Usage - -```js -getPrimitiveOf(value) -``` \ No newline at end of file diff --git a/primitive/object/getTypeOf/index.js b/primitive/object/getTypeOf/index.js deleted file mode 100644 index ee143d9..0000000 --- a/primitive/object/getTypeOf/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function getTypeOf (value) { - return typeof value -} diff --git a/primitive/object/getTypeOf/readme.md b/primitive/object/getTypeOf/readme.md deleted file mode 100644 index 4891533..0000000 --- a/primitive/object/getTypeOf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/getTypeOf - -## Usage - -```js -getTypeOf(value) -``` \ No newline at end of file diff --git a/primitive/object/isInstanceOf/index.js b/primitive/object/isInstanceOf/index.js deleted file mode 100644 index 969bcbd..0000000 --- a/primitive/object/isInstanceOf/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { isNull } from '../../null/isNull' -import { isUndefined } from '../../undefined/isUndefined' - -const getPrototypeOf = Object.getPrototypeOf - -export function isInstanceOf (constructor, value) { - if (isNull(value) || isUndefined(value)) { - return false - } - - value = getPrototypeOf(Object(value)) - - return value === constructor.prototype || - isInstanceOf(constructor, value) -} diff --git a/primitive/object/isInstanceOf/readme.md b/primitive/object/isInstanceOf/readme.md deleted file mode 100644 index 33b6591..0000000 --- a/primitive/object/isInstanceOf/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/isInstanceOf - -## Usage - -```js -isInstanceOf(constructor, value) -``` \ No newline at end of file diff --git a/primitive/object/isObject/index.js b/primitive/object/isObject/index.js deleted file mode 100644 index a5f3f4d..0000000 --- a/primitive/object/isObject/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { getTypeOf } from '../getTypeOf' - -export function isObject (value) { - return getTypeOf(value) === 'object' && value !== null -} diff --git a/primitive/object/isObject/readme.md b/primitive/object/isObject/readme.md deleted file mode 100644 index d08a3e4..0000000 --- a/primitive/object/isObject/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/isObject - -## Usage - -```js -isObject(value) -``` \ No newline at end of file diff --git a/primitive/object/keys/index.js b/primitive/object/keys/index.js deleted file mode 100644 index c777dba..0000000 --- a/primitive/object/keys/index.js +++ /dev/null @@ -1 +0,0 @@ -export const keys = Object.keys diff --git a/primitive/object/keys/readme.md b/primitive/object/keys/readme.md deleted file mode 100644 index 4b9f38f..0000000 --- a/primitive/object/keys/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/keys - -## Usage - -```js -keys(value) -``` \ No newline at end of file diff --git a/primitive/object/readme.md b/primitive/object/readme.md deleted file mode 100644 index d317897..0000000 --- a/primitive/object/readme.md +++ /dev/null @@ -1,9 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/object - -* [create](./create/#reference) -* [getPrimitiveOf](./getPrimitiveOf/#reference) -* [getTypeOf](./getTypeOf/#reference) -* [isInstanceOf](./isInstanceOf/#reference) -* [isObject](./isObject/#reference) -* [keys](./keys/#reference) -* [toString](./toString/#reference) \ No newline at end of file diff --git a/primitive/object/toString/index.js b/primitive/object/toString/index.js deleted file mode 100644 index 5d11e3d..0000000 --- a/primitive/object/toString/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const toString = demethodize(Object.prototype.toString) diff --git a/primitive/object/toString/readme.md b/primitive/object/toString/readme.md deleted file mode 100644 index 3c1e145..0000000 --- a/primitive/object/toString/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[object](../#reference)/toString - -## Usage - -```js -toString(value) -``` \ No newline at end of file diff --git a/primitive/readme.md b/primitive/readme.md deleted file mode 100644 index 4ca1ba5..0000000 --- a/primitive/readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# [anticore](../../../#reference)/primitive - -* [array](./array/#reference) -* [boolean](./boolean/#reference) -* [function](./function/#reference) -* [null](./null/#reference) -* [number](./number/#reference) -* [object](./object/#reference) -* [string](./string/#reference) -* [symbol](./symbol/#reference) -* [undefined](./undefined/#reference) \ No newline at end of file diff --git a/primitive/string/camelToDash/index.js b/primitive/string/camelToDash/index.js deleted file mode 100644 index 5893521..0000000 --- a/primitive/string/camelToDash/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { toLowerCase } from '../toLowerCase' - -function format (value) { - return '-'.concat(toLowerCase(value)) -} - -export function camelToDash (value) { - return value.replace(/([A-Z])/g, format) -} diff --git a/primitive/string/camelToDash/readme.md b/primitive/string/camelToDash/readme.md deleted file mode 100644 index 9fb905f..0000000 --- a/primitive/string/camelToDash/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/camelToDash - -## Usage - -```js -camelToDash(value) -``` \ No newline at end of file diff --git a/primitive/string/dashToCamel/index.js b/primitive/string/dashToCamel/index.js deleted file mode 100644 index ff86c79..0000000 --- a/primitive/string/dashToCamel/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { toUpperCase } from '../toUpperCase' - -function format (value) { - return toUpperCase(value).replace('-', '') -} - -export function dashToCamel (value) { - return value.replace(/(-[a-z])/g, format) -} diff --git a/primitive/string/dashToCamel/readme.md b/primitive/string/dashToCamel/readme.md deleted file mode 100644 index 6589480..0000000 --- a/primitive/string/dashToCamel/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/dashToCamel - -## Usage - -```js -dashToCamel(value) -``` \ No newline at end of file diff --git a/primitive/string/isString/index.js b/primitive/string/isString/index.js deleted file mode 100644 index 0300cde..0000000 --- a/primitive/string/isString/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getPrimitiveOf } from '../../object/getPrimitiveOf' -import { getTypeOf } from '../../object/getTypeOf' - -const type = 'string' - -export function isString (value) { - return getTypeOf(value) === type || - getPrimitiveOf(value) === type -} diff --git a/primitive/string/isString/readme.md b/primitive/string/isString/readme.md deleted file mode 100644 index 7a400ee..0000000 --- a/primitive/string/isString/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/isString - -## Usage - -```js -isString(value) -``` \ No newline at end of file diff --git a/primitive/string/readme.md b/primitive/string/readme.md deleted file mode 100644 index 8dcf52d..0000000 --- a/primitive/string/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/string - -* [camelToDash](./camelToDash/#reference) -* [dashToCamel](./dashToCamel/#reference) -* [isString](./isString/#reference) -* [toLowerCase](./toLowerCase/#reference) -* [toUpperCase](./toUpperCase/#reference) -* [toDOM](./toDOM/#reference) \ No newline at end of file diff --git a/primitive/string/toDOM/index.js b/primitive/string/toDOM/index.js deleted file mode 100644 index 7b872e5..0000000 --- a/primitive/string/toDOM/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import { element } from '../../../dom/node/element' -import { fragment } from '../../../dom/node/fragment' -import { nodes } from '../../../dom/query/nodes' -import { html } from '../../../dom/tree/html' - -export function toDOM (data) { - return fragment(nodes(html(element('body'), data))) -} diff --git a/primitive/string/toDOM/readme.md b/primitive/string/toDOM/readme.md deleted file mode 100644 index c09bae2..0000000 --- a/primitive/string/toDOM/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/toDOM - -## Usage - -```js -toDOM(data) -``` \ No newline at end of file diff --git a/primitive/string/toLowerCase/index.js b/primitive/string/toLowerCase/index.js deleted file mode 100644 index 24ce383..0000000 --- a/primitive/string/toLowerCase/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const toLowerCase = demethodize(String.prototype.toLowerCase) diff --git a/primitive/string/toLowerCase/readme.md b/primitive/string/toLowerCase/readme.md deleted file mode 100644 index 5e37c83..0000000 --- a/primitive/string/toLowerCase/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/toLowerCase - -## Usage - -```js -toLowerCase(str) -``` \ No newline at end of file diff --git a/primitive/string/toUpperCase/index.js b/primitive/string/toUpperCase/index.js deleted file mode 100644 index 37071cc..0000000 --- a/primitive/string/toUpperCase/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { demethodize } from '../../function/demethodize' - -export const toUpperCase = demethodize(String.prototype.toUpperCase) diff --git a/primitive/string/toUpperCase/readme.md b/primitive/string/toUpperCase/readme.md deleted file mode 100644 index 0dd18ff..0000000 --- a/primitive/string/toUpperCase/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[string](../#reference)/toUpperCase - -## Usage - -```js -toUpperCase(str) -``` \ No newline at end of file diff --git a/primitive/symbol/isSymbol/index.js b/primitive/symbol/isSymbol/index.js deleted file mode 100644 index 98fa3e3..0000000 --- a/primitive/symbol/isSymbol/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getPrimitiveOf } from '../../object/getPrimitiveOf' -import { getTypeOf } from '../../object/getTypeOf' - -const type = 'symbol' - -export function isSymbol (value) { - return getTypeOf(value) === type || - getPrimitiveOf(value) === type -} diff --git a/primitive/symbol/isSymbol/readme.md b/primitive/symbol/isSymbol/readme.md deleted file mode 100644 index 0ac3082..0000000 --- a/primitive/symbol/isSymbol/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[number](../#reference)/isSymbol - -## Usage - -```js -isSymbol(value) -``` \ No newline at end of file diff --git a/primitive/symbol/readme.md b/primitive/symbol/readme.md deleted file mode 100644 index 302404a..0000000 --- a/primitive/symbol/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/isSymbol - -* [isSymbol](isSymbol/#reference) \ No newline at end of file diff --git a/primitive/undefined/isUndefined/index.js b/primitive/undefined/isUndefined/index.js deleted file mode 100644 index 2b635d8..0000000 --- a/primitive/undefined/isUndefined/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function isUndefined (value) { - return value === undefined -} diff --git a/primitive/undefined/isUndefined/readme.md b/primitive/undefined/isUndefined/readme.md deleted file mode 100644 index e233c71..0000000 --- a/primitive/undefined/isUndefined/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../../../#reference)/[primitive](../../#reference)/[undefined](../#reference)/isUndefined - -## Usage - -```js -isUndefined(value) -``` \ No newline at end of file diff --git a/primitive/undefined/readme.md b/primitive/undefined/readme.md deleted file mode 100644 index 4300ac3..0000000 --- a/primitive/undefined/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# [anticore](../../../../#reference)/[primitive](../#reference)/undefined - -* [isUndefined](./isUndefined/#reference) \ No newline at end of file diff --git a/readme.md b/readme.md index 323fd57..c2806db 100644 --- a/readme.md +++ b/readme.md @@ -1,99 +1,90 @@ -# anticore +# anticore [![npm](https://img.shields.io/npm/v/anticore.svg?style=plastic)]() [![Downloads](https://img.shields.io/npm/dt/anticore.svg?style=plastic)]() [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) -**anticore** is a generic living DOM library to simplify your client code, like with its easiest middleware manager for -AJAX requests. - -## What it solves? - -* **Based on the ES6 modules**, each middleware should be written in a separated module, ideally following the [single responsibility principle](https://en.wikipedia.org/wiki/Single_responsibility_principle), improving the maintainability -* You can create your middlewares as **specific or generic as you need**, increasing the **reusable components between projects** -* A middleware is really short to write, **easy to replace/remove**, no need to check if it doesn't risk to break your code, there is no chain -* **No need to build any AJAX requests**, anticore is based on the forms/anchors attributes -* **No need to check the response status/content**, everything is content based, targeted by the middleware selector, then it requires SSR contents +**anticore** is a library to handle your AJAX/SSE DOM contents, using some contracts. ## Install -`npm i -D anticore` +`npm i anticore` -## Or try it in a few seconds +## Basic usage + +```js +import { trigger } from 'anticore' +// begin of custom contracts -https://lcfvs.github.io/anticore-quick-start +// end of custom contracts +import 'anticore-contracts/fetchers/defaults' +import 'anticore-contracts/main/mono' -## Demos +trigger() +``` -* [Live demos](http://lcfvs.github.io/anticore) -* [Demo sources](https://github.com/Lcfvs/anticore/tree/gh-pages) +## APIs -## Usage +### on(selector, listener) +Useful to declare a contract to be applied for any element matching the selector, where: +* `selector`: a query selector +* `listener`: a function to be applied on the matching elements + * `element`: the matching element + * `next`: a function to let the other contracts declared after this one (**must be always called!**) + * `url`: the url providing the node (can be empty) ```js -import { anticore } from 'anticore' -import { getTarget } from 'anticore/dom/emitter/getTarget' -import { onClick } from 'anticore/dom/emitter/on/onClick' -import { closest } from 'anticore/dom/query/closest' -import { one } from 'anticore/dom/query/one' -import { append } from 'anticore/dom/tree/append' -import { remove } from 'anticore/dom/tree/remove' -import { replace } from 'anticore/dom/tree/replace' - -function onClose (event) { - remove(closest('.modal', getTarget(event))) -} - -// middleware to treat an element with a 'modal' class -anticore.on('.modal', function (element, next) { - // append the modal to the body - append(element, one('body')) - next() -}) +import { on } from 'anticore' -// middleware to treat a button with a 'closer' class contained in a modal -anticore.on('.modal button.closer', function (element, next) { - // listen the click on the button to close the modal - onClick(element, onClose) - next() +on('body', (element, next, url) => { + element.innerHTML = `This is the called url: ${url}` + next() }) - -// apply the defaults middlewares (to listen anchor/button click and form submit) -// then trigger all the middlewares on the current document -import 'anticore/middleware/main/mono' -anticore.defaults().populate() ``` -## What's new in the V2? +### trigger([node]) +Useful to apply the declared contracts on the provided `node`, where: +* **optional** `node`: the targeted node (element or document)) -If the V1 was really lightweight, the V2 isn't, because it comes with a lot of generic utils (proposals are -welcome), useful to easily write your client code, without any unused features and with a better -minification result... but without growing your `dist` package. +```js +import { trigger } from 'anticore' -You can use the anticore methods or not... or both, if you need some offered functions, these functions are -embed in your `dist`, but never if your don't import it explicitly. +trigger(document) +``` + +### fetch(target, request[, interval = 1000[, retries = Infinity]]) -On an other aspect, the V2 is 100% based on `import`/`export`. +Useful to create your own DOM content fetchers, where: +* `event`: the event invoking the `fetch` +* `target`: the element invoking the `fetch` (gets a `.fetching`, until resolved) +* `request`: the [Request](https://developer.mozilla.org/fr/docs/Web/API/Request) instance +* **optional** `options`: the options object + * **optional** `interval`: the delay before a retry, if the fetch fails + * **optional** `retries`: the number of possible retries -## Breaking changes from the V1 +```js +import { fetch } from 'anticore' -The anticore methods are unchanged, but all the utils are rewritten as separated modules. +fetch(event, element, request, options) +``` -If you need the previous version, you can install it by `npm i -D anticore@1.9.1` +## sse(url, [options, [reviver]]) +Useful to listen Server-Sent Events +```js +import sse from 'anticore/sse' + +const eventSource = sse(url, options, reviver) +``` -## anticore methods -[anticore methods](https://github.com/Lcfvs/anticore/blob/master/anticore.md#reference) +## Companions -## Tools +* [anticore-contracts](https://github.com/Lcfvs/anticore-contracts) +* [anticore-core](https://github.com/Lcfvs/anticore-core) +* [anticore-dom](https://github.com/Lcfvs/anticore-dom) +* [anticore-utils](https://github.com/Lcfvs/anticore-utils) -* [api](https://github.com/Lcfvs/anticore/blob/master/api/#reference) -* [dom](https://github.com/Lcfvs/anticore/blob/master/dom/#reference) -* [global](https://github.com/Lcfvs/anticore/blob/master/global/#reference) -* [middleware](https://github.com/Lcfvs/anticore/blob/master/global/#reference) -* [primitive](https://github.com/Lcfvs/anticore/blob/master/primitive/#reference) -* [request](https://github.com/Lcfvs/anticore/blob/master/request/#reference) ## License diff --git a/request/.queue.js b/request/.queue.js deleted file mode 100644 index f4d5fea..0000000 --- a/request/.queue.js +++ /dev/null @@ -1,9 +0,0 @@ -export const queue = [] - -queue.next = function () { - queue.shift() - - if (queue.length) { - queue[0].request.fetchRequest() - } -} diff --git a/request/index.js b/request/index.js deleted file mode 100644 index 0d2cef7..0000000 --- a/request/index.js +++ /dev/null @@ -1,182 +0,0 @@ -import { one } from '../dom/query/one' -import { global } from '../global' -import { create } from '../primitive/object/create' -import { queue } from './.queue' - -const window = global() -const fetch = window.fetch -const XMLHttpRequest = window.XMLHttpRequest -const Response = window.Response -const TypeError = window.TypeError -const prototype = create() -const selector = 'input[type=submit]:focus,' + - 'button[type=submit]:focus,' + - 'button:not([type]):focus,' + - 'input[type=submit]:hover,' + - 'button[type=submit]:hover,' + - 'button:not([type]):hover,' + - ':not(input):hover,' + - 'input[type=submit],' + - 'button[type=submit],' + - 'button:not([type])' - -/** - * Adds a field value on an existing body - * @param {String} name - * @param {*} value - * @return {Object} - */ -prototype.body = function (name, value) { - this.options.body.append(name, value) - - return this -} - -/** - * Adds credentials to the request - * (let by default, if you fetch a resource on the same domain, if not, use 'include') - * @param {String} [value='same-origin'] - * @return {Object} - */ -prototype.credentials = function (value) { - this.options.credentials = value || 'same-origin' - - return this -} - -/** - * Fetches the request & adds a trigger callback for the response - * @param {Function} trigger - * @returns {Promise} - */ -prototype.fetch = function (trigger) { - let item = create() - - item.request = this - queue.push(item) - - return new Promise(function (resolve, reject) { - item.request.resolve = resolve - item.trigger = trigger - - item.reject = function (error) { - reject(error) - queue.next() - } - - item.request.fetchRequest() - }) -} - -/** - * Retries to fetch a request - * @returns {Object} - */ -prototype.retry = function () { - if (!queue[0] || queue[0].request !== this) { - return this - } - - queue.unshift(1) - queue.next() - - return this -} - -/** - * Add a header to the request - * @param {String} name - * @param {String} value - * @returns {Object} - */ -prototype.header = function (name, value) { - this.options.headers[name] = value - - return this -} - -/** - * Adds an option to the request - * @param {String} name - * @param {String} value - * @returns {Object} - */ -prototype.option = function (name, value) { - this.options[name] = value - - return this -} - -prototype.fetchRequest = function () { - let item = queue[0] - - if (queue[1]) { - return - } - - const url = item.request.url - const fetch = item.request.negotiate(url) - - return fetch(url, item.request.options).then(item.trigger || - item.request.resolve).then(queue.next)['catch'](item.reject) -} - -prototype.negotiate = function (url) { - return window.location.href.substr(0, 8) === 'file:///' && /^\.|\//.test(url) - ? fetchFile - : fetch -} - -function fetchFile (url) { - return new Promise(function (resolve, reject) { - const xhr = new XMLHttpRequest() - - xhr.addEventListener('load', function () { - resolve(new Response(xhr.responseText, { - status: xhr.status || 200 - })) - }) - - xhr.addEventListener('error', function () { - reject(new TypeError('Local request failed')) - }) - - xhr.open('GET', url) - xhr.send(null) - }) -} - -/** - * Builds a request - * @param {String} url - * @param {String} method (get or post) - * @param {Object} [body] (the post request body) - * @param {Element} [target] (the event target) - * @return {Object} - */ -export function request (url, method, body, target) { - let request, - options - - request = create(prototype) - options = create() - - request.options = options - - if (target) { - request.target = target - request.originalTarget = one(selector, target.ownerDocument) - } - - request.url = url - - options.headers = create() - options.headers['X-Requested-With'] = 'XMLHttpRequest' - options.method = method - - if (method === 'post') { - options.body = body - } - - return request -} diff --git a/request/readme.md b/request/readme.md deleted file mode 100644 index 9eb1c76..0000000 --- a/request/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# [anticore](../../../#reference)/request - -## Usage - -```js -request(url, method, body, target) -``` \ No newline at end of file diff --git a/sse.js b/sse.js new file mode 100644 index 0000000..2699b62 --- /dev/null +++ b/sse.js @@ -0,0 +1,22 @@ +import EventSource from 'anticore-core/apis/EventSource' +import onError from 'anticore-dom/emitter/onError' +import onMessage from 'anticore-dom/emitter/onMessage' +import fromString from 'anticore-dom/tree/fromString' +import { trigger, debug } from './index' + +/** + * Listens an event source + * turns the contents to DOM, except if a reviver is provided + * @param {string} url + * @param {object} config + * @param {function} reviver + * @returns {EventSource} source + */ +export default function sse (url, config, reviver = fromString) { + const source = new EventSource(url, config) + + onMessage(source, event => trigger(reviver(event.data), url)) + onError(source, debug.onError) + + return source +}