Created
January 13, 2020 07:25
-
-
Save rozek/768b302fcaef22317ca448f464eb419a to your computer and use it in GitHub Desktop.
Bangle.js: lists installed applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Storage = require('Storage'); | |
let FileList = Storage.list(); | |
let segmentedAppSet = Object.create(null); | |
for (let i = 0, l = FileList.length; i < l; i++) { | |
let FileName = FileList[i]; | |
if (/^\+.*\x01$/.test(FileName)) { | |
segmentedAppSet[FileName.replace(/.$/,'')] = true; | |
} | |
} | |
let ApplicationList = []; | |
for (let i = 0, l = FileList.length; i < l; i++) { | |
let FileName = FileList[i]; | |
if ( | |
(FileName[0] === '+') && | |
! (FileName.slice(0,FileName.length-1) in segmentedAppSet) | |
) { | |
ApplicationList.push(FileName.slice(1)); | |
} | |
} | |
for (let FileName in segmentedAppSet) { | |
ApplicationList.push(FileName.slice(1)); | |
} | |
ApplicationList.sort(); | |
for (let i = 0, l = ApplicationList.length; i < l; i++) { | |
print(' -',ApplicationList[i].replace(/[\x00-\x1F\x7F-\x9F]/g, function (Match) { | |
let CharCode = Match.charCodeAt(0); | |
return '\\x' + (CharCode < 10 ? '0' : '') + CharCode.toString(16); | |
})); | |
} | |
print('done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment