From c560aeb0665d2e93279f84cc7cd8b73262797ac4 Mon Sep 17 00:00:00 2001 From: Luchanso Date: Sun, 21 May 2017 12:48:27 +0300 Subject: [PATCH] rebuild Batch --- lib/Batch.js | 2 +- lib/Batch.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Batch.js b/lib/Batch.js index fa03b8b..df84001 100644 --- a/lib/Batch.js +++ b/lib/Batch.js @@ -1,2 +1,2 @@ -(function(b,c){'object'==typeof exports&&'object'==typeof module?module.exports=c(require('react')):'function'==typeof define&&define.amd?define('Batch',['react'],c):'object'==typeof exports?exports.Batch=c(require('react')):b.Batch=c(b.react)})(this,function(){return function(b){function c(e){if(d[e])return d[e].exports;var f=d[e]={i:e,l:!1,exports:{}};return b[e].call(f.exports,f,f.exports,c),f.l=!0,f.exports}var d={};return c.m=b,c.c=d,c.i=function(e){return e},c.d=function(e,f,g){c.o(e,f)||Object.defineProperty(e,f,{configurable:!1,enumerable:!0,get:g})},c.n=function(e){var f=e&&e.__esModule?function(){return e['default']}:function(){return e};return c.d(f,'a',f),f},c.o=function(e,f){return Object.prototype.hasOwnProperty.call(e,f)},c.p='./',c(c.s=1)}({'./src/components/Batch/index.js':function(b,c,d){'use strict';Object.defineProperty(c,'__esModule',{value:!0});var e=d(0),f=d.n(e);class g extends e.Component{constructor({flushCount:h,flushInterval:i,debug:j}){super(),this.lastFlushCount=0,this.lastFlushTime=Date.now(),this.flushInterval=i,this.flushCount=h,this.debug=j}componentDidMount(){this._interval=setInterval(()=>this.checkAge(),this.flushInterval)}componentWillUnmount(){clearInterval(this._interval)}log(h,...i){this.debug&&console.log('[batch]: '+h,...i)}age(){return Date.now()-this.lastFlushTime}pending(){const{props:{count:h=0}={}}=this;return h-this.lastFlushCount}intervalExceeded(){return this.age()>=this.flushInterval}checkAge(){this.age()>=this.flushInterval&&0!=this.pending()&&(this.log('flush forced interval'),this.forceUpdate())}shouldComponentUpdate({count:h}){const i=h-this.lastFlushCount;return i>=this.flushCount?(this.log('flush count (age %dms)',this.age()),!0):!!(this.age()>=this.flushInterval)&&(this.log('flush interval (count %d)',i),!0)}render(){const{render:h,count:i}=this.props;return this.lastFlushCount=i,this.lastFlushTime=Date.now(),h()}}c['default']=g},0:function(b){b.exports=require('react')},1:function(b,c,d){b.exports=d('./src/components/Batch/index.js')}})}); +(function(b,c){'object'==typeof exports&&'object'==typeof module?module.exports=c(require('prop-types'),require('react')):'function'==typeof define&&define.amd?define('Batch',['prop-types','react'],c):'object'==typeof exports?exports.Batch=c(require('prop-types'),require('react')):b.Batch=c(b['prop-types'],b.react)})(this,function(){return function(c){function d(f){if(e[f])return e[f].exports;var g=e[f]={i:f,l:!1,exports:{}};return c[f].call(g.exports,g,g.exports,d),g.l=!0,g.exports}var e={};return d.m=c,d.c=e,d.i=function(f){return f},d.d=function(f,g,h){d.o(f,g)||Object.defineProperty(f,g,{configurable:!1,enumerable:!0,get:h})},d.n=function(f){var g=f&&f.__esModule?function(){return f['default']}:function(){return f};return d.d(g,'a',g),g},d.o=function(f,g){return Object.prototype.hasOwnProperty.call(f,g)},d.p='./',d(d.s=2)}({'./src/components/Batch/index.js':function(c,d,e){'use strict';Object.defineProperty(d,'__esModule',{value:!0});var f=e(1),g=e.n(f),h=e(0),i=e.n(h);class j extends f.Component{constructor({flushCount:k,flushInterval:l,debug:m}){this.lastFlushCount=0,this.lastFlushTime=Date.now(),this.flushInterval=l,this.flushCount=k,this.debug=m}componentDidMount(){this._interval=setInterval(()=>this.checkAge(),this.flushInterval)}componentWillUnmount(){clearInterval(this._interval)}log(k,...l){this.debug&&console.log('[batch]: '+k,...l)}age(){return Date.now()-this.lastFlushTime}pending(){const{props:{count:k=0}={}}=this;return k-this.lastFlushCount}intervalExceeded(){return this.age()>=this.flushInterval}checkAge(){this.age()>=this.flushInterval&&0!=this.pending()&&(this.log('flush forced interval'),this.forceUpdate())}shouldComponentUpdate({count:k}){const l=k-this.lastFlushCount;return l>=this.flushCount?(this.log('flush count (age %dms)',this.age()),!0):!!(this.age()>=this.flushInterval)&&(this.log('flush interval (count %d)',l),!0)}render(){const{render:k,count:l}=this.props;return this.lastFlushCount=l,this.lastFlushTime=Date.now(),k()}}d['default']=j,j.propTypes={count:h.number.isRequired,flushCount:h.number.isRequired,flushInterval:h.number.isRequired,render:h.func.isRequired,debug:bool},j.defaultProps={debug:!1}},0:function(c){c.exports=require('prop-types')},1:function(c){c.exports=require('react')},2:function(c,d,e){c.exports=e('./src/components/Batch/index.js')}})}); //# sourceMappingURL=Batch.js.map \ No newline at end of file diff --git a/lib/Batch.js.map b/lib/Batch.js.map index c318696..f6f6931 100644 --- a/lib/Batch.js.map +++ b/lib/Batch.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap ebf23404e9c23c1c2f6d","webpack:///./src/components/Batch/index.js","webpack:///external \"react\""],"names":[],"mappings":"AAAA,cACA,2BACA,iDACA,4CACA,6BACA,GACA,iDAEA,oBACA,QAAC,mBACD,kBCTA,cAMA,MACA,eAGA,mBACA,GACA,EACA,KAIA,mDAGA,KAGA,OACA,OAIA,IAzBA,iBA4BA,MAGA,iBAA2C,OAAc,EAGzD,qBACA,OACA,8BACA,CACA,gBACA,kBAGA,GAGA,iBACA,YACA,qBAA2B,UAA0B,UACrD,YAAiC,OAAe,EAChD,mBACA,GACA,CAGA,mBAAsD,+CAA+D,EAGrH,MAGA,iJChEA,GAEqB,eAAc,YAYjC,aAAY,CAAE,aAAY,gBAAe,SACvC,CACA,aAAK,eACL,OAAK,cAAgB,KACrB,WAAK,cACL,OAAK,WACL,OAAK,MACN,CAMD,oBACE,MAAK,UAAY,YAAY,IAAK,KAAK,WAAY,KACpD,cAMD,uBACE,eAAc,KACf,UAMD,CAAI,MAAQ,KACN,CAAC,KACL,eAAQ,IAAI,YAAc,EAAK,GAChC,EAMD,MACE,OAAO,MAAK,MAAQ,KACrB,aAMD,UACE,MAAM,CAAE,MAAO,CAAE,QAAc,OAC/B,WAAO,GAAQ,KAChB,cAMD,mBACE,OAAO,MAAK,OAAS,KACtB,aAMD,WACE,CAAI,KAAK,OAAS,KAAK,eACrB,CADsC,OAAK,iBACtC,IACL,8BAEH,cAMD,uBAAsB,CAAE,SACtB,MAAM,GAAU,EAAQ,KAExB,qBAAI,IAAW,KACb,iBAAK,IAAI,yBAA0B,KAIrC,cAAI,KAAK,OAAS,KAChB,sBAAK,IAAI,4BAKZ,MAMD,SACE,MAAM,CAAE,SAAQ,SAAU,KAC1B,kBAAK,eACL,OAAK,cAAgB,KACrB,MACD,GA/G0C,gCCF7C,kB","file":"Batch.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Batch\", [\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Batch\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"Batch\"] = factory(root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"./\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ebf23404e9c23c1c2f6d","import React, { Component } from 'react'\n\nexport default class Batch extends Component {\n\n /**\n * Properties:\n *\n * - `count`: the number of items available for rendering\n * - `flushCount`: render after a given number of items\n * - `flushInterval`: render after a given interval is exceeded\n * - `render`: render callback\n * - `debug`: enable debug logging\n */\n\n constructor({ flushCount, flushInterval, debug}) {\n super()\n this.lastFlushCount = 0\n this.lastFlushTime = Date.now()\n this.flushInterval = flushInterval\n this.flushCount = flushCount\n this.debug = debug\n }\n\n /**\n * Start interval check for forced updates.\n */\n\n componentDidMount() {\n this._interval = setInterval(_ => this.checkAge(), this.flushInterval)\n }\n\n /**\n * Clear interval.\n */\n\n componentWillUnmount() {\n clearInterval(this._interval)\n }\n\n /**\n * Log when debug is enabled.\n */\n\n log(msg, ...args) {\n if (!this.debug) return\n console.log('[batch]: ' + msg, ...args)\n }\n\n /**\n * Age of the buffer.\n */\n\n age() {\n return Date.now() - this.lastFlushTime\n }\n\n /**\n * Pending items.\n */\n\n pending() {\n const { props: { count = 0 } = {} } = this\n return count - this.lastFlushCount\n }\n\n /**\n * Interval has exceeded.\n */\n\n intervalExceeded() {\n return this.age() >= this.flushInterval\n }\n\n /**\n * Check age and force flush if the interval has been exceeded.\n */\n\n checkAge() {\n if (this.age() >= this.flushInterval && this.pending() != 0) {\n this.log('flush forced interval')\n this.forceUpdate()\n }\n }\n\n /**\n * Check if the buffer is full or the interval has been exceeded.\n */\n\n shouldComponentUpdate({ count }) {\n const pending = count - this.lastFlushCount\n\n if (pending >= this.flushCount) {\n this.log('flush count (age %dms)', this.age())\n return true\n }\n\n if (this.age() >= this.flushInterval) {\n this.log('flush interval (count %d)', pending)\n return true\n }\n\n return false\n }\n\n /**\n * Render the component.\n */\n\n render() {\n const { render, count } = this.props\n this.lastFlushCount = count\n this.lastFlushTime = Date.now()\n return render()\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/Batch/index.js","module.exports = require(\"react\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react\"\n// module id = 0\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap d5430300efc23349c7c3","webpack:///./src/components/Batch/index.js","webpack:///external \"prop-types\"","webpack:///external \"react\""],"names":[],"mappings":"AAAA,cACA,2BACA,uEACA,4CACA,0CACA,GACA,uEAEA,oCACA,QAAC,mBACD,kBCTA,cAMA,MACA,eAGA,mBACA,GACA,EACA,KAIA,mDAGA,KAGA,OACA,OAIA,IAzBA,iBA4BA,MAGA,iBAA2C,OAAc,EAGzD,qBACA,OACA,8BACA,CACA,gBACA,kBAGA,GAGA,iBACA,YACA,qBAA2B,UAA0B,UACrD,YAAiC,OAAe,EAChD,mBACA,GACA,CAGA,mBAAsD,+CAA+D,EAGrH,MAGA,iKC/DA,GAEqB,eAAc,YAYjC,aAAY,CAAE,aAAY,gBAAe,SACvC,MAAK,eACL,OAAK,cAAgB,KACrB,WAAK,cACL,OAAK,WACL,OAAK,MACN,CAMD,oBACE,MAAK,UAAY,YAAY,IAAK,KAAK,WAAY,KACpD,cAMD,uBACE,eAAc,KACf,UAMD,CAAI,MAAQ,KACN,CAAC,KACL,eAAQ,IAAI,YAAc,EAAK,GAChC,EAMD,MACE,OAAO,MAAK,MAAQ,KACrB,aAMD,UACE,MAAM,CAAE,MAAO,CAAE,QAAc,OAC/B,WAAO,GAAQ,KAChB,cAMD,mBACE,OAAO,MAAK,OAAS,KACtB,aAMD,WACE,CAAI,KAAK,OAAS,KAAK,eACrB,CADsC,OAAK,iBACtC,IACL,8BAEH,cAMD,uBAAsB,CAAE,SACtB,MAAM,GAAU,EAAQ,KAExB,qBAAI,IAAW,KACb,iBAAK,IAAI,yBAA0B,KAIrC,cAAI,KAAK,OAAS,KAChB,sBAAK,IAAI,4BAKZ,MAMD,SACE,MAAM,CAAE,SAAQ,SAAU,KAC1B,kBAAK,eACL,OAAK,cAAgB,KACrB,MACD,GA9G0C,iBAiH7C,EAAM,UACJ,OAAO,SACP,sBAAY,SACZ,yBAAe,SACf,kBAAQ,OACR,iBAAO,MAGT,EAAM,aACJ,CAAO,yBC7HT,kB,6BCAA,kB","file":"Batch.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"prop-types\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Batch\", [\"prop-types\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Batch\"] = factory(require(\"prop-types\"), require(\"react\"));\n\telse\n\t\troot[\"Batch\"] = factory(root[\"prop-types\"], root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"./\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap d5430300efc23349c7c3","import React, { Component } from 'react'\nimport { string, number, func } from 'prop-types'\n\nexport default class Batch extends Component {\n\n /**\n * Properties:\n *\n * - `count`: the number of items available for rendering\n * - `flushCount`: render after a given number of items\n * - `flushInterval`: render after a given interval is exceeded\n * - `render`: render callback\n * - `debug`: enable debug logging\n */\n\n constructor({ flushCount, flushInterval, debug}) {\n this.lastFlushCount = 0\n this.lastFlushTime = Date.now()\n this.flushInterval = flushInterval\n this.flushCount = flushCount\n this.debug = debug\n }\n\n /**\n * Start interval check for forced updates.\n */\n\n componentDidMount() {\n this._interval = setInterval(_ => this.checkAge(), this.flushInterval)\n }\n\n /**\n * Clear interval.\n */\n\n componentWillUnmount() {\n clearInterval(this._interval)\n }\n\n /**\n * Log when debug is enabled.\n */\n\n log(msg, ...args) {\n if (!this.debug) return\n console.log('[batch]: ' + msg, ...args)\n }\n\n /**\n * Age of the buffer.\n */\n\n age() {\n return Date.now() - this.lastFlushTime\n }\n\n /**\n * Pending items.\n */\n\n pending() {\n const { props: { count = 0 } = {} } = this\n return count - this.lastFlushCount\n }\n\n /**\n * Interval has exceeded.\n */\n\n intervalExceeded() {\n return this.age() >= this.flushInterval\n }\n\n /**\n * Check age and force flush if the interval has been exceeded.\n */\n\n checkAge() {\n if (this.age() >= this.flushInterval && this.pending() != 0) {\n this.log('flush forced interval')\n this.forceUpdate()\n }\n }\n\n /**\n * Check if the buffer is full or the interval has been exceeded.\n */\n\n shouldComponentUpdate({ count }) {\n const pending = count - this.lastFlushCount\n\n if (pending >= this.flushCount) {\n this.log('flush count (age %dms)', this.age())\n return true\n }\n\n if (this.age() >= this.flushInterval) {\n this.log('flush interval (count %d)', pending)\n return true\n }\n\n return false\n }\n\n /**\n * Render the component.\n */\n\n render() {\n const { render, count } = this.props\n this.lastFlushCount = count\n this.lastFlushTime = Date.now()\n return render()\n }\n}\n\nBatch.propTypes = {\n count: number.isRequired,\n flushCount: number.isRequired,\n flushInterval: number.isRequired,\n render: func.isRequired,\n debug: bool\n}\n\nBatch.defaultProps = {\n debug: false\n}\n\n\n// WEBPACK FOOTER //\n// ./src/components/Batch/index.js","module.exports = require(\"prop-types\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"prop-types\"\n// module id = 0\n// module chunks = 0","module.exports = require(\"react\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react\"\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file