initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
125
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/_process.js
generated
vendored
Normal file
125
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/_process.js
generated
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('_process:', function () {
|
||||
describe('Should process modifier', function () {
|
||||
describe('if value is a string', function () {
|
||||
function up (val) {
|
||||
return val.toUpperCase()
|
||||
}
|
||||
|
||||
it('using a single modifier', function () {
|
||||
Dot._process('k', up).should.eql('K')
|
||||
})
|
||||
|
||||
it('using an array of modifiers', function () {
|
||||
var v = 'k'
|
||||
Dot._process(v, [up]).should.eql('K')
|
||||
})
|
||||
})
|
||||
|
||||
describe('if value is an object', function () {
|
||||
function withReturn (val) {
|
||||
val.withReturn = 'return'
|
||||
return val
|
||||
}
|
||||
|
||||
function noReturn (val) {
|
||||
val.noReturn = 'no return'
|
||||
}
|
||||
|
||||
it('using a single modifier *with* return', function () {
|
||||
var a = {
|
||||
test: 1
|
||||
}
|
||||
|
||||
var expected = {
|
||||
test: 1,
|
||||
withReturn: 'return'
|
||||
}
|
||||
|
||||
var ret = Dot._process(a, withReturn)
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
})
|
||||
|
||||
it('using a single modifier *without* return', function () {
|
||||
var a = {
|
||||
test: 1
|
||||
}
|
||||
var expected = {
|
||||
test: 1,
|
||||
noReturn: 'no return'
|
||||
}
|
||||
var ret = Dot._process(a, noReturn)
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
})
|
||||
|
||||
it('using an array of modifiers *with* return and *without* return',
|
||||
function () {
|
||||
var a = {
|
||||
test: 1
|
||||
}
|
||||
|
||||
var expected = {
|
||||
test: 1,
|
||||
withReturn: 'return',
|
||||
noReturn: 'no return'
|
||||
}
|
||||
|
||||
var ret = Dot._process(a, [withReturn, noReturn])
|
||||
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
describe('if value is an array', function () {
|
||||
function withReturn (val) {
|
||||
val.push('return')
|
||||
return val
|
||||
}
|
||||
|
||||
function noReturn (val) {
|
||||
val.push('no return')
|
||||
}
|
||||
|
||||
it('using a single modifier *with* return', function () {
|
||||
var a = [1]
|
||||
|
||||
var expected = [1, 'return']
|
||||
|
||||
var ret = Dot._process(a, withReturn)
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
})
|
||||
|
||||
it('using a single modifier *without* return', function () {
|
||||
var a = [1]
|
||||
|
||||
var expected = [1, 'no return']
|
||||
|
||||
var ret = Dot._process(a, noReturn)
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
})
|
||||
|
||||
it('using an array of modifiers *with* return and *without* return',
|
||||
function () {
|
||||
var a = [1]
|
||||
|
||||
var expected = [1, 'return', 'no return']
|
||||
|
||||
var ret = Dot._process(a, [withReturn, noReturn])
|
||||
|
||||
a.should.eql(expected)
|
||||
ret.should.eql(expected)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
176
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/array_notation.js
generated
vendored
Normal file
176
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/array_notation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
'use strict'
|
||||
|
||||
/* jshint -W030 */
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Dotted Array notation', function () {
|
||||
var src
|
||||
|
||||
beforeEach(function () {
|
||||
src = {
|
||||
path: [{
|
||||
longitude: 5.512482166290283,
|
||||
latitude: 52.5006217956543
|
||||
}, {
|
||||
longitude: 5.512370586395264,
|
||||
latitude: 52.50059509277344
|
||||
}, {
|
||||
longitude: 5.512370586395264,
|
||||
latitude: 52.50059509277344
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
function runVariant (type) {
|
||||
var v = function (v) {
|
||||
if (type === 'bracket') {
|
||||
// rewrite some.prop.1 to some.prop[1]
|
||||
return v.replace(/\.(-?\d+)/g, '[$1]')
|
||||
} else {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
describe('can pick', function () {
|
||||
it('index', function () {
|
||||
Dot.pick(v('path.0'), src).should.eql(src.path[0])
|
||||
Dot.pick(v('path.2'), src).should.eql(src.path[2])
|
||||
;(typeof Dot.pick(v('path.9'), src)).should.eql('undefined')
|
||||
})
|
||||
|
||||
it('negative index', function () {
|
||||
Dot.pick(v('path.-1'), src).should.eql(src.path[2])
|
||||
Dot.pick(v('path.-2'), src).should.eql(src.path[1])
|
||||
Dot.pick(v('path.-3'), src).should.eql(src.path[0])
|
||||
;(typeof Dot.pick(v('path.-9'), src)).should.eql('undefined')
|
||||
})
|
||||
|
||||
it('non-array `-` prefixed properties', function () {
|
||||
var src = {
|
||||
path: {
|
||||
'-1': 'test1',
|
||||
'-2': 'test2',
|
||||
'-3': 'test3',
|
||||
'----key': 'test4'
|
||||
}
|
||||
}
|
||||
Dot.pick(v('path.-1'), src).should.eql('test1')
|
||||
Dot.pick(v('path.-2'), src).should.eql('test2')
|
||||
Dot.pick(v('path.-3'), src).should.eql('test3')
|
||||
Dot.pick(v('path.----key'), src).should.eql('test4')
|
||||
;(typeof Dot.pick(v('path.-9'), src)).should.eql('undefined')
|
||||
})
|
||||
|
||||
it('multiple indexes', function () {
|
||||
var src = {
|
||||
I: [
|
||||
{ am: [{ nes: ['ted'] }] },
|
||||
{ me: 'too' }
|
||||
]
|
||||
}
|
||||
|
||||
Dot.pick(v('I.0'), src).should.eql(src.I[0])
|
||||
Dot.pick(v('I.0.am'), src).should.eql(src.I[0].am)
|
||||
Dot.pick(v('I.0.am.0'), src).should.eql(src.I[0].am[0])
|
||||
Dot.pick(v('I.0.am.0.nes'), src).should.eql(src.I[0].am[0].nes)
|
||||
Dot.pick(v('I.0.am.0.nes.0'), src).should.eql('ted')
|
||||
Dot.pick(v('I.1.me'), src).should.eql('too')
|
||||
})
|
||||
})
|
||||
|
||||
describe('can set', function () {
|
||||
it('index at target', function () {
|
||||
var obj = { path: [] }
|
||||
|
||||
Dot.set(v('path.0'), 'test', obj)
|
||||
Dot.set(v('path.1'), 'test2', obj)
|
||||
|
||||
obj.path.should.be.instanceOf(Array)
|
||||
obj.should.eql({ path: ['test', 'test2'] })
|
||||
})
|
||||
|
||||
it('index and set undefined for empty indices', function () {
|
||||
var obj = { path: [] }
|
||||
|
||||
Dot.set(v('path.0'), 'test', obj)
|
||||
Dot.set(v('path.2'), 'test2', obj)
|
||||
|
||||
obj.path.should.be.instanceOf(Array)
|
||||
|
||||
// array will have an undefined index.
|
||||
JSON.stringify(obj)
|
||||
.should.eql(
|
||||
JSON.stringify({ path: ['test', undefined, 'test2'] })
|
||||
)
|
||||
|
||||
// to json will converted it to null
|
||||
JSON.stringify(obj).should.eql('{"path":["test",null,"test2"]}')
|
||||
})
|
||||
|
||||
it('index and overwrite existing values', function () {
|
||||
var obj = { path: ['still', 'shall', 'be', 'gone', 'here'] }
|
||||
|
||||
Dot.set(v('path.1'), 'x', obj)
|
||||
Dot.set(v('path.2'), 'xx', obj)
|
||||
Dot.set(v('path.3'), 'xxx', obj)
|
||||
|
||||
obj.should.eql({ path: ['still', 'x', 'xx', 'xxx', 'here'] })
|
||||
})
|
||||
})
|
||||
|
||||
describe('can remove', function () {
|
||||
it('indexes one by one leaving traces', function () {
|
||||
var obj = { path: ['still', 'shall', 'really', 'be', 'gone', 'here'] }
|
||||
|
||||
Dot.remove(v('path.1'), obj)
|
||||
Dot.remove(v('path.2'), obj)
|
||||
Dot.del(v('path.3'), obj) // use alias
|
||||
Dot.del(v('path.4'), obj)
|
||||
|
||||
// array will have an undefined index.
|
||||
JSON.stringify(obj)
|
||||
.should.eql(
|
||||
JSON.stringify({
|
||||
path: [
|
||||
'still', undefined, undefined, undefined, undefined, 'here'
|
||||
]
|
||||
})
|
||||
)
|
||||
|
||||
// to json will converted it to null
|
||||
JSON.stringify(obj).should.eql(
|
||||
'{"path":["still",null,null,null,null,"here"]}'
|
||||
)
|
||||
})
|
||||
|
||||
it('array of indexes leaving no traces', function () {
|
||||
var obj = { path: ['still', 'shall', 'really', 'be', 'gone', 'here'] }
|
||||
|
||||
Dot.remove([
|
||||
v('path.1'),
|
||||
v('path.2'),
|
||||
v('path.3'),
|
||||
v('path.4')], obj)
|
||||
|
||||
JSON.stringify(obj).should.eql('{"path":["still","here"]}')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe('with dot notation', function () {
|
||||
runVariant()
|
||||
})
|
||||
|
||||
// extra logic no real benefit.
|
||||
describe('with bracket notation', function () {
|
||||
runVariant('bracket')
|
||||
})
|
||||
|
||||
describe('Refuse to update __proto__', function () {
|
||||
var obj = { path: [] }
|
||||
|
||||
;(() => Dot.set('path[0].__proto__.toString', 'test', obj)).should.throw(/Refusing to update/)
|
||||
})
|
||||
})
|
||||
86
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/copy.js
generated
vendored
Normal file
86
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/copy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Copy:', function () {
|
||||
it('Should be able to copy properties', function () {
|
||||
var src = {
|
||||
name: 'John',
|
||||
stuff: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tgt = {
|
||||
name: 'Brandon'
|
||||
}
|
||||
|
||||
var srcExpected = JSON.parse(JSON.stringify(src))
|
||||
|
||||
var tgtExpected = {
|
||||
name: 'Brandon',
|
||||
copied: 'John',
|
||||
wanna: {
|
||||
haves: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copy object
|
||||
Dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt)
|
||||
|
||||
// copy string
|
||||
Dot.copy('name', 'copied', src, tgt)
|
||||
|
||||
src.should.eql(srcExpected)
|
||||
tgt.should.eql(tgtExpected)
|
||||
})
|
||||
|
||||
it('Should process modifiers', function () {
|
||||
function up (val) {
|
||||
val.brand = val.brand.toUpperCase()
|
||||
return val
|
||||
}
|
||||
|
||||
var src = {
|
||||
name: 'John',
|
||||
stuff: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tgt = {
|
||||
name: 'Brandon'
|
||||
}
|
||||
|
||||
var srcExpected = JSON.parse(JSON.stringify(src))
|
||||
|
||||
var tgtExpected = {
|
||||
name: 'Brandon',
|
||||
wanna: {
|
||||
haves: {
|
||||
phone: {
|
||||
brand: 'IPHONE',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt, up)
|
||||
|
||||
src.should.eql(srcExpected)
|
||||
tgt.should.eql(tgtExpected)
|
||||
})
|
||||
})
|
||||
30
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/array_deep_bug.json
generated
vendored
Normal file
30
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/array_deep_bug.json
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "array deep bug #10",
|
||||
"options": {
|
||||
"useArray": true
|
||||
},
|
||||
"input": {
|
||||
"a[0]": "A0",
|
||||
"a[1]": "A1",
|
||||
"a[2]": "A2",
|
||||
"a[3].b[0].c[0]": "A3B0C0",
|
||||
"a[3].b[0].c[1]": "A3B0C1"
|
||||
},
|
||||
"expected": {
|
||||
"a": [
|
||||
"A0",
|
||||
"A1",
|
||||
"A2",
|
||||
{
|
||||
"b": [
|
||||
{
|
||||
"c": [
|
||||
"A3B0C0",
|
||||
"A3B0C1"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
19
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/array_deep_bug2.json
generated
vendored
Normal file
19
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/array_deep_bug2.json
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "array deep bug2 #10",
|
||||
"options": {
|
||||
"useArray": true
|
||||
},
|
||||
"input": {
|
||||
"b.0.c.1": "b0c1",
|
||||
"b.0.c.2": "b0c2"
|
||||
},
|
||||
"expected": {
|
||||
"b" : [ {
|
||||
"c" : [
|
||||
null,
|
||||
"b0c1",
|
||||
"b0c2"
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
43
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/empty_array.json
generated
vendored
Normal file
43
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/empty_array.json
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "empty array",
|
||||
"input": [
|
||||
{
|
||||
"a": []
|
||||
},
|
||||
{
|
||||
"a.0": 1,
|
||||
"a": []
|
||||
},
|
||||
{
|
||||
"a": [],
|
||||
"a.0": 2
|
||||
},
|
||||
{
|
||||
"a.0.b": []
|
||||
},
|
||||
{
|
||||
"b.a.0": "b",
|
||||
"b.a": [],
|
||||
"b.a.1": "c"
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
{
|
||||
"a": []
|
||||
},
|
||||
{
|
||||
"a": [1]
|
||||
},
|
||||
{
|
||||
"a": [2]
|
||||
},
|
||||
{
|
||||
"a" : [ {"b" : [] } ]
|
||||
},
|
||||
{
|
||||
"b" : {
|
||||
"a": [ "b", "c" ]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
23
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/empty_object.json
generated
vendored
Normal file
23
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/empty_object.json
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "empty object",
|
||||
"input": [
|
||||
{
|
||||
"a.b": {}
|
||||
},
|
||||
{
|
||||
"a.b.c": 1,
|
||||
"a.b": {} ,
|
||||
"a.b.d": 2
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
{
|
||||
"a" : {"b" : {} }
|
||||
},
|
||||
{
|
||||
"a" : {
|
||||
"b": { "c": 1, "d": 2 }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
8
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/index.js
generated
vendored
Normal file
8
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module.exports = [
|
||||
require('./array_deep_bug'),
|
||||
require('./array_deep_bug2'),
|
||||
require('./empty_array'),
|
||||
require('./empty_object'),
|
||||
require('./object_deep_numeric_keys'),
|
||||
require('./object_deep_numeric_keys2')
|
||||
]
|
||||
30
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/object_deep_numeric_keys.json
generated
vendored
Normal file
30
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/object_deep_numeric_keys.json
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "object deep numeric keys",
|
||||
"options": {
|
||||
"useArray": false
|
||||
},
|
||||
"input": {
|
||||
"a[0]": "A0",
|
||||
"a[1]": "A1",
|
||||
"a[2]": "A2",
|
||||
"a[3].b[0].c[0]": "A3B0C0",
|
||||
"a[3].b[0].c[1]": "A3B0C1"
|
||||
},
|
||||
"expected": {
|
||||
"a": {
|
||||
"0": "A0",
|
||||
"1": "A1",
|
||||
"2": "A2",
|
||||
"3": {
|
||||
"b": {
|
||||
"0": {
|
||||
"c": {
|
||||
"0": "A3B0C0",
|
||||
"1": "A3B0C1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/object_deep_numeric_keys2.json
generated
vendored
Normal file
20
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/data/object_deep_numeric_keys2.json
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "object deep numeric keys 2 #10",
|
||||
"options": {
|
||||
"useArray": false
|
||||
},
|
||||
"input": {
|
||||
"b.0.c.1": "b0c1",
|
||||
"b.0.c.2": "b0c2"
|
||||
},
|
||||
"expected": {
|
||||
"b": {
|
||||
"0": {
|
||||
"c": {
|
||||
"1": "b0c1",
|
||||
"2": "b0c2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
237
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/dot-json.js
generated
vendored
Normal file
237
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/dot-json.js
generated
vendored
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var _s = require('underscore.string')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Object test:', function () {
|
||||
it('Should expand dotted keys', function () {
|
||||
var row = {
|
||||
id: 2,
|
||||
'contact.name.first': 'John',
|
||||
'contact.name.last': 'Doe',
|
||||
'contact.email': 'example@gmail.com',
|
||||
'contact.info.about.me': 'classified'
|
||||
}
|
||||
|
||||
Dot.object(row)
|
||||
|
||||
row.should.eql({
|
||||
id: 2,
|
||||
contact: {
|
||||
name: {
|
||||
first: 'John',
|
||||
last: 'Doe'
|
||||
},
|
||||
email: 'example@gmail.com',
|
||||
info: {
|
||||
about: {
|
||||
me: 'classified'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should expand dotted keys with array notation', function () {
|
||||
var row = {
|
||||
id: 2,
|
||||
'my.arr.0': 'one',
|
||||
'my.arr.1': 'two',
|
||||
'my.arr.2': 'three',
|
||||
'my.arr2[0]': 'one',
|
||||
'my.arr2[1]': 'two',
|
||||
'my.arr2[2]': 'three'
|
||||
}
|
||||
|
||||
Dot.object(row)
|
||||
|
||||
row.should.eql({
|
||||
id: 2,
|
||||
my: {
|
||||
arr: ['one', 'two', 'three'],
|
||||
arr2: ['one', 'two', 'three']
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should expand dotted keys with array notation with different separator', function () {
|
||||
var row = {
|
||||
id: 2,
|
||||
my_arr_0: 'one',
|
||||
my_arr_1: 'two',
|
||||
my_arr_2: 'three',
|
||||
'my_arr2[0]': 'one',
|
||||
'my_arr2[1]': 'two',
|
||||
'my_arr2[2]': 'three'
|
||||
}
|
||||
|
||||
new Dot('_').object(row)
|
||||
|
||||
row.should.eql({
|
||||
id: 2,
|
||||
my: {
|
||||
arr: ['one', 'two', 'three'],
|
||||
arr2: ['one', 'two', 'three']
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should allow keys with numbers', function () {
|
||||
var row = {
|
||||
id: 2,
|
||||
'0A': 'a',
|
||||
'0A9': 'b',
|
||||
'0B.1AB.A34C9': 'c'
|
||||
}
|
||||
|
||||
Dot.object(row)
|
||||
|
||||
row.should.eql({
|
||||
id: 2,
|
||||
'0A': 'a',
|
||||
'0A9': 'b',
|
||||
'0B': {
|
||||
'1AB': {
|
||||
A34C9: 'c'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should expand dotted string', function () {
|
||||
var tgt = {}
|
||||
|
||||
Dot.str('this.is.my.string', 'value', tgt)
|
||||
|
||||
tgt.should.eql({
|
||||
this: {
|
||||
is: {
|
||||
my: {
|
||||
string: 'value'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Dot.str Redefinition should fail', function () {
|
||||
var tgt = {
|
||||
already: 'set'
|
||||
}
|
||||
|
||||
;(function () {
|
||||
Dot.str('already.new', 'value', tgt)
|
||||
}).should.throw('Trying to redefine `already` which is a string')
|
||||
})
|
||||
|
||||
it('Dot.str should process a modifier', function () {
|
||||
var tgt = {}
|
||||
|
||||
Dot.str('this.is.my.string', 'value', tgt, _s.capitalize)
|
||||
|
||||
tgt.should.eql({
|
||||
this: {
|
||||
is: {
|
||||
my: {
|
||||
string: 'Value'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Dot.str should process multiple modifiers', function () {
|
||||
var tgt = {}
|
||||
|
||||
Dot.str(
|
||||
'this.is.my.string',
|
||||
' this is a test ',
|
||||
tgt, [_s.trim, _s.underscored]
|
||||
)
|
||||
|
||||
tgt.should.eql({
|
||||
this: {
|
||||
is: {
|
||||
my: {
|
||||
string: 'this_is_a_test'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Dot.object should process a modifier', function () {
|
||||
var row = {
|
||||
'page.title': 'my page',
|
||||
'page.slug': 'My Page'
|
||||
}
|
||||
|
||||
var mods = {
|
||||
'page.title': _s.titleize,
|
||||
'page.slug': _s.slugify
|
||||
}
|
||||
|
||||
Dot.object(row, mods)
|
||||
|
||||
row.should.eql({ page: { title: 'My Page', slug: 'my-page' } })
|
||||
})
|
||||
|
||||
it('should process root properties',
|
||||
function () {
|
||||
var row = {
|
||||
nr: 200,
|
||||
'nested.nr': 200
|
||||
}
|
||||
|
||||
var mods = {
|
||||
nr: [val => val * 2],
|
||||
'nested.nr': [val => val * 2]
|
||||
}
|
||||
|
||||
Dot.object(row, mods)
|
||||
|
||||
row.should.eql({ nr: 400, nested: { nr: 400 } })
|
||||
}
|
||||
)
|
||||
|
||||
it('should process non dot value with modifier when override is false',
|
||||
function () {
|
||||
var row = { title: 'my page', slug: 'My Page' }
|
||||
|
||||
var mods = { title: _s.titleize, slug: _s.slugify }
|
||||
|
||||
Dot.object(row, mods)
|
||||
|
||||
row.should.eql({ title: 'My Page', slug: 'my-page' })
|
||||
}
|
||||
)
|
||||
|
||||
it('Dot.object should process multiple modifiers', function () {
|
||||
var row = { 'page.name': ' My Page ' }
|
||||
|
||||
var mods = { 'page.name': [_s.trim, _s.underscored] }
|
||||
|
||||
Dot.object(row, mods)
|
||||
|
||||
row.should.eql({ page: { name: 'my_page' } })
|
||||
})
|
||||
|
||||
it('Dot.object should work with a different separator', function () {
|
||||
var row = { 'page=>name': ' My Page ' }
|
||||
|
||||
var mods = { 'page=>name': [_s.trim, _s.underscored] }
|
||||
|
||||
var dot = new Dot('=>', false)
|
||||
dot.object(row, mods)
|
||||
|
||||
row.should.eql({ page: { name: 'my_page' } })
|
||||
})
|
||||
|
||||
it('Dot.object should disallow to set __proto__', function () {
|
||||
var row = { '__proto__.toString': 'hi' }
|
||||
|
||||
var dot = new Dot()
|
||||
;(() => dot.object(row)).should.throw(/Refusing to update/)
|
||||
})
|
||||
})
|
||||
155
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/dot.js
generated
vendored
Normal file
155
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/dot.js
generated
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
var pkg = require('./fixtures/package.json')
|
||||
|
||||
describe('dot():', function () {
|
||||
var obj
|
||||
|
||||
// Dot.useBrackets = false;
|
||||
|
||||
beforeEach(function () {
|
||||
obj = {
|
||||
id: 'my-id',
|
||||
nes: {
|
||||
ted: {
|
||||
value: true
|
||||
}
|
||||
},
|
||||
other: {
|
||||
nested: {
|
||||
stuff: 5
|
||||
}
|
||||
},
|
||||
nested: {
|
||||
array: [
|
||||
{
|
||||
with: 'object1'
|
||||
},
|
||||
{
|
||||
and: 'object2'
|
||||
}
|
||||
]
|
||||
},
|
||||
some: {
|
||||
array: ['A', 'B']
|
||||
},
|
||||
ehrm: 123,
|
||||
dates: {
|
||||
first: new Date('Mon Oct 13 2014 00:00:00 GMT+0100 (BST)')
|
||||
},
|
||||
arrays: [
|
||||
[
|
||||
[
|
||||
{
|
||||
all: [
|
||||
[
|
||||
{
|
||||
the: [
|
||||
'way',
|
||||
['down']
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
it('Should be able to convert to dotted-key/value pairs', function () {
|
||||
var expected = {
|
||||
id: 'my-id',
|
||||
'nes.ted.value': true,
|
||||
'other.nested.stuff': 5,
|
||||
'nested.array[0].with': 'object1',
|
||||
'nested.array[1].and': 'object2',
|
||||
'some.array[0]': 'A',
|
||||
'some.array[1]': 'B',
|
||||
ehrm: 123,
|
||||
'dates.first': new Date('Mon Oct 13 2014 00:00:00 GMT+0100 (BST)'),
|
||||
'arrays[0][0][0].all[0][0].the[0]': 'way',
|
||||
'arrays[0][0][0].all[0][0].the[1][0]': 'down'
|
||||
}
|
||||
|
||||
Dot.dot(obj).should.eql(expected)
|
||||
})
|
||||
|
||||
it('dot() should equal object()', function () {
|
||||
Dot.object(Dot.dot(pkg)).should.eql(pkg)
|
||||
})
|
||||
|
||||
it('keepArray prevents arrays from being dotted', function () {
|
||||
var expected = {
|
||||
id: 'my-id',
|
||||
'nes.ted.value': true,
|
||||
'other.nested.stuff': 5,
|
||||
'nested.array': [{
|
||||
with: 'object1'
|
||||
}, {
|
||||
and: 'object2'
|
||||
}],
|
||||
'some.array': ['A', 'B'],
|
||||
ehrm: 123,
|
||||
'dates.first': new Date('Mon Oct 13 2014 00:00:00 GMT+0100 (BST)'),
|
||||
arrays: JSON.parse(JSON.stringify(obj.arrays))
|
||||
}
|
||||
|
||||
Dot.keepArray = true
|
||||
|
||||
Dot.dot(obj).should.eql(expected)
|
||||
|
||||
Dot.keepArray = false
|
||||
})
|
||||
|
||||
it('useBrackets wrap indexes with brackets', function () {
|
||||
var expected = {
|
||||
id: 'my-id',
|
||||
'nes.ted.value': true,
|
||||
'other.nested.stuff': 5,
|
||||
'nested.array[0].with': 'object1',
|
||||
'nested.array[1].and': 'object2',
|
||||
'some.array[0]': 'A',
|
||||
'some.array[1]': 'B',
|
||||
ehrm: 123,
|
||||
'dates.first': new Date('Mon Oct 13 2014 00:00:00 GMT+0100 (BST)'),
|
||||
'arrays[0][0][0].all[0][0].the[0]': 'way',
|
||||
'arrays[0][0][0].all[0][0].the[1][0]': 'down'
|
||||
}
|
||||
|
||||
Dot.dot(obj).should.eql(expected)
|
||||
})
|
||||
|
||||
it('useBrackets wrap indexes without brackets', function () {
|
||||
var expected = {
|
||||
id: 'my-id',
|
||||
'nes.ted.value': true,
|
||||
'other.nested.stuff': 5,
|
||||
'nested.array.0.with': 'object1',
|
||||
'nested.array.1.and': 'object2',
|
||||
'some.array.0': 'A',
|
||||
'some.array.1': 'B',
|
||||
ehrm: 123,
|
||||
'dates.first': new Date('Mon Oct 13 2014 00:00:00 GMT+0100 (BST)'),
|
||||
'arrays.0.0.0.all.0.0.the.0': 'way',
|
||||
'arrays.0.0.0.all.0.0.the.1.0': 'down'
|
||||
}
|
||||
|
||||
Dot.useBrackets = false
|
||||
Dot.dot(obj).should.eql(expected)
|
||||
Dot.useBrackets = true
|
||||
})
|
||||
|
||||
it('Always keeps empty arrays', function () {
|
||||
Dot.dot({ hello: [] }).should.eql({ hello: [] })
|
||||
Dot.dot({ hello: { world: [] } }).should.eql({ 'hello.world': [] })
|
||||
})
|
||||
|
||||
it('Always keeps empty objects', function () {
|
||||
Dot.dot({ hello: {} }).should.eql({ hello: {} })
|
||||
Dot.dot({ hello: { world: {} } }).should.eql({ 'hello.world': {} })
|
||||
})
|
||||
})
|
||||
46
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/fixtures/package.json
generated
vendored
Normal file
46
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/fixtures/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "dot-object",
|
||||
"description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.",
|
||||
"version": "1.1.0",
|
||||
"author": {
|
||||
"name": "Rob Halff",
|
||||
"email": "rob.halff@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/rhalff/dot-object.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/rhalff/dot-object/issues"
|
||||
},
|
||||
"main": "index",
|
||||
"bin": "./bin/dot-object",
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-beautify": "^1.1.2",
|
||||
"gulp-headerfooter": "^1.0.3",
|
||||
"gulp-jscs": "^2.0.0",
|
||||
"gulp-jshint": "^1.11.2",
|
||||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-uglify": "^1.2.0",
|
||||
"gulp-util": "^3.0.6",
|
||||
"jscs": "^2.0.0",
|
||||
"jscs-jsdoc": "1.1.0",
|
||||
"mocha": "2.x.x"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"filter",
|
||||
"transform",
|
||||
"dot notation",
|
||||
"dot"
|
||||
],
|
||||
"dependencies": {
|
||||
"commander": "^2.8.1",
|
||||
"glob": "^5.0.14"
|
||||
}
|
||||
}
|
||||
96
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/merge.js
generated
vendored
Normal file
96
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/merge.js
generated
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Should be able to merge:', function () {
|
||||
it('to property', function () {
|
||||
var link = {
|
||||
other: {
|
||||
three: 'Three Things',
|
||||
four: 'Four Things'
|
||||
},
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things'
|
||||
}
|
||||
}
|
||||
|
||||
var expected = {
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things',
|
||||
three: 'Three Things',
|
||||
four: 'Four Things'
|
||||
}
|
||||
}
|
||||
|
||||
Dot.move('other', 'things', link, true)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
|
||||
it('to nested property', function () {
|
||||
var link = {
|
||||
other: {
|
||||
three: 'Three Things',
|
||||
four: 'Four Things'
|
||||
},
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things',
|
||||
target: {
|
||||
im: 'already here'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var expected = {
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things',
|
||||
target: {
|
||||
im: 'already here',
|
||||
three: 'Three Things',
|
||||
four: 'Four Things'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dot.move('other', 'things.target', link, true)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
|
||||
it('array to array', function () {
|
||||
var link = {
|
||||
other: [
|
||||
'Three Things',
|
||||
'Four Things'
|
||||
],
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things',
|
||||
target: [
|
||||
'already here'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
var expected = {
|
||||
things: {
|
||||
one: 'One Thing',
|
||||
two: 'Two Things',
|
||||
target: [
|
||||
'already here',
|
||||
'Three Things',
|
||||
'Four Things'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Dot.move('other', 'things.target', link, true)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
})
|
||||
70
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/move.js
generated
vendored
Normal file
70
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/move.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Move test:', function () {
|
||||
it('Should be able to move properties', function () {
|
||||
var link = {
|
||||
id: '527423a65e380f0000588e47',
|
||||
source: '526dd5c6b4c4aa8770000001',
|
||||
target: '527402d6b15d1800008755cf',
|
||||
out: 'github',
|
||||
in: 'in'
|
||||
}
|
||||
|
||||
var expected = {
|
||||
id: '527423a65e380f0000588e47',
|
||||
source: { id: '526dd5c6b4c4aa8770000001', port: 'github' },
|
||||
target: { id: '527402d6b15d1800008755cf', port: 'in' }
|
||||
}
|
||||
|
||||
Dot.move('source', 'source.id', link)
|
||||
Dot.move('out', 'source.port', link)
|
||||
Dot.move('target', 'target.id', link)
|
||||
Dot.move('in', 'target.port', link)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
|
||||
it('Undefined properties should be ignored', function () {
|
||||
var link = {
|
||||
source: '526dd5c6b4c4aa8770000001',
|
||||
target: '527402d6b15d1800008755cf',
|
||||
out: 'github',
|
||||
in: 'in'
|
||||
}
|
||||
|
||||
var expected = {
|
||||
source: { id: '526dd5c6b4c4aa8770000001' },
|
||||
target: { port: 'in' },
|
||||
out: 'github'
|
||||
}
|
||||
|
||||
Dot.move('source', 'source.id', link)
|
||||
Dot.move('out.er.nope', 'source.port', link)
|
||||
Dot.move('target.bla.di.bla', 'target.id', link)
|
||||
Dot.move('in', 'target.port', link)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
|
||||
it('Should process modifiers', function () {
|
||||
var link = {
|
||||
source: 'one',
|
||||
target: 'two'
|
||||
}
|
||||
|
||||
var expected = {
|
||||
source: { id: 'ONE' },
|
||||
target: { port: 'TWO' }
|
||||
}
|
||||
|
||||
function up (val) { return val.toUpperCase() }
|
||||
|
||||
Dot.move('source', 'source.id', link, up)
|
||||
Dot.move('target', 'target.port', link, up)
|
||||
|
||||
link.should.eql(expected)
|
||||
})
|
||||
})
|
||||
93
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/override.js
generated
vendored
Normal file
93
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/override.js
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var _s = require('underscore.string')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Override test:', function () {
|
||||
it('Redefinition should _not_ fail if override is true', function () {
|
||||
var dot = new Dot('.', true)
|
||||
|
||||
var obj = {
|
||||
some: 'value',
|
||||
already: 'set'
|
||||
}
|
||||
|
||||
dot.str('already.new', 'value', obj)
|
||||
|
||||
obj.should.eql({
|
||||
some: 'value',
|
||||
already: { new: 'value' }
|
||||
})
|
||||
})
|
||||
|
||||
it('Redefinition should _not_ fail if override is true (2)', function () {
|
||||
var dot = new Dot('.', true)
|
||||
|
||||
var obj = {
|
||||
some: 'value',
|
||||
already: 'set'
|
||||
}
|
||||
|
||||
dot.str('already.new', 'value', obj)
|
||||
dot.str('some', 'new_value', obj)
|
||||
|
||||
obj.should.eql({
|
||||
some: 'new_value',
|
||||
already: { new: 'value' }
|
||||
})
|
||||
})
|
||||
|
||||
it('Allow override even when target is non-empty object',
|
||||
function () {
|
||||
var obj = {
|
||||
sample: {
|
||||
dotted: {
|
||||
bar: {
|
||||
baz: 'baz'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dot.override = true
|
||||
|
||||
Dot.str('sample.dotted.bar', { baz: 'boom' }, obj)
|
||||
|
||||
Dot.override = false
|
||||
|
||||
obj.should.eql({
|
||||
sample: {
|
||||
dotted: {
|
||||
bar: {
|
||||
baz: 'boom'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
it('should process non dot notation value with modifier if override is true',
|
||||
function () {
|
||||
var dot = new Dot('.', true)
|
||||
|
||||
var row = {
|
||||
title: 'my page',
|
||||
slug: 'My Page'
|
||||
}
|
||||
|
||||
var mods = {
|
||||
title: _s.titleize,
|
||||
slug: _s.slugify
|
||||
}
|
||||
|
||||
dot.object(row, mods)
|
||||
|
||||
row.should.eql({
|
||||
title: 'My Page',
|
||||
slug: 'my-page'
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
134
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/pick.js
generated
vendored
Normal file
134
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/pick.js
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
'use strict'
|
||||
|
||||
/* jshint -W030 */
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Pick:', function () {
|
||||
it('Should be able to pick a value', function () {
|
||||
var obj = {
|
||||
some: 'value',
|
||||
already: 'set'
|
||||
}
|
||||
|
||||
var val = Dot.pick('some', obj)
|
||||
|
||||
val.should.eql('value')
|
||||
})
|
||||
|
||||
it('Should be able to pick dotted value', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value'
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.pick('some.other', obj)
|
||||
|
||||
val.should.eql('value')
|
||||
})
|
||||
|
||||
it('Should be able to pick null properties', function () {
|
||||
var obj = {
|
||||
some: null
|
||||
}
|
||||
|
||||
var val = Dot.pick('some', obj)
|
||||
|
||||
;(val === null).should.equal(true)
|
||||
})
|
||||
|
||||
it('Should return undefined when picking an non-existing value', function () {
|
||||
var obj = {
|
||||
some: null
|
||||
}
|
||||
|
||||
var val = Dot.pick('other', obj)
|
||||
|
||||
;(val === undefined).should.equal(true)
|
||||
})
|
||||
|
||||
it('Should return undefined when picking an non-existing dotted value',
|
||||
function () {
|
||||
var obj = {
|
||||
some: null
|
||||
}
|
||||
|
||||
var val = Dot.pick('some.other', obj)
|
||||
|
||||
;(val === undefined).should.equal(true)
|
||||
}
|
||||
)
|
||||
|
||||
it("Should check down the object's prototype chain", function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value'
|
||||
}
|
||||
}
|
||||
|
||||
var objIns = Object.create(obj)
|
||||
|
||||
objIns.should.have.property('some')
|
||||
|
||||
var val = Dot.pick('some.other', objIns)
|
||||
val.should.be.instanceOf(String)
|
||||
})
|
||||
|
||||
it('Should be able to delete picked value', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value',
|
||||
foo: 'bar'
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.pick('some.foo', obj, true)
|
||||
|
||||
val.should.eql('bar')
|
||||
obj.should.eql({
|
||||
some: {
|
||||
other: 'value'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should be able to delete picked array value', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'bar', 'baz']
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.pick('some.arrayItems[1]', obj, true)
|
||||
|
||||
val.should.eql('bar')
|
||||
obj.should.eql({
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', , 'baz'] /* eslint-disable-line no-sparse-arrays */
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should be able to delete picked array value and reindex', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'bar', 'baz']
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.pick('some.arrayItems[1]', obj, true, true)
|
||||
|
||||
val.should.eql('bar')
|
||||
obj.should.eql({
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'baz']
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
80
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/remove.js
generated
vendored
Normal file
80
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/remove.js
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Remove/del:', function () {
|
||||
var obj
|
||||
var expected
|
||||
|
||||
beforeEach(function () {
|
||||
obj = {
|
||||
id: 'my-id',
|
||||
nes: {
|
||||
ted: {
|
||||
gone: 'value',
|
||||
still: 'there'
|
||||
}
|
||||
},
|
||||
ehrm: 123
|
||||
}
|
||||
|
||||
expected = {
|
||||
id: 'my-id',
|
||||
nes: {
|
||||
ted: {
|
||||
still: 'there'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('Should be able to remove() properties', function () {
|
||||
Dot.remove('ehrm', obj).should.equal(123)
|
||||
Dot.remove('nes.ted.gone', obj).should.equal('value')
|
||||
obj.should.eql(expected)
|
||||
})
|
||||
|
||||
it('Should be able to use del() alias', function () {
|
||||
Dot.del('ehrm', obj).should.equal(123)
|
||||
Dot.del('nes.ted.gone', obj).should.equal('value')
|
||||
obj.should.eql(expected)
|
||||
})
|
||||
|
||||
it('Should be able to remove() array item and reindex array', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'bar', 'baz']
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.remove('some.arrayItems[1]', obj, true, true)
|
||||
|
||||
val.should.eql('bar')
|
||||
obj.should.eql({
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'baz']
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('Should be handle being told to reindex an object by ignoring reindex rule', function () {
|
||||
var obj = {
|
||||
some: {
|
||||
other: 'value',
|
||||
arrayItems: ['foo', 'bar', 'baz']
|
||||
}
|
||||
}
|
||||
|
||||
var val = Dot.remove('some.other', obj, true, true)
|
||||
|
||||
val.should.eql('value')
|
||||
obj.should.eql({
|
||||
some: {
|
||||
arrayItems: ['foo', 'bar', 'baz']
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
63
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/str.js
generated
vendored
Normal file
63
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/str.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('str:', function () {
|
||||
it('can set root property', function () {
|
||||
Dot.str('b', 2, {
|
||||
a: 1
|
||||
}).should.deepEqual({
|
||||
a: 1,
|
||||
b: 2
|
||||
})
|
||||
})
|
||||
|
||||
it('can set nested property', function () {
|
||||
Dot.str('b.a', 2, {
|
||||
a: 1
|
||||
}).should.deepEqual({
|
||||
a: 1,
|
||||
b: {
|
||||
a: 2
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can set nested with array notation', function () {
|
||||
var obj = {
|
||||
a: 1
|
||||
}
|
||||
Dot.str('object.fields[0].subfield', 'value', obj)
|
||||
Dot.str('object.fields[1].subfield', 'value1', obj)
|
||||
|
||||
obj.should.deepEqual({
|
||||
a: 1,
|
||||
object: {
|
||||
fields: [
|
||||
{
|
||||
subfield: 'value'
|
||||
},
|
||||
{
|
||||
subfield: 'value1'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can set root level property regardless whether override is set', function () {
|
||||
Dot.str('a', 'b', {
|
||||
a: 1
|
||||
}).should.deepEqual({
|
||||
a: 'b'
|
||||
})
|
||||
})
|
||||
|
||||
it('cannot set __proto__ property', function () {
|
||||
(() => Dot.str('__proto__.toString', 'hi', {})).should.throw(
|
||||
/Refusing to update/
|
||||
);
|
||||
({}.toString().should.deepEqual('[object Object]'))
|
||||
})
|
||||
})
|
||||
42
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/test_data.js
generated
vendored
Normal file
42
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/test_data.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
var testData = require('./data')
|
||||
|
||||
function singleTest (dot, input, expected) {
|
||||
dot.object(input)
|
||||
JSON.stringify(input).should.eql(JSON.stringify(expected))
|
||||
}
|
||||
|
||||
describe('Test Data:', function () {
|
||||
var dot = new Dot()
|
||||
function testIt (test) {
|
||||
it(test.name, function () {
|
||||
if (test.options) {
|
||||
Object.keys(test.options).forEach(function (name) {
|
||||
dot[name] = test.options[name]
|
||||
})
|
||||
}
|
||||
|
||||
if (Array.isArray(test.input)) {
|
||||
if (
|
||||
!Array.isArray(test.expected) ||
|
||||
test.input.length !== test.expected.length
|
||||
) {
|
||||
throw Error('Input and Expected tests length must be the same')
|
||||
}
|
||||
test.expected.forEach((expected, i) => {
|
||||
singleTest(dot, test.input[i], expected)
|
||||
})
|
||||
} else {
|
||||
singleTest(dot, test.input, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// note with object() it is possible to cleanup, with del it is not.
|
||||
|
||||
testData.forEach(testIt)
|
||||
})
|
||||
28
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/test_transforms.js
generated
vendored
Normal file
28
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/test_transforms.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
var testData = [
|
||||
require('./transforms/twitter'),
|
||||
require('./transforms/contact')
|
||||
]
|
||||
|
||||
describe('Test Transforms:', function () {
|
||||
var dot = new Dot()
|
||||
function testIt (test) {
|
||||
it(test.name, function () {
|
||||
if (test.options) {
|
||||
Object.keys(test.options).forEach(function (name) {
|
||||
dot[name] = test.options[name]
|
||||
})
|
||||
}
|
||||
var tgt1 = {}
|
||||
var tgt2 = dot.transform(test.transform, test.input, tgt1)
|
||||
JSON.stringify(tgt1).should.eql(JSON.stringify(test.expected))
|
||||
JSON.stringify(tgt2).should.eql(JSON.stringify(test.expected))
|
||||
})
|
||||
}
|
||||
|
||||
testData.forEach(testIt)
|
||||
})
|
||||
81
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transfer.js
generated
vendored
Normal file
81
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transfer.js
generated
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('Transfer:', function () {
|
||||
it('Should be able to transfer properties', function () {
|
||||
var src = {
|
||||
name: 'John',
|
||||
stuff: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tgt = {
|
||||
name: 'Brandon'
|
||||
}
|
||||
|
||||
var srcExpected = { name: 'John', stuff: {} }
|
||||
|
||||
var tgtExpected = {
|
||||
name: 'Brandon',
|
||||
wanna: {
|
||||
haves: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt)
|
||||
|
||||
src.should.eql(srcExpected)
|
||||
tgt.should.eql(tgtExpected)
|
||||
})
|
||||
|
||||
it('Should process modifiers', function () {
|
||||
var up = function (val) {
|
||||
val.brand = val.brand.toUpperCase()
|
||||
return val
|
||||
}
|
||||
|
||||
var src = {
|
||||
name: 'John',
|
||||
stuff: {
|
||||
phone: {
|
||||
brand: 'iphone',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tgt = {
|
||||
name: 'Brandon'
|
||||
}
|
||||
|
||||
var srcExpected = { name: 'John', stuff: {} }
|
||||
|
||||
var tgtExpected = {
|
||||
name: 'Brandon',
|
||||
wanna: {
|
||||
haves: {
|
||||
phone: {
|
||||
brand: 'IPHONE',
|
||||
version: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt, up)
|
||||
|
||||
src.should.eql(srcExpected)
|
||||
tgt.should.eql(tgtExpected)
|
||||
})
|
||||
})
|
||||
26
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transforms/contact.json
generated
vendored
Normal file
26
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transforms/contact.json
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "Contact Transform",
|
||||
"input": {
|
||||
"id": 1,
|
||||
"contact": {
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"email": "example@test.com"
|
||||
}
|
||||
},
|
||||
"transform": {
|
||||
"id": "nr",
|
||||
"contact.firstName": "name.first",
|
||||
"contact.lastName": "name.last",
|
||||
"contact.email": "email"
|
||||
},
|
||||
"expected": {
|
||||
"nr": 1,
|
||||
"name": {
|
||||
"first": "John",
|
||||
"last": "Doe"
|
||||
},
|
||||
"email": "example@test.com"
|
||||
}
|
||||
}
|
||||
|
||||
174
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transforms/twitter.json
generated
vendored
Normal file
174
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/transforms/twitter.json
generated
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
{
|
||||
"name": "Twitter Transform",
|
||||
"input": {
|
||||
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...",
|
||||
"truncated": true,
|
||||
"in_reply_to_user_id": null,
|
||||
"in_reply_to_status_id": null,
|
||||
"favorited": false,
|
||||
"source": "<a href=\"http://twitter.com/\" rel=\"nofollow\">Twitter for iPhone</a>",
|
||||
"in_reply_to_screen_name": null,
|
||||
"in_reply_to_status_id_str": null,
|
||||
"id_str": "54691802283900928",
|
||||
"entities": {
|
||||
"user_mentions": [
|
||||
{
|
||||
"indices": [
|
||||
3,
|
||||
19
|
||||
],
|
||||
"screen_name": "PostGradProblem",
|
||||
"id_str": "271572434",
|
||||
"name": "PostGradProblems",
|
||||
"id": 271572434
|
||||
}
|
||||
],
|
||||
"urls": [
|
||||
|
||||
],
|
||||
"hashtags": [
|
||||
|
||||
]
|
||||
},
|
||||
"contributors": null,
|
||||
"retweeted": false,
|
||||
"in_reply_to_user_id_str": null,
|
||||
"place": null,
|
||||
"retweet_count": 4,
|
||||
"created_at": "Sun Apr 03 23:48:36 +0000 2011",
|
||||
"retweeted_status": {
|
||||
"text": "In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during company time. #PGP",
|
||||
"truncated": false,
|
||||
"in_reply_to_user_id": null,
|
||||
"in_reply_to_status_id": null,
|
||||
"favorited": false,
|
||||
"source": "<a href=\"http://www.hootsuite.com\" rel=\"nofollow\">HootSuite</a>",
|
||||
"in_reply_to_screen_name": null,
|
||||
"in_reply_to_status_id_str": null,
|
||||
"id_str": "54640519019642881",
|
||||
"entities": {
|
||||
"user_mentions": [
|
||||
|
||||
],
|
||||
"urls": [
|
||||
|
||||
],
|
||||
"hashtags": [
|
||||
{
|
||||
"text": "PGP",
|
||||
"indices": [
|
||||
130,
|
||||
134
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"contributors": null,
|
||||
"retweeted": false,
|
||||
"in_reply_to_user_id_str": null,
|
||||
"place": null,
|
||||
"retweet_count": 4,
|
||||
"created_at": "Sun Apr 03 20:24:49 +0000 2011",
|
||||
"user": {
|
||||
"notifications": null,
|
||||
"profile_use_background_image": true,
|
||||
"statuses_count": 31,
|
||||
"profile_background_color": "C0DEED",
|
||||
"followers_count": 3066,
|
||||
"profile_image_url": "http://a2.twimg.com/profile_images/1285770264/PGP_normal.jpg",
|
||||
"listed_count": 6,
|
||||
"profile_background_image_url": "http://a3.twimg.com/a/1301071706/images/themes/theme1/bg.png",
|
||||
"description": "",
|
||||
"screen_name": "PostGradProblem",
|
||||
"default_profile": true,
|
||||
"verified": false,
|
||||
"time_zone": null,
|
||||
"profile_text_color": "333333",
|
||||
"is_translator": false,
|
||||
"profile_sidebar_fill_color": "DDEEF6",
|
||||
"location": "",
|
||||
"id_str": "271572434",
|
||||
"default_profile_image": false,
|
||||
"profile_background_tile": false,
|
||||
"lang": "en",
|
||||
"friends_count": 21,
|
||||
"protected": false,
|
||||
"favourites_count": 0,
|
||||
"created_at": "Thu Mar 24 19:45:44 +0000 2011",
|
||||
"profile_link_color": "0084B4",
|
||||
"name": "PostGradProblems",
|
||||
"show_all_inline_media": false,
|
||||
"follow_request_sent": null,
|
||||
"geo_enabled": false,
|
||||
"profile_sidebar_border_color": "C0DEED",
|
||||
"url": null,
|
||||
"id": 271572434,
|
||||
"contributors_enabled": false,
|
||||
"following": null,
|
||||
"utc_offset": null
|
||||
},
|
||||
"id": 54640519019642880,
|
||||
"coordinates": null,
|
||||
"geo": null
|
||||
},
|
||||
"user": {
|
||||
"notifications": null,
|
||||
"profile_use_background_image": true,
|
||||
"statuses_count": 351,
|
||||
"profile_background_color": "C0DEED",
|
||||
"followers_count": 48,
|
||||
"profile_image_url": "http://a1.twimg.com/profile_images/455128973/gCsVUnofNqqyd6tdOGevROvko1_500_normal.jpg",
|
||||
"listed_count": 0,
|
||||
"profile_background_image_url": "http://a3.twimg.com/a/1300479984/images/themes/theme1/bg.png",
|
||||
"description": "watcha doin in my waters?",
|
||||
"screen_name": "OldGREG85",
|
||||
"default_profile": true,
|
||||
"verified": false,
|
||||
"time_zone": "Hawaii",
|
||||
"profile_text_color": "333333",
|
||||
"is_translator": false,
|
||||
"profile_sidebar_fill_color": "DDEEF6",
|
||||
"location": "Texas",
|
||||
"id_str": "80177619",
|
||||
"default_profile_image": false,
|
||||
"profile_background_tile": false,
|
||||
"lang": "en",
|
||||
"friends_count": 81,
|
||||
"protected": false,
|
||||
"favourites_count": 0,
|
||||
"created_at": "Tue Oct 06 01:13:17 +0000 2009",
|
||||
"profile_link_color": "0084B4",
|
||||
"name": "GG",
|
||||
"show_all_inline_media": false,
|
||||
"follow_request_sent": null,
|
||||
"geo_enabled": false,
|
||||
"profile_sidebar_border_color": "C0DEED",
|
||||
"url": null,
|
||||
"id": 80177619,
|
||||
"contributors_enabled": false,
|
||||
"following": null,
|
||||
"utc_offset": -36000
|
||||
},
|
||||
"id": 54691802283900930,
|
||||
"coordinates": null,
|
||||
"geo": null
|
||||
},
|
||||
"transform": {
|
||||
"text": "content",
|
||||
"created_at": "time",
|
||||
"user.location": "location",
|
||||
"user.favourites_count": "stats.favs",
|
||||
"user.followers_count": "stats.followers",
|
||||
"user.statuses_count": "stats.statuses"
|
||||
},
|
||||
"expected": {
|
||||
"content": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...",
|
||||
"time": "Sun Apr 03 23:48:36 +0000 2011",
|
||||
"location": "Texas",
|
||||
"stats": {
|
||||
"favs": 0,
|
||||
"followers": 48,
|
||||
"statuses": 351
|
||||
}
|
||||
}
|
||||
}
|
||||
68
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/useArray.js
generated
vendored
Normal file
68
dawidd6/action-download-artifact-v3/node_modules/dot-object/test/useArray.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict'
|
||||
|
||||
require('should')
|
||||
var Dot = require('../index')
|
||||
|
||||
describe('useArray:', function () {
|
||||
var dotObject, arrayObject, object
|
||||
var arrayObjectExpected, objectExpected, dotObjectExpected
|
||||
|
||||
beforeEach(function () {
|
||||
dotObject = {
|
||||
'a.0': 'value'
|
||||
}
|
||||
dotObjectExpected = {
|
||||
'a.0': 'value'
|
||||
}
|
||||
arrayObject = {
|
||||
a: ['value']
|
||||
}
|
||||
arrayObjectExpected = {
|
||||
a: ['value']
|
||||
}
|
||||
object = {
|
||||
a: {
|
||||
0: 'value'
|
||||
}
|
||||
}
|
||||
objectExpected = {
|
||||
a: {
|
||||
0: 'value'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('default is using array ', function () {
|
||||
var dotLocal = require('../index')
|
||||
arrayObjectExpected.should.eql(dotLocal.object(dotObject))
|
||||
})
|
||||
it('Should convert dot using arrays ', function () {
|
||||
Dot.useArray = true
|
||||
arrayObjectExpected.should.eql(Dot.object(dotObject))
|
||||
})
|
||||
it('Should convert dot not using arrays ', function () {
|
||||
Dot.useArray = false
|
||||
objectExpected.should.eql(Dot.object(dotObject))
|
||||
})
|
||||
it('Should convert object using arrays ', function () {
|
||||
Dot.useArray = true
|
||||
arrayObjectExpected.should.eql(Dot.object(dotObject))
|
||||
})
|
||||
it('Should convert dot using arrays and convert back equals source', function () {
|
||||
Dot.useArray = true
|
||||
Dot.useBrackets = false
|
||||
dotObjectExpected.should.eql(Dot.dot(Dot.object(dotObject)))
|
||||
})
|
||||
it('Should convert object using arrays and convert back equals source', function () {
|
||||
Dot.useArray = true
|
||||
arrayObjectExpected.should.eql(Dot.object(Dot.dot(object)))
|
||||
})
|
||||
it('Should convert dot not using arrays and convert back equals source', function () {
|
||||
Dot.useArray = false
|
||||
dotObjectExpected.should.eql(Dot.dot(Dot.object(dotObject)))
|
||||
})
|
||||
it('Should convert object not using arrays and convert back equals source', function () {
|
||||
Dot.useArray = false
|
||||
objectExpected.should.eql(Dot.object(Dot.dot(arrayObject)))
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue