Skip to content

Commit

Permalink
Merge pull request #30 from Clever/SECNG-1235
Browse files Browse the repository at this point in the history
0.5.2
  • Loading branch information
mcab committed Jun 28, 2022
2 parents 16b9a8b + 445c579 commit 498134a
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 9 deletions.
11 changes: 8 additions & 3 deletions .circleci/config.yml
Expand Up @@ -12,10 +12,15 @@ jobs:
command: cd $HOME && git clone --depth 1 -v https://github.com/Clever/ci-scripts.git && cd ci-scripts && git show --oneline -s
name: Clone ci-scripts
- checkout
- setup_remote_docker
- run:
command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
name: Set up CircleCI artifacts directories
- run:
command: npm install
name: npm install
name: Set up .npmrc
command: |
sed -i.bak s/\${npm_auth_token}/$NPM_TOKEN/ .npmrc_docker
mv .npmrc_docker .npmrc
- run: npm ci
- run: make build
- run: make test
- run: if [ "${CIRCLE_BRANCH}" == "master" ]; then $HOME/ci-scripts/circleci/npm-publish $NPM_TOKEN .; fi;
1 change: 1 addition & 0 deletions .npmignore
@@ -1,3 +1,4 @@
node_modules
*~
.*.swp
.npmrc_docker
5 changes: 5 additions & 0 deletions .npmrc_docker
@@ -0,0 +1,5 @@
ca = null
//registry.npmjs.org/:_authToken=${npm_auth_token}
@clever:registry=https://registry.npmjs.org/
always-auth = true
strict-ssl = true
7 changes: 3 additions & 4 deletions Makefile
@@ -1,4 +1,4 @@
.PHONY: build test publish
.PHONY: build test tag

TESTS=$(shell cd test && ls *.coffee | sed s/\.coffee$$//)

Expand All @@ -16,13 +16,12 @@ $(TESTS): build
@echo $(LIBS)
node_modules/mocha/bin/mocha --bail --timeout 60000 --compilers coffee:coffee-script test/$@.coffee

publish:
tag:
$(eval VERSION := $(shell grep version package.json | sed -ne 's/^[ ]*"version":[ ]*"\([0-9\.]*\)",/\1/p';))
@echo \'$(VERSION)\'
$(eval REPLY := $(shell read -p "Publish and tag as $(VERSION)? " -n 1 -r; echo $$REPLY))
$(eval REPLY := $(shell read -p "Tag as $(VERSION)? " -n 1 -r; echo $$REPLY))
@echo \'$(REPLY)\'
@if [[ $(REPLY) =~ ^[Yy]$$ ]]; then \
npm publish; \
git tag -a v$(VERSION) -m "version $(VERSION)"; \
git push --tags; \
fi
6 changes: 5 additions & 1 deletion README.coffee.md
@@ -1,9 +1,13 @@
# Notice

This repo is not actively maintained by Clever. We currently do not have a drop-in replacement to recommend.

# underscore.deep

Underscore.deep is a collection of Underscore mixins that operate on nested
objects.

This README is written in [Literate CoffeeScript](http://coffeescript.org/#literate) as a [Mocha](http://visionmedia.github.io/mocha/) test suite, so you can execute all of the examples - just run:
This README is written in [Literate CoffeeScript](https://coffeescript.org/#literate) as a [Mocha](https://mochajs.org/) test suite, so you can execute all of the examples - just run:

```
make README.coffee.md
Expand Down
166 changes: 166 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "underscore.deep",
"version": "0.5.1",
"version": "0.5.2",
"description": "Underscore mixins for deeply nested objects",
"main": "underscore.deep.js",
"engines": {
Expand Down
12 changes: 12 additions & 0 deletions test/deepClone.coffee
Expand Up @@ -43,3 +43,15 @@ describe '_.deepClone', ->

it "doesn't clone class intances", ->
assert.strictEqual copy.structs.instance, orig.structs.instance

it "correcly copies truthy and falsy boolean objects", ->
bools =
truthy_true: new Boolean(true)
truthy_anything: new Boolean("anything")
falsy_empty: new Boolean()
falsy_false: new Boolean(false)
falsy_zero: new Boolean(0)
copied_bools = _.deepClone(bools)

assert.deepEqual bools, copied_bools
assert.notStrictEqual bools, copied_bools
2 changes: 2 additions & 0 deletions underscore.deep.coffee
Expand Up @@ -22,6 +22,8 @@ module.exports =
return object if not object?

# normalizing primitives e.g. if someone did new String('aaa'), or new Number('444');
# boolean objects are very weird; explicitly case to force false values.
return new Boolean() if object instanceof Boolean && object.valueOf() == false
return new type object for type in [Date, Number, String, Boolean] when object instanceof type

# for arrays clone each element of it
Expand Down

0 comments on commit 498134a

Please sign in to comment.