Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bjorklund-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bjorklund-js - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

33

bjorklund.js

@@ -56,2 +56,15 @@ (function (root, factory) {

function interlace (a, b) {
// interlace values in a
return a.reduce(
function(interlaced, x, i) {
return interlaced.concat([x, b[i]]);
},
[]
).concat(
// then remaining items in b
b.slice(a.length)
);
}
function bjorklund(n, k) {

@@ -68,8 +81,18 @@

if (m > k) {
l = euclid(m, k, qs, rs);
build(qs, rs, l, 0, 1, gs);
if (m !== 0) {
if (k === 0) {
return Array(n).fill(0);
} else if (n % k !== 0) {
if (m > k) {
l = euclid(m, k, qs, rs);
build(qs, rs, l, 0, 1, gs);
} else {
l = euclid(k, m, qs, rs);
build(qs, rs, l, 1, 0, gs);
}
} else {
return interlace(Array(k).fill(1), Array(n - k).fill(0));
}
} else {
l = euclid(k, m, qs, rs);
build(qs, rs, l, 1, 0, gs);
return Array(n).fill(1);
}

@@ -76,0 +99,0 @@

2

bjorklund.min.js

@@ -1,2 +0,2 @@

!function(n,e){"function"==typeof define&&define.amd?define(function(){return n.bjorklund=e()}):"object"==typeof exports?module.exports=e():n.bjorklund=e()}(this,function(){function n(e,r,u,o,f){f=f||0;var i=t(e/r),a=e%r;return u.push(i),o.push(a),a?n(r,a,u,o,f+1):f}function e(n,r,t,u,o,f){var i,a,c;switch(t){case-1:f.push(u);break;case-2:f.push(o);break;default:for(a=n[t],c=r[t],i=0;a>i;i++)e(n,r,t-1,u,o,f);0!==c&&e(n,r,t-2,u,o,f)}}function r(r,t){var u,o=r-t,f=[],i=[t],a=[];return o>t?(u=n(o,t,f,i),e(f,i,u,0,1,a)):(u=n(t,o,f,i),e(f,i,u,1,0,a)),a}var t=Math.floor;return r});
!function(r,n){"function"==typeof define&&define.amd?define(function(){return r.bjorklund=n()}):"object"==typeof exports?module.exports=n():r.bjorklund=n()}(this,function(){function r(n,e,t,o,f){f=f||0;var c=u(n/e),i=n%e;return t.push(c),o.push(i),i?r(e,i,t,o,f+1):f}function n(r,e,t,u,o,f){var c,i,a;switch(t){case-1:f.push(u);break;case-2:f.push(o);break;default:for(i=r[t],a=e[t],c=0;c<i;c++)n(r,e,t-1,u,o,f);0!==a&&n(r,e,t-2,u,o,f)}}function e(r,n){return r.reduce(function(r,e,t){return r.concat([e,n[t]])},[]).concat(n.slice(r.length))}function t(t,u){var o,f=t-u,c=[],i=[u],a=[];return 0===f?Array(t).fill(1):0===u?Array(t).fill(0):t%u===0?e(Array(u).fill(1),Array(t-u).fill(0)):(f>u?(o=r(f,u,c,i),n(c,i,o,0,1,a)):(o=r(u,f,c,i),n(c,i,o,1,0,a)),a)}var u=Math.floor;return t});
//# sourceMappingURL=bjorklund.min.js.map
{
"name": "bjorklund-js",
"version": "0.1.0",
"version": "0.1.2",
"homepage": "https://github.com/adriano-di-giovanni/bjorklund-js",

@@ -5,0 +5,0 @@ "authors": [

{
"name": "bjorklund-js",
"version": "0.1.1",
"version": "0.1.2",
"description": "A Javascript Universal Module implementation of the Bjorklund algorithm",

@@ -10,2 +10,3 @@ "main": "bjorklund.min.js",

"scripts": {
"build": "gulp build",
"test": "mocha --reporter spec test"

@@ -12,0 +13,0 @@ },

@@ -47,1 +47,5 @@ ## Bjorklund

Add minified version
## 0.1.2
Fixed algorithm for N==k, n % k == 0, k == 0. Thanks [@colinsullivan](https://github.com/colinsullivan)

@@ -36,2 +36,9 @@ /* eslint-env mocha */

it('E(13,24)', function () { expect(t(b(24, 13))).to.contain('101101010101011010101010'); });
it('E(4,4)', function () { expect(t(b(4, 4))).to.contain('1111'); })
it('E(5,5)', function () { expect(t(b(5, 5))).to.contain('11111'); })
it('E(1,1)', function () { expect(t(b(1, 1))).to.contain('1'); })
it('E(4,8)', function () { expect(t(b(8, 4))).to.contain('10101010'); })
it('E(5,10)', function () { expect(t(b(10, 5))).to.contain('1010101010'); })
it('E(4,6)', function () { expect(t(b(6, 4))).to.contain('110110'); })
it('E(0,6)', function () { expect(t(b(6, 0))).to.contain('000000'); })
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc