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

@platform/cell.coord

Package Overview
Dependencies
Maintainers
1
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platform/cell.coord - npm Package Compare versions

Comparing version 0.5.35 to 0.6.0

25

lib/uri/Uri.d.ts

@@ -12,19 +12,14 @@ import { t } from '../common';

};
static string: {
ns: (id: string) => string;
cell: (ns: string, key: string) => string;
row: (ns: string, key: string) => string;
column: (ns: string, key: string) => string;
};
static generate: {
ns(args?: {
ns?: string | undefined;
}): string;
cell(args: {
key: string;
ns?: string | undefined;
}): string;
row(args: {
key: string;
ns?: string | undefined;
}): string;
column(args: {
key: string;
ns?: string | undefined;
}): string;
ns: (id?: string | undefined) => string;
cell: (key: string, ns?: string | undefined) => string;
row: (key: string, ns?: string | undefined) => string;
column: (key: string, ns?: string | undefined) => string;
};
}

62

lib/uri/Uri.js

@@ -6,2 +6,3 @@ "use strict";

var cell_1 = require("../cell");
var cuid = common_1.id.cuid;
var Uri = (function () {

@@ -70,23 +71,13 @@ function Uri() {

};
Uri.string = {
ns: function (id) { return toUri('ns', id); },
cell: function (ns, key) { return toUri('cell', ns, key); },
row: function (ns, key) { return toUri('row', ns, key); },
column: function (ns, key) { return toUri('col', ns, key); },
};
Uri.generate = {
ns: function (args) {
if (args === void 0) { args = {}; }
var ns = trimInput('ns', args.ns || common_1.id.cuid());
return "ns:" + ns;
},
cell: function (args) {
var ns = trimInput('ns', args.ns || common_1.id.cuid());
var key = args.key || common_1.id.shortid();
return "cell:" + ns + "!" + key;
},
row: function (args) {
var ns = trimInput('ns', args.ns || common_1.id.cuid());
var key = args.key || common_1.id.shortid();
return "row:" + ns + "!" + key;
},
column: function (args) {
var ns = trimInput('ns', args.ns || common_1.id.cuid());
var key = args.key || common_1.id.shortid();
return "col:" + ns + "!" + key;
},
ns: function (id) { return Uri.string.ns(id || cuid()); },
cell: function (key, ns) { return Uri.string.cell(ns || cuid(), key); },
row: function (key, ns) { return Uri.string.row(ns || cuid(), key); },
column: function (key, ns) { return Uri.string.column(ns || cuid(), key); },
};

@@ -96,5 +87,32 @@ return Uri;

exports.Uri = Uri;
function trimInput(prefix, input) {
var regex = new RegExp("^" + prefix + ":");
function trimPrefix(prefix, input) {
var regex = new RegExp("^" + prefix + ":+");
return input.trim().replace(regex, '');
}
var PREFIX_MAP = {
cell: 'CELL',
col: 'COLUMN',
row: 'ROW',
};
function toUri(prefix, id, suffix) {
id = id.trim();
id = id === ':' ? '' : id;
if (id) {
['ns', 'col', 'row', 'cell'].forEach(function (prefix) { return (id = trimPrefix(prefix, id)); });
}
if (!id) {
throw new Error("The \"" + prefix + "\" URI was not supplied with an ID.");
}
if (typeof suffix === 'string') {
suffix = suffix.replace(/^\!*/, '');
if (!suffix) {
throw new Error("The \"" + prefix + "\" URI was not supplied with a suffix key.");
}
var type = cell_1.cell.toType(suffix);
if (PREFIX_MAP[prefix] !== type) {
throw new Error("The \"" + prefix + ":\" URI was not supplied with a valid " + type + " key (given key \"" + suffix + "\").");
}
suffix = "!" + suffix;
}
return prefix + ":" + id + (suffix || '');
}
{
"name": "@platform/cell.coord",
"version": "0.5.35",
"version": "0.6.0",
"description": "Data types for working with grid cell cooridnates (eg 'A1').",

@@ -5,0 +5,0 @@ "main": "lib/index",

Sorry, the diff of this file is not supported yet

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