synchsafe 6.0.17 → 6.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/build/es5/bundle.js +2 -11
- package/build/node/module.js +2 -15
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# synchsafe
|
|
2
2
|
|
|
3
|
-
**A
|
|
3
|
+
**A module to decode and encode synchsafe integers.**
|
|
4
4
|
|
|
5
|
-
[](https://github.com/chrisguttandin/synchsafe/network/dependencies)
|
|
6
5
|
[](https://www.npmjs.com/package/synchsafe)
|
|
7
6
|
|
|
8
|
-
This module provides two functions to decode and encode synchsafe integers as it is for example
|
|
9
|
-
required by the [ID3 standard](http://id3.org/id3v2.4.0-structure). It is basically a fork of this
|
|
10
|
-
[Gist](https://gist.github.com/raym/7b8cb7b838c94cada0b7) by [raym](https://github.com/raym).
|
|
7
|
+
This module provides two functions to decode and encode synchsafe integers as it is for example required by the [ID3 standard](http://id3.org/id3v2.4.0-structure). It is a fork of this [Gist](https://gist.github.com/raym/7b8cb7b838c94cada0b7) by [raym](https://github.com/raym).
|
|
11
8
|
|
|
12
9
|
## Usage
|
|
13
10
|
|
package/build/es5/bundle.js
CHANGED
|
@@ -10,12 +10,9 @@
|
|
|
10
10
|
var decode = function decode(synchsafed) {
|
|
11
11
|
var mask = 0x7f000000;
|
|
12
12
|
var unsynchsafed = 0;
|
|
13
|
-
|
|
14
13
|
while (mask !== 0) {
|
|
15
14
|
unsynchsafed >>= 1; // tslint:disable-line no-bitwise
|
|
16
|
-
|
|
17
15
|
unsynchsafed |= synchsafed & mask; // tslint:disable-line no-bitwise
|
|
18
|
-
|
|
19
16
|
mask >>= 8; // tslint:disable-line no-bitwise
|
|
20
17
|
}
|
|
21
18
|
|
|
@@ -24,24 +21,18 @@
|
|
|
24
21
|
/**
|
|
25
22
|
* This functions turns a regular integer into synchronisation-saved one.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
24
|
var encode = function encode(unsynchsafed) {
|
|
29
25
|
var mask = 0x7f;
|
|
30
26
|
var synchsafed;
|
|
31
|
-
var unsynchsafedRest = unsynchsafed;
|
|
32
|
-
|
|
27
|
+
var unsynchsafedRest = unsynchsafed;
|
|
28
|
+
// tslint:disable-next-line:no-bitwise
|
|
33
29
|
while ((mask ^ 0x7fffffff) !== 0) {
|
|
34
30
|
synchsafed = unsynchsafedRest & ~mask; // tslint:disable-line no-bitwise
|
|
35
|
-
|
|
36
31
|
synchsafed <<= 1; // tslint:disable-line no-bitwise
|
|
37
|
-
|
|
38
32
|
synchsafed |= unsynchsafedRest & mask; // tslint:disable-line no-bitwise
|
|
39
|
-
|
|
40
33
|
mask = (mask + 1 << 8) - 1; // tslint:disable-line no-bitwise
|
|
41
|
-
|
|
42
34
|
unsynchsafedRest = synchsafed;
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
return synchsafed;
|
|
46
37
|
};
|
|
47
38
|
|
package/build/node/module.js
CHANGED
|
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.encode = exports.decode = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* This functions turns a synchronisation-saved integer into regular one.
|
|
10
9
|
*/
|
|
11
10
|
const decode = synchsafed => {
|
|
12
11
|
let mask = 0x7f000000;
|
|
13
12
|
let unsynchsafed = 0;
|
|
14
|
-
|
|
15
13
|
while (mask !== 0) {
|
|
16
14
|
unsynchsafed >>= 1; // tslint:disable-line no-bitwise
|
|
17
|
-
|
|
18
15
|
unsynchsafed |= synchsafed & mask; // tslint:disable-line no-bitwise
|
|
19
|
-
|
|
20
16
|
mask >>= 8; // tslint:disable-line no-bitwise
|
|
21
17
|
}
|
|
22
18
|
|
|
@@ -25,28 +21,19 @@ const decode = synchsafed => {
|
|
|
25
21
|
/**
|
|
26
22
|
* This functions turns a regular integer into synchronisation-saved one.
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
24
|
exports.decode = decode;
|
|
31
|
-
|
|
32
25
|
const encode = unsynchsafed => {
|
|
33
26
|
let mask = 0x7f;
|
|
34
27
|
let synchsafed;
|
|
35
|
-
let unsynchsafedRest = unsynchsafed;
|
|
36
|
-
|
|
28
|
+
let unsynchsafedRest = unsynchsafed;
|
|
29
|
+
// tslint:disable-next-line:no-bitwise
|
|
37
30
|
while ((mask ^ 0x7fffffff) !== 0) {
|
|
38
31
|
synchsafed = unsynchsafedRest & ~mask; // tslint:disable-line no-bitwise
|
|
39
|
-
|
|
40
32
|
synchsafed <<= 1; // tslint:disable-line no-bitwise
|
|
41
|
-
|
|
42
33
|
synchsafed |= unsynchsafedRest & mask; // tslint:disable-line no-bitwise
|
|
43
|
-
|
|
44
34
|
mask = (mask + 1 << 8) - 1; // tslint:disable-line no-bitwise
|
|
45
|
-
|
|
46
35
|
unsynchsafedRest = synchsafed;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
return synchsafed;
|
|
50
38
|
};
|
|
51
|
-
|
|
52
39
|
exports.encode = encode;
|
package/package.json
CHANGED
|
@@ -10,30 +10,30 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@babel/runtime": "^7.
|
|
13
|
+
"@babel/runtime": "^7.19.4",
|
|
14
14
|
"tslib": "^2.4.0"
|
|
15
15
|
},
|
|
16
|
-
"description": "A
|
|
16
|
+
"description": "A module to decode and encode synchsafe integers.",
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@babel/cli": "^7.
|
|
19
|
-
"@babel/core": "^7.
|
|
18
|
+
"@babel/cli": "^7.19.3",
|
|
19
|
+
"@babel/core": "^7.19.6",
|
|
20
20
|
"@babel/plugin-external-helpers": "^7.18.6",
|
|
21
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
22
|
-
"@babel/preset-env": "^7.
|
|
21
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
22
|
+
"@babel/preset-env": "^7.19.4",
|
|
23
23
|
"@babel/register": "^7.18.9",
|
|
24
|
-
"@commitlint/cli": "^17.
|
|
25
|
-
"@commitlint/config-angular": "^17.0
|
|
24
|
+
"@commitlint/cli": "^17.1.2",
|
|
25
|
+
"@commitlint/config-angular": "^17.1.0",
|
|
26
26
|
"@rollup/plugin-babel": "^5.3.1",
|
|
27
27
|
"chai": "^4.3.6",
|
|
28
28
|
"commitizen": "^4.2.5",
|
|
29
29
|
"cz-conventional-changelog": "^3.3.0",
|
|
30
|
-
"eslint": "^8.
|
|
31
|
-
"eslint-config-holy-grail": "^52.0.
|
|
30
|
+
"eslint": "^8.26.0",
|
|
31
|
+
"eslint-config-holy-grail": "^52.0.33",
|
|
32
32
|
"grunt": "^1.5.3",
|
|
33
33
|
"grunt-cli": "^1.4.3",
|
|
34
34
|
"grunt-sh": "^0.2.0",
|
|
35
35
|
"husky": "^8.0.1",
|
|
36
|
-
"karma": "^6.4.
|
|
36
|
+
"karma": "^6.4.1",
|
|
37
37
|
"karma-chrome-launcher": "^3.1.1",
|
|
38
38
|
"karma-firefox-launcher": "^2.1.2",
|
|
39
39
|
"karma-mocha": "^2.0.1",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
"karma-sinon-chai": "^2.0.2",
|
|
43
43
|
"karma-webpack": "^5.0.0",
|
|
44
44
|
"load-grunt-config": "^4.0.1",
|
|
45
|
-
"mocha": "^10.
|
|
45
|
+
"mocha": "^10.1.0",
|
|
46
46
|
"prettier": "^2.7.1",
|
|
47
47
|
"pretty-quick": "^3.1.3",
|
|
48
48
|
"rimraf": "^3.0.2",
|
|
49
|
-
"rollup": "^2.
|
|
50
|
-
"sinon": "^14.0.
|
|
49
|
+
"rollup": "^2.79.1",
|
|
50
|
+
"sinon": "^14.0.1",
|
|
51
51
|
"sinon-chai": "^3.7.0",
|
|
52
|
-
"ts-loader": "^9.
|
|
53
|
-
"tsconfig-holy-grail": "^11.1.
|
|
52
|
+
"ts-loader": "^9.4.1",
|
|
53
|
+
"tsconfig-holy-grail": "^11.1.36",
|
|
54
54
|
"tslint": "^6.1.3",
|
|
55
|
-
"tslint-config-holy-grail": "^53.2.
|
|
56
|
-
"typescript": "^4.
|
|
55
|
+
"tslint-config-holy-grail": "^53.2.33",
|
|
56
|
+
"typescript": "^4.8.4",
|
|
57
57
|
"webpack": "^5.74.0"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"test": "grunt lint && grunt test"
|
|
81
81
|
},
|
|
82
82
|
"types": "build/es2019/module.d.ts",
|
|
83
|
-
"version": "6.0.
|
|
83
|
+
"version": "6.0.19"
|
|
84
84
|
}
|