完成less的修改
parent
d0a6dd21f1
commit
6e3b874108
|
@ -1,8 +1,7 @@
|
||||||
.vscode
|
.vscode
|
||||||
node_modules/
|
node_modules/
|
||||||
dist
|
dist
|
||||||
benchmark
|
test
|
||||||
bin
|
|
||||||
|
|
||||||
*.sublime-project
|
*.sublime-project
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import Es from 'esbuild'
|
||||||
|
import fs from 'iofs'
|
||||||
|
|
||||||
|
Es.buildSync({
|
||||||
|
entryPoints: ['src/less-node/index.js'],
|
||||||
|
outdir: 'dist',
|
||||||
|
platform: 'node',
|
||||||
|
format: 'esm',
|
||||||
|
// minify: true,
|
||||||
|
bundle: true,
|
||||||
|
target: 'node12'
|
||||||
|
})
|
|
@ -1,14 +0,0 @@
|
||||||
import pkg from './../package.json' assert { type: 'json' }
|
|
||||||
|
|
||||||
export default `/**
|
|
||||||
* Less - ${pkg.description} v${pkg.version}
|
|
||||||
* http://lesscss.org
|
|
||||||
*
|
|
||||||
* Copyright (c) 2009-${new Date().getFullYear()}, ${pkg.author.name} <${
|
|
||||||
pkg.author.email
|
|
||||||
}>
|
|
||||||
* Licensed under the ${pkg.license} License.
|
|
||||||
*
|
|
||||||
* @license ${pkg.license}
|
|
||||||
*/
|
|
||||||
`
|
|
|
@ -1,90 +0,0 @@
|
||||||
import rollup from 'rollup'
|
|
||||||
import typescript from 'rollup-plugin-typescript2'
|
|
||||||
import commonjs from '@rollup/plugin-commonjs'
|
|
||||||
import json from '@rollup/plugin-json'
|
|
||||||
import resolve from '@rollup/plugin-node-resolve'
|
|
||||||
import terser from 'rollup-plugin-terser'
|
|
||||||
import banner from './banner'
|
|
||||||
import path from 'path')
|
|
||||||
|
|
||||||
const rootPath = path.join(__dirname, '..')
|
|
||||||
|
|
||||||
import minimist from 'minimist'
|
|
||||||
|
|
||||||
const args = minimist(process.argv.slice(2))
|
|
||||||
|
|
||||||
let outDir = args.dist ? './dist' : './tmp'
|
|
||||||
|
|
||||||
async function buildBrowser() {
|
|
||||||
let bundle = await rollup.rollup({
|
|
||||||
input: './src/less-browser/bootstrap.js',
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: 'less.js',
|
|
||||||
format: 'umd'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: 'less.min.js',
|
|
||||||
format: 'umd'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
resolve(),
|
|
||||||
commonjs(),
|
|
||||||
json(),
|
|
||||||
typescript({
|
|
||||||
verbosity: 2,
|
|
||||||
tsconfigDefaults: {
|
|
||||||
compilerOptions: {
|
|
||||||
allowJs: true,
|
|
||||||
sourceMap: true,
|
|
||||||
target: 'ES5'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
include: ['*.ts', '**/*.ts', '*.js', '**/*.js'],
|
|
||||||
exclude: ['node_modules'] // only transpile our source code
|
|
||||||
}),
|
|
||||||
terser({
|
|
||||||
compress: true,
|
|
||||||
include: [/^.+\.min\.js$/],
|
|
||||||
output: {
|
|
||||||
comments: function (node, comment) {
|
|
||||||
if (comment.type == 'comment2') {
|
|
||||||
// preserve banner
|
|
||||||
return /@license/i.test(comment.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!args.out || args.out.indexOf('less.js') > -1) {
|
|
||||||
const file = args.out || `${outDir}/less.js`
|
|
||||||
console.log(`Writing ${file}...`)
|
|
||||||
await bundle.write({
|
|
||||||
file: path.join(rootPath, file),
|
|
||||||
format: 'umd',
|
|
||||||
name: 'less',
|
|
||||||
banner
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args.out || args.out.indexOf('less.min.js') > -1) {
|
|
||||||
const file = args.out || `${outDir}/less.min.js`
|
|
||||||
console.log(`Writing ${file}...`)
|
|
||||||
await bundle.write({
|
|
||||||
file: path.join(rootPath, file),
|
|
||||||
format: 'umd',
|
|
||||||
name: 'less',
|
|
||||||
sourcemap: true,
|
|
||||||
banner
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function build() {
|
|
||||||
await buildBrowser()
|
|
||||||
}
|
|
||||||
|
|
||||||
build()
|
|
105
package.json
105
package.json
|
@ -1,101 +1,24 @@
|
||||||
{
|
{
|
||||||
"name": "less",
|
"name": "@bytedo/less",
|
||||||
"version": "4.1.3",
|
"version": "0.0.1",
|
||||||
"description": "Leaner CSS",
|
"type": "module",
|
||||||
|
"description": "less精简版",
|
||||||
"homepage": "http://lesscss.org",
|
"homepage": "http://lesscss.org",
|
||||||
"author": {
|
"author": "yutent",
|
||||||
"name": "Alexis Sellier",
|
|
||||||
"email": "self@cloudhead.net"
|
|
||||||
},
|
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"The Core Less Team"
|
"The Core Less Team"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/less/less.js.git"
|
"url": "https://github.com/bytedo/less.git"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"main": "dist/index.js",
|
||||||
"lessc": "./bin/lessc"
|
"files": [
|
||||||
},
|
"dist/*"
|
||||||
"main": "index",
|
],
|
||||||
"module": "./lib/less-node/index",
|
|
||||||
"directories": {
|
|
||||||
"test": "./test"
|
|
||||||
},
|
|
||||||
"browser": "./dist/less.js",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test",
|
"build": "node build.js"
|
||||||
"grunt": "grunt",
|
|
||||||
"lint": "eslint '**/*.{ts,js}'",
|
|
||||||
"lint:fix": "eslint '**/*.{ts,js}' --fix",
|
|
||||||
"build": "npm-run-all clean compile",
|
|
||||||
"clean": "shx rm -rf ./lib tsconfig.tsbuildinfo",
|
|
||||||
"compile": "tsc -p tsconfig.build.json",
|
|
||||||
"copy:root": "shx cp -rf ./dist ../../",
|
|
||||||
"dev": "tsc -p tsconfig.build.json -w",
|
|
||||||
"prepublishOnly": "grunt dist"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"errno": "^0.1.1",
|
|
||||||
"graceful-fs": "^4.1.2",
|
|
||||||
"image-size": "~0.5.0",
|
|
||||||
"make-dir": "^2.1.0",
|
|
||||||
"mime": "^1.4.1",
|
|
||||||
"needle": "^3.1.0",
|
|
||||||
"source-map": "~0.6.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@less/test-data": "^4.1.0",
|
|
||||||
"@less/test-import-module": "^4.0.0",
|
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
|
||||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
|
||||||
"@typescript-eslint/parser": "^4.28.0",
|
|
||||||
"benny": "^3.6.12",
|
|
||||||
"bootstrap-less-port": "0.3.0",
|
|
||||||
"chai": "^4.2.0",
|
|
||||||
"cross-env": "^7.0.3",
|
|
||||||
"diff": "^3.2.0",
|
|
||||||
"eslint": "^7.29.0",
|
|
||||||
"fs-extra": "^8.1.0",
|
|
||||||
"git-rev": "^0.2.1",
|
|
||||||
"globby": "^10.0.1",
|
|
||||||
"grunt": "^1.0.4",
|
|
||||||
"grunt-cli": "^1.3.2",
|
|
||||||
"grunt-contrib-clean": "^1.0.0",
|
|
||||||
"grunt-contrib-connect": "^1.0.2",
|
|
||||||
"grunt-eslint": "^23.0.0",
|
|
||||||
"grunt-saucelabs": "^9.0.1",
|
|
||||||
"grunt-shell": "^1.3.0",
|
|
||||||
"html-template-tag": "^3.2.0",
|
|
||||||
"jit-grunt": "^0.10.0",
|
|
||||||
"less-plugin-autoprefix": "^1.5.1",
|
|
||||||
"less-plugin-clean-css": "^1.5.1",
|
|
||||||
"minimist": "^1.2.0",
|
|
||||||
"mocha": "^6.2.1",
|
|
||||||
"mocha-headless-chrome": "^4.0.0",
|
|
||||||
"mocha-teamcity-reporter": "^3.0.0",
|
|
||||||
"nock": "^11.8.2",
|
|
||||||
"npm-run-all": "^4.1.5",
|
|
||||||
"performance-now": "^0.2.0",
|
|
||||||
"phin": "^2.2.3",
|
|
||||||
"promise": "^7.1.1",
|
|
||||||
"read-glob": "^3.0.0",
|
|
||||||
"resolve": "^1.17.0",
|
|
||||||
"rollup": "^2.52.2",
|
|
||||||
"rollup-plugin-terser": "^5.1.1",
|
|
||||||
"rollup-plugin-typescript2": "^0.29.0",
|
|
||||||
"semver": "^6.3.0",
|
|
||||||
"shx": "^0.3.2",
|
|
||||||
"time-grunt": "^1.3.0",
|
|
||||||
"ts-node": "^9.1.1",
|
|
||||||
"typescript": "^4.3.4",
|
|
||||||
"uikit": "2.27.4"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"compile less",
|
"compile less",
|
||||||
|
@ -121,9 +44,5 @@
|
||||||
"stylesheet",
|
"stylesheet",
|
||||||
"variables in css",
|
"variables in css",
|
||||||
"css less"
|
"css less"
|
||||||
],
|
]
|
||||||
"dependencies": {
|
|
||||||
"copy-anything": "^2.0.1",
|
|
||||||
"parse-node-version": "^1.0.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from './fs'
|
import fs from 'fs'
|
||||||
import AbstractFileManager from '../less/environment/abstract-file-manager.js'
|
import AbstractFileManager from '../less/environment/abstract-file-manager.js'
|
||||||
|
|
||||||
const FileManager = function () {}
|
export default class FileManager extends AbstractFileManager {
|
||||||
FileManager.prototype = Object.assign(new AbstractFileManager(), {
|
|
||||||
supports() {
|
supports() {
|
||||||
return true
|
return true
|
||||||
},
|
}
|
||||||
|
|
||||||
supportsSync() {
|
supportsSync() {
|
||||||
return true
|
return true
|
||||||
},
|
}
|
||||||
|
|
||||||
loadFile(filename, currentDirectory, options, environment, callback) {
|
loadFile(filename, currentDirectory, options, environment, callback) {
|
||||||
let fullFilename
|
let fullFilename
|
||||||
|
@ -142,12 +141,10 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||||
}
|
}
|
||||||
})(0)
|
})(0)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
loadFileSync(filename, currentDirectory, options, environment) {
|
loadFileSync(filename, currentDirectory, options, environment) {
|
||||||
options.syncImport = true
|
options.syncImport = true
|
||||||
return this.loadFile(filename, currentDirectory, options, environment)
|
return this.loadFile(filename, currentDirectory, options, environment)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
export default FileManager
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
export default fs from 'graceful-fs'
|
|
||||||
|
|
||||||
// export default fs from 'fs'
|
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
import environment from './environment'
|
// import environment from './environment'
|
||||||
import FileManager from './file-manager'
|
import FileManager from './file-manager'
|
||||||
import UrlFileManager from './url-file-manager'
|
import UrlFileManager from './url-file-manager'
|
||||||
import createFromEnvironment from '../less'
|
import createFromEnvironment from '../less'
|
||||||
const less = createFromEnvironment(environment, [
|
const less = createFromEnvironment({}, [
|
||||||
new FileManager(),
|
new FileManager(),
|
||||||
new UrlFileManager()
|
new UrlFileManager()
|
||||||
])
|
])
|
||||||
import lesscHelper from './lessc-helper'
|
|
||||||
import PluginLoader from './plugin-loader'
|
import PluginLoader from './plugin-loader'
|
||||||
import fs from './fs.js'
|
import fs from 'fs'
|
||||||
import options from '../less/default-options'
|
import options from '../less/default-options'
|
||||||
import imageSize from './image-size'
|
|
||||||
|
|
||||||
// allow people to create less with their own environment
|
// allow people to create less with their own environment
|
||||||
less.createFromEnvironment = createFromEnvironment
|
less.createFromEnvironment = createFromEnvironment
|
||||||
less.lesscHelper = lesscHelper
|
|
||||||
less.PluginLoader = PluginLoader
|
less.PluginLoader = PluginLoader
|
||||||
less.fs = fs
|
less.fs = fs
|
||||||
less.FileManager = FileManager
|
less.FileManager = FileManager
|
||||||
|
@ -23,7 +20,4 @@ less.UrlFileManager = UrlFileManager
|
||||||
// Set up options
|
// Set up options
|
||||||
less.options = options
|
less.options = options
|
||||||
|
|
||||||
// provide image-size functionality
|
|
||||||
imageSize(less.environment)
|
|
||||||
|
|
||||||
export default less
|
export default less
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
// lessc_helper.js
|
// lessc_helper.js
|
||||||
//
|
//
|
||||||
// helper functions for lessc
|
// helper functions for lessc
|
||||||
const lessc_helper = {
|
|
||||||
// Stylize a string
|
export function stylize(str, style) {
|
||||||
stylize: function (str, style) {
|
|
||||||
const styles = {
|
const styles = {
|
||||||
reset: [0, 0],
|
reset: [0, 0],
|
||||||
bold: [1, 22],
|
bold: [1, 22],
|
||||||
|
@ -15,10 +14,10 @@ const lessc_helper = {
|
||||||
grey: [90, 39]
|
grey: [90, 39]
|
||||||
}
|
}
|
||||||
return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`
|
return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`
|
||||||
},
|
}
|
||||||
|
|
||||||
// Print command line options
|
// Print command line options
|
||||||
printUsage: function () {
|
export function printUsage() {
|
||||||
console.log(
|
console.log(
|
||||||
'usage: lessc [option option=parameter ...] <source> [destination]'
|
'usage: lessc [option option=parameter ...] <source> [destination]'
|
||||||
)
|
)
|
||||||
|
@ -52,9 +51,7 @@ const lessc_helper = {
|
||||||
console.log(
|
console.log(
|
||||||
' --insecure Allows imports from insecure https hosts.'
|
' --insecure Allows imports from insecure https hosts.'
|
||||||
)
|
)
|
||||||
console.log(
|
console.log(' -v, --version Prints version number and exit.')
|
||||||
' -v, --version Prints version number and exit.'
|
|
||||||
)
|
|
||||||
console.log(' --verbose Be verbose.')
|
console.log(' --verbose Be verbose.')
|
||||||
console.log(
|
console.log(
|
||||||
' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).'
|
' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).'
|
||||||
|
@ -137,9 +134,7 @@ const lessc_helper = {
|
||||||
console.log(' --disable-plugin-rule Disallow @plugin statements')
|
console.log(' --disable-plugin-rule Disallow @plugin statements')
|
||||||
console.log('')
|
console.log('')
|
||||||
console.log('-------------------------- Deprecated ----------------')
|
console.log('-------------------------- Deprecated ----------------')
|
||||||
console.log(
|
console.log(' -sm=on|off Legacy parens-only math. Use --math')
|
||||||
' -sm=on|off Legacy parens-only math. Use --math'
|
|
||||||
)
|
|
||||||
console.log(' --strict-math=on|off ')
|
console.log(' --strict-math=on|off ')
|
||||||
console.log('')
|
console.log('')
|
||||||
console.log(' --line-numbers=TYPE Outputs filename and line numbers.')
|
console.log(' --line-numbers=TYPE Outputs filename and line numbers.')
|
||||||
|
@ -168,12 +163,3 @@ const lessc_helper = {
|
||||||
console.log('Report bugs to: http://github.com/less/less.js/issues')
|
console.log('Report bugs to: http://github.com/less/less.js/issues')
|
||||||
console.log('Home page: <http://lesscss.org/>')
|
console.log('Home page: <http://lesscss.org/>')
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Exports helper functions
|
|
||||||
// eslint-disable-next-line no-prototype-builtins
|
|
||||||
for (const h in lessc_helper) {
|
|
||||||
if (lessc_helper.hasOwnProperty(h)) {
|
|
||||||
exports[h] = lessc_helper[h]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import url from 'url'
|
||||||
let request
|
let request
|
||||||
import AbstractFileManager from '../less/environment/abstract-file-manager.js'
|
import AbstractFileManager from '../less/environment/abstract-file-manager.js'
|
||||||
import logger from '../less/logger'
|
import logger from '../less/logger'
|
||||||
import needle from 'needle'
|
|
||||||
|
|
||||||
const UrlFileManager = function () {}
|
const UrlFileManager = function () {}
|
||||||
UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
|
UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||||
|
@ -18,13 +17,6 @@ UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||||
|
|
||||||
loadFile(filename, currentDirectory, options, environment) {
|
loadFile(filename, currentDirectory, options, environment) {
|
||||||
return new Promise((fulfill, reject) => {
|
return new Promise((fulfill, reject) => {
|
||||||
if (request === undefined) {
|
|
||||||
try {
|
|
||||||
request = needle
|
|
||||||
} catch (e) {
|
|
||||||
request = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!request) {
|
if (!request) {
|
||||||
reject({
|
reject({
|
||||||
type: 'File',
|
type: 'File',
|
||||||
|
|
|
@ -19,7 +19,6 @@ import ImportManager from './import-manager'
|
||||||
import Parse from './parse'
|
import Parse from './parse'
|
||||||
import Render from './render'
|
import Render from './render'
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
import parseVersion from 'parse-node-version'
|
|
||||||
|
|
||||||
export default function (environment, fileManagers) {
|
export default function (environment, fileManagers) {
|
||||||
let sourceMapOutput, sourceMapBuilder, parseTree, importManager
|
let sourceMapOutput, sourceMapBuilder, parseTree, importManager
|
||||||
|
@ -33,9 +32,9 @@ export default function (environment, fileManagers) {
|
||||||
const render = Render(environment, parseTree, importManager)
|
const render = Render(environment, parseTree, importManager)
|
||||||
const parse = Parse(environment, parseTree, importManager)
|
const parse = Parse(environment, parseTree, importManager)
|
||||||
|
|
||||||
const v = parseVersion(`v${version}`)
|
const v = version.split('.').map(n => +n)
|
||||||
const initial = {
|
const initial = {
|
||||||
version: [v.major, v.minor, v.patch],
|
version: [v[0], v[1], v[2]],
|
||||||
data,
|
data,
|
||||||
tree,
|
tree,
|
||||||
Environment,
|
Environment,
|
||||||
|
|
|
@ -145,7 +145,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
|
||||||
// @param callback call `callback` when done.
|
// @param callback call `callback` when done.
|
||||||
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
|
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
|
||||||
//
|
//
|
||||||
parse: function (str, callback, additionalData) {
|
parse(str, callback, additionalData) {
|
||||||
let root
|
let root
|
||||||
let err = null
|
let err = null
|
||||||
let globalVars
|
let globalVars
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
/* jshint proto: true */
|
/* jshint proto: true */
|
||||||
import * as Constants from './constants'
|
import * as Constants from './constants'
|
||||||
import { copy } from 'copy-anything'
|
|
||||||
|
function copy(obj = {}) {
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return obj.map(it => copy(it))
|
||||||
|
} else if (typeof obj === 'object') {
|
||||||
|
let tmp = {}
|
||||||
|
for (let k in obj) {
|
||||||
|
if (obj[k] === void 0) {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
if (typeof obj[k] === 'object' && obj[k] !== null) {
|
||||||
|
tmp[k] = copy(obj[k])
|
||||||
|
} else {
|
||||||
|
tmp[k] = obj[k]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp
|
||||||
|
} else {
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getLocation(index, inputStream) {
|
export function getLocation(index, inputStream) {
|
||||||
let n = index + 1
|
let n = index + 1
|
||||||
|
@ -22,14 +43,7 @@ export function getLocation(index, inputStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyArray(arr) {
|
export function copyArray(arr) {
|
||||||
let i
|
return [...arr]
|
||||||
const length = arr.length
|
|
||||||
const copy = new Array(length)
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
copy[i] = arr[i]
|
|
||||||
}
|
|
||||||
return copy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clone(obj) {
|
export function clone(obj) {
|
||||||
|
@ -46,10 +60,10 @@ export function defaults(obj1, obj2) {
|
||||||
let newObj = obj2 || {}
|
let newObj = obj2 || {}
|
||||||
if (!obj2._defaults) {
|
if (!obj2._defaults) {
|
||||||
newObj = {}
|
newObj = {}
|
||||||
const defaults = copy(obj1)
|
const _defaults = copy(obj1)
|
||||||
newObj._defaults = defaults
|
newObj._defaults = _defaults
|
||||||
const cloned = obj2 ? copy(obj2) : {}
|
const cloned = obj2 ? copy(obj2) : {}
|
||||||
Object.assign(newObj, defaults, cloned)
|
Object.assign(newObj, _defaults, cloned)
|
||||||
}
|
}
|
||||||
return newObj
|
return newObj
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue