{"id":22859996,"url":"https://github.com/reelyactive/reelib","last_synced_at":"2025-10-25T11:41:16.216Z","repository":{"id":31381652,"uuid":"34944717","full_name":"reelyactive/reelib","owner":"reelyactive","description":"Library for common reelyActive methods.  We believe in an open Internet of Things.","archived":false,"fork":false,"pushed_at":"2017-07-08T22:01:59.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-07T08:03:38.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reelyactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-02T11:06:55.000Z","updated_at":"2016-01-30T23:17:57.000Z","dependencies_parsed_at":"2022-08-17T18:55:18.635Z","dependency_job_id":null,"html_url":"https://github.com/reelyactive/reelib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/reelyactive/reelib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reelyactive%2Freelib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reelyactive%2Freelib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reelyactive%2Freelib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reelyactive%2Freelib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reelyactive","download_url":"https://codeload.github.com/reelyactive/reelib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reelyactive%2Freelib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268315900,"owners_count":24231059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T09:08:38.431Z","updated_at":"2025-10-25T11:41:16.161Z","avatar_url":"https://github.com/reelyactive.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"reelib\n======\n\nLibrary for common reelyActive methods.  Currently includes:\n- [time](#time-library)\n- [identifier](#identifier-library)\n- [tiraid](#tiraid-library)\n- [event](#event-library)\n- [reel](#reel-library)\n\n\nInstallation\n------------\n\n    npm install reelib\n\n\nHello reelib\n------------\n\n```javascript\nvar reelib = require('reelib');\n\nconsole.log(\"Right now it is \" + reelib.time.getCurrentISO());\n```\n\n\nTime library\n------------\n\nA numerical timestamp (milliseconds since January 1st, 1970, expressed as a number) is used for _internal_ processing and storage because this format is concise and allows for efficient storage, manipulations and comparisons.  An ISO8601 timestamp string is used for everything else because it's a human-readable global standard (ex: 2014-01-01T01:23:45.678Z).\n\nThe following are accessible under _reelib.time_:\n\n### toTimestamp(timestamp)\n\nConvert the given timestamp into the standard numerical format (number of milliseconds since January 1st, 1970, expressed as a number).  For example:\n\n    reelib.time.toTimestamp('2015-01-01T01:23:45.678Z');\n    reelib.time.toTimestamp(1420075425678);\n\nwould both yield 1420075425678.\n\n### getCurrent()\n\nGet the current timestamp in standard numerical format.\n\n### getCurrentISO()\n\nGet the current timestamp as an ISO8601 String.  For example:\n\n    reelib.time.getCurrentISO();\n\nwould yield something like '2015-01-01T01:23:45.678Z'.\n\n### getFuture(milliseconds)\n\nGet the timestamp, in standard numerical format, which is the given number of milliseconds in the future.\n\n### getCurrentOffset(timestamp)\n\nGet the offset, in milliseconds, between the current and given timestamps.  Accepts timestamps in both the standard numerical format and the String format.\n\n### toFuture(timestamp, milliseconds)\n\nReturn the given timestamp, in standard numerical format, advanced in the future by the given number of milliseconds.  Accepts timestamps in both the standard numerical format and the String format.\n\n### isInPast(timestamp)\n\nReturn whether the given timestamp is in the past.  Accepts timestamps in both the standard numerical format and the String format.\n\n### isEarlier(timestamp1, timestamp2)\n\nReturn whether the first given timestamp is earlier than the second.  Accepts timestamps in both the standard numerical format and the String format.\n\n### isValid(timestamp)\n\nReturns whether the given timestamp is valid or not.\n\n### toLocalTimeOfDay(timestamp)\n\nReturns the timestamp as a human-readable String representing the time of day on the local machine, ex: 12:34:56.789\n\n### toLocalTwelveDigitString(timestamp)\n\nReturns the timestamp as a twelve-digit String representing the time of day on the local machine, in the format YYMMDDHHMMSS, ex: 160101123456\n\n\nIdentifier library\n------------------\n\nIdentifiers have a type and a value, both of which are expressed as strings.  Some identifier types may have additional fields which are generated automatically by the toIdentifier() function.\n\nThe following are accessible under _reelib.identifier_:\n\n### Constants\n\n- EUI64: 'EUI-64'\n- RA28: 'RA-28'\n- ADVA48: 'ADVA-48'\n- RADIO_PAYLOAD: 'RadioPayload'\n- UNDEFINED: 'Undefined'\n\n### toIdentifier(type, value)\n\nCreate an identifier object with the given type and value.  For example:\n\n    {\n      type: 'ADVA-48',\n      value: 'fee150bada55'\n    }\n\n### toIdentifierString(identifier)\n\nConvert the given identifier (as string or object) to a _valid_ identifier string, if possible, otherwise return null.  A valid identifier string is:\n- hexadecimal characters only (no separators)\n- all lowercase\n- 16, 48, 64 or 128 bits in length\n\nFor example:\n\n     reelib.identifier.toIdentifierString('FE:E1:50:BA:DA:55');\n\nwould return 'fee150bada55'.\n\n### convertType(identifier, newType)\n\nCreate a new identifier object of the given type from the given identifier object.  For example:\n\n    var newIdentifier = reelib.identifier.convertType(oldIdentifier, TYPE_EUI64);\n\n### isValid(identifier)\n\nReturns whether the given identifier (as string or object) is valid or not.\n\n### isMatch(identifiers1, identifiers2)\n\nReturns whether there is a common identifier among the two inputs or not.  Each input can be either an identifier string or and array of identifier strings.\n\n\nTiraid library\n--------------\n\nTiraids have a [timestamp](#time-library), radioDecodings and an [identifier](#identifier-library).\n\nThe following are accessible under _reelib.tiraid_:\n\n### Constants\n\n- CSV_HEADER: 'Timestamp,TransmitterID,ReceiverID,RSSI'\n\n### getTimestamp(tiraid)\n\nReturns the timestamp of the given tiraid as per the [toTimestamp(timestamp)](#totimestamptimestamp) function.\n\n### getDeviceId(tiraid)\n\nReturns the device identifier of the given tiraid as per the [toIdentifierString(identifier)](#toidentifierstringidentifier) function.\n\n### getReceiverId(tiraid)\n\nReturns the strongest receiver identifier of the given tiraid as per the [toIdentifierString(identifier)](#toidentifierstringidentifier) function.\n\n### getAssociationIds(tiraid)\n\nReturns an array of all association identifiers embedded in the identifier payload of the given tiraid as per the [toIdentifierString(identifier)](#toidentifierstringidentifier) function.\n\n### getRSSI(tiraid)\n\nReturns the RSSI of the stongest receiver of the given tiraid.\n\n### isValid(tiraid)\n\nReturns whether the given tiraid is valid or not.\n\n### isReelyActiveTransmission(tiraid)\n\nReturns whether the given tiraid represents a wireless transmission by a reelyActive device or not.\n\n### toFlattened(tiraid)\n\nReturns the tiraid as a flattened object.  For example:\n\n    {\n      time: 1420075425678,\n      deviceId: \"001bc50940100000\",\n      receiverId: \"001bc50940800000\",\n      rssi: 128\n    }\n\n### toShortString(tiraid)\n\nReturns the tiraid as a human-readable String expected to fit on a single line (less than 80 characters).  For example:\n\n    dID: 001bc50940100000 rID: 001bc50940800000 rssi: 128 +1r at 01:23:45.678\n\n### toCSVString(tiraid)\n\nReturns the tiraid as a Comma-Separated Values (CSV) String.  For example:\n\n    01:23:45.678,001bc50940100000,001bc50940800000,128\n\n\nEvent library\n-------------\n\nEvents have an event (appearance, displacement, keep-alive or disappearance) and [tiraid](#tiraid-library).\n\nThe following are accessible under _reelib.event_:\n\n### Constants\n\n- APPEARANCE: 'appearance'\n- DISPLACEMENT: 'displacement'\n- KEEPALIVE: 'keep-alive'\n- DISAPPEARANCE: 'disappearance'\n- EVENTS_ROUTE_NAME: 'events'\n- CSV_HEADER: 'Timestamp,TransmitterID,ReceiverID,RSSI,Events'\n\n### getEvent(tiraid)\n\nReturns the type of event.\n\n### isValid(event)\n\nReturns whether the given event is valid or not.\n\n### isPass(event, accept, reject)\n\nReturns whether the given event meets the accept criteria while not meeting the reject criteria.  Each criteria is structured as follows:\n\n    {\n      deviceIds: [ /* IDs which meet the criteria */ ],\n      receiverIds: [ /* IDs which meet the criteria */ ],\n      rssi: { minimum: #, maximum: # }\n    }\n\nNot all of the above properties need to be included.  Note that no event can meet an empty criteria of {}!  To ignore either or both the accept/reject criteria, set these to _null_ instead.\n\n### postUpdate(options, event, callback)\n\nPOSTs the given event to a remote server.  The following options are supported (those shown are the defaults):\n\n    {\n      hostname: \"www.hyperlocalcontext.com\",\n      port: 80,\n      timeout: 10000,\n      logToConsole: false\n    }\n\nTo use a proxy server, add the following to the options:\n\n    proxy: 'http://my.proxy.name'\n\nThe callback returns the error (if any), the original event, and the response message (if any).  For example:\n\n```javascript\nvar options = { /* See above */ };\nvar event = { event: 'appearance', tiraid: tiraid };\n\nreelib.event.postUpdate(options, event, function(err, event, message) {\n  /* Handle the callback */\n});\n```\n\n### toFlattened(event)\n\nReturns the event as a flattened object.  For example:\n\n    {\n      event: \"appearance\",\n      time: 1420075425678,\n      deviceId: \"001bc50940100000\",\n      receiverId: \"001bc50940800000\",\n      rssi: 128\n    }\n\n### toCSVString(event)\n\nReturns the event as a Comma-Separated Values (CSV) String.  For example:\n\n    01:23:45.678,001bc50940100000,001bc50940800000,128,appearance\n\n### eventqueue\n\nA simple event queue class which accepts tiraids and generates events, if applicable, in the callback.  The following options are supported (those shown are the defaults):\n\n    {\n      keepAliveMilliseconds: 5000,\n      disappearanceMilliseconds: 15000\n    }\n\n```javascript\nvar options = { /* See above */ };\nvar eventqueue = new reelib.event.eventqueue(options);\n\neventqueue.insert(tiraid, function(event) {\n  if(event) { /* Do something with the event */ }\n});\n```\n\n\nReel library\n------------\n\nMethods specific to the reelyActive sensor reel architecture are contained in this library.\n\nThe following are accessible under _reelib.reel_:\n\n### putStatusUpdate(options, event, callback)\n\nPUTs the given reel status event to a remote server.  The following options are supported (those shown are the defaults):\n\n    {\n      hostname: \"www.hyperlocalcontext.com\",\n      port: 80,\n      timeout: 10000,\n      logToConsole: false\n    }\n\nTo use a proxy server, add the following to the options:\n\n    proxy: 'http://my.proxy.name'\n\nThe callback returns the error (if any), the original event, and the response message (if any).  For example:\n\n```javascript\nvar options = { /* See above */ };\nvar event = { type: 'reelceiverStatistics', ... };\n\nreelib.reel.putStatusUpdate(options, event, function(err, event, message) {\n  /* Handle the callback */\n});\n```\n\n\nWhat's next?\n------------\n\nThis is an active work in progress.  Expect regular changes and updates, as well as improved documentation!\n\n\nLicense\n-------\n\nMIT License\n\nCopyright (c) 2015-2016 reelyActive\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \nTHE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freelyactive%2Freelib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freelyactive%2Freelib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freelyactive%2Freelib/lists"}