diff --git a/gzip-size-3.0.0.tgz b/gzip-size-3.0.0.tgz new file mode 100644 index 0000000..314d68c Binary files /dev/null and b/gzip-size-3.0.0.tgz differ diff --git a/nodejs-gzip-size.spec b/nodejs-gzip-size.spec new file mode 100644 index 0000000..6c43517 --- /dev/null +++ b/nodejs-gzip-size.spec @@ -0,0 +1,50 @@ +%{?nodejs_find_provides_and_requires} +%global enable_tests 0 +Name: nodejs-gzip-size +Version: 3.0.0 +Release: 1 +Summary: Get the gzipped size of a string or buffer +License: MIT +URL: https://github.com/sindresorhus/gzip-size +Source0: http://registry.npmjs.org/gzip-size/-/gzip-size-%{version}.tgz +Source1: https://raw.githubusercontent.com/sindresorhus/gzip-size/v%{version}/test.js +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} noarch +BuildRequires: nodejs-packaging +%if 0%{?enable_tests} +BuildRequires: npm(ava) npm(concat-stream) npm(zlib-browserify) +%endif +%description +%{summary}. + +%prep +%setup -q -n package +cp -p %{SOURCE1} . + +%build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/gzip-size +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/gzip-size +mkdir -p %{buildroot}%{_bindir} +ln -sf %{nodejs_sitelib}/gzip-size/index.js \ + %{buildroot}%{_bindir}/gzip-size +%nodejs_symlink_deps +%if 0%{?enable_tests} + +%check +%nodejs_symlink_deps --check +%__nodejs tap.js +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license license +%{nodejs_sitelib}/gzip-size +%{_bindir}/gzip-size + +%changelog +* Thu Aug 20 2020 yaokai - 3.0.0-1 +- Package init diff --git a/nodejs-gzip-size.yaml b/nodejs-gzip-size.yaml new file mode 100644 index 0000000..957ef9a --- /dev/null +++ b/nodejs-gzip-size.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: sindresorhus/gzip-size +tag_pattern: "^v" +seperator: "." diff --git a/test.js b/test.js new file mode 100644 index 0000000..eb83fdc --- /dev/null +++ b/test.js @@ -0,0 +1,63 @@ +'use strict'; +var fs = require('fs'); +var tap = require('tap'); +var gzipSize = require('./'); +var a = fs.readFileSync('test.js', 'utf8'); + +tap.test('get the gzipped size', function (t) { + t.plan(2); + + gzipSize(a, function (err, size) { + t.assert(!err); + t.assert(size < a.length); + }); +}); + +tap.test('sync - get the gzipped size', function (t) { + t.plan(1); + + t.assert(gzipSize.sync(a) < a.length); +}); + +tap.test('sync - match async version', function (t) { + t.plan(2); + + gzipSize(a, function (err, size) { + t.assert(!err); + t.assert(gzipSize.sync(a) === size); + }); +}); + +tap.test('stream', function (t) { + t.plan(1); + + fs.createReadStream('test.js') + .pipe(gzipSize.stream()) + .on('end', function () { + t.equal(this.gzipSize, gzipSize.sync(a)); + }); +}); + +tap.test('gzip-size event', function (t) { + t.plan(1); + + fs.createReadStream('test.js') + .pipe(gzipSize.stream()) + .on('gzip-size', function (size) { + t.equal(size, gzipSize.sync(a)); + }); +}); + +tap.test('passthrough', function (t) { + t.plan(1); + + var out = ''; + fs.createReadStream('test.js') + .pipe(gzipSize.stream()) + .on('data', function (buf) { + out += buf; + }) + .on('end', function () { + t.equal(out, a); + }); +});